Hi all, first off - ive only had basic4ppc for about 4 days, but im really loving it. That me onto my forth program now - so i think i'll be buying the full program soon. I work in a petrol station, and find that when its quiet i can sit and do my programming without any problems, really does make the days go by quicker .
Anyway back on topic.
I have wrote a bit of code, but it takes too long to run (well about 10 seconds) I know that what i want can be done almost instantly but i dont have my thinking cap on.
Can anyone optimize this code for me, either by shifting bits, multiplication or whatever.
so that is the first problem.
the second is that i have a '3 step program', just now i am using panels for the different steps and hiding and showing them as needed.
the program is like this.
Step 1... choose an item from a combo box
Step 2... show the panel corresponding to the option chosen in Step 1
this panel could include combo boxes, text boxes, check boxes or whatever. clicking 'next' on this panel does a calculation on the data given in the panel, and passes it on to panel 3
Step 3... Show the result, this will be a number of indeterminate length, usually 4-8 digits
So far i have created 6 option for step 1, therefore i have 6 panel 2's, and its starting to get confusing. Im also worried about using too many controls on a single form (up to about 100 or so, so far) and i want to bump it up to around 50 options (therefore 50 panels * about 12 controls each)
I imagine that will also start to slow down the program.
It also means that i need to supply a full new program each time i make a change.
What i want to do.
I want the program to start,... then look through the app directory for DLL's, each one it finds - it interrogates, to get its name, and adds it the list in step 1.
If you choose an option, then for step 2, the THE DLL SHOWS A PANEL/FORM/WHATEVER that looks like part of the host application, when the DLL panel has been filled, it hides its panel, does its maths (different for each DLL) and returns the number for my program to display on the Step 3 page.
Is this possible to use DLLs in this way, can they be dynamically loaded at run time, can they display information in my application.
This would mean that as i develop new algorithms, i just need to send out new DLLs, or if i need to alter an algorithm, again just a replacement DLL.
Id like to add the ability to download additional DLL's over the air, then add them dynamically to the list of options.
If im going about this all wrong, please can you point me in the right direction.
Thanks
Graham
Anyway back on topic.
I have wrote a bit of code, but it takes too long to run (well about 10 seconds) I know that what i want can be done almost instantly but i dont have my thinking cap on.
Can anyone optimize this code for me, either by shifting bits, multiplication or whatever.
B4X:
dim tmpcode(3)
dim codecount,loopa,loopb,inputnum
tmpcode(0)=1
tmpcode(1)=1
tmpcode(2)=1
tmpcode(3)=1
inputnum = *****a number between 0 and 1023*****
for loopa = 0 to codecount - 1
tmpcode(3) = tmpcode(3) + 1
for loopb = 3 to 1 step -1
if tmpcode(loopb) = 7 then
tmpcode(loopb) = 1
tmpcode(loopb - 1) = tmpcode (loopb - 1) + 1
end if
next loopb
next loopa
txtOutput.text = tmpcode(0) & tmpcode(1) & tmpcode(2) & tmpcode(3)
so that is the first problem.
the second is that i have a '3 step program', just now i am using panels for the different steps and hiding and showing them as needed.
the program is like this.
Step 1... choose an item from a combo box
Step 2... show the panel corresponding to the option chosen in Step 1
this panel could include combo boxes, text boxes, check boxes or whatever. clicking 'next' on this panel does a calculation on the data given in the panel, and passes it on to panel 3
Step 3... Show the result, this will be a number of indeterminate length, usually 4-8 digits
So far i have created 6 option for step 1, therefore i have 6 panel 2's, and its starting to get confusing. Im also worried about using too many controls on a single form (up to about 100 or so, so far) and i want to bump it up to around 50 options (therefore 50 panels * about 12 controls each)
I imagine that will also start to slow down the program.
It also means that i need to supply a full new program each time i make a change.
What i want to do.
I want the program to start,... then look through the app directory for DLL's, each one it finds - it interrogates, to get its name, and adds it the list in step 1.
If you choose an option, then for step 2, the THE DLL SHOWS A PANEL/FORM/WHATEVER that looks like part of the host application, when the DLL panel has been filled, it hides its panel, does its maths (different for each DLL) and returns the number for my program to display on the Step 3 page.
Is this possible to use DLLs in this way, can they be dynamically loaded at run time, can they display information in my application.
This would mean that as i develop new algorithms, i just need to send out new DLLs, or if i need to alter an algorithm, again just a replacement DLL.
Id like to add the ability to download additional DLL's over the air, then add them dynamically to the list of options.
If im going about this all wrong, please can you point me in the right direction.
Thanks
Graham