![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Questions & Help Needed Post any question regarding Basic4ppc. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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. Code:
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) 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 |
|
|||
|
hi thanks, i get what you mean. I will have a look at the mod command, i knew it could be done easier, but i havn't done any programming since microsoft decided to move over to .NET.
I have been programming on the windows for many years, but it was always business orientated, and no complex maths involved. All my experience has been on VB5 and 6. I now have have my program doing 18 algorithms, but am still using panels. ** i paraphrased the code a bit so i was only posting relevant code ** InputNum comes from either a textbox for some of the algorithms or a set of checkboxes (10 bit binary). The reason for the array is that i use many different algorithms which do things in different ways. so i figured use an array so that my code display page runs without any modification regardless of which algorithm im using at that time. I am having to work out my algorithms from a list of input numbers = codes, thats why my code isn't optimized, as i dont have the original algorithms used to generate the codes. Basically i work out how the code from the input number, then try and come up with an algorithm that will solve it. Once it works i try and optimize it to work faster. Basically on my pocket pc, and with the nature of the codes i should ALWAYS be able to calculate the code within 1 second. i'll work on the mod thing, and post back if i solve it. thanks. can a dll show a panel within my program?? Last edited by gangsta : 03-28-2008 at 02:55 PM. |
|
|||
|
just had a look in the online help, and couldn't find the MOD function, is it implimented in basic4ppc???
if not can i use this formula to simulate the mod fuction (from wikipedia): mod(a, n) = a - n * floor(a / n) i have substituted INT in place of floor in the hope that it will still work. which i would impliment in code as something like: Code:
Sub Mod (a, n) Return (a - n) * int(a / n) End Sub |
|
||||
|
Quote:
Quote:
|
|
||||
|
Hi gangsta,
Mod is not a function but an operator, and is implemented in B4PPC. Ex: a = 7 mod 3 result 1 The function means 7 devided 3 equals 2 and the reminder is 1, a is the reminder a = 7 Mod 3 result 1 a = 8 Mod 3 result 2 a = 9 Mod 3 result 0 a = 10 Mod 3 result 1 and so on. I have added a small program you can play with. For your example in the first post, could you explain exactly what you want to do or add some more code with an example to make it easier for others to give you any advice. Best regards
__________________
Klaus Switzerland |
|
|||
|
Hi the program is for decoding.
Eg you supply it with the serial number for the device, and it applys the algorithm to it, to give the unlock code. I have visual basic enterprise edition , can i use that for building dll's to use within basic4ppc or do i have to buy .NET (or will visual studio express work for this) My posted code at the top of the page works perfectly for this algorithm, its just slow ![]() i have been playing with mod, had a look at the demo, so hopefully i'll work it out shortly ![]() thanks Graham |
|
|||
|
woohoo
![]() thanks people, I have wrote a small base convertor based on what I found on the net, it will convert any integer to any other base, but be warned - no boundry checks - I did a stpid mistake when testing it an converted to base 1, my ppc was NOT amused - lol thanks for pointing me in the right direction, I actually enjoy learning new things, and don't mind looking stuff up if im pointed in the right direction. Graham Code:
Sub convertBase(iNum, bNum) Dim q, r, a q = iNum r = iNum Do While q <> 0 r = q Mod bNum q = Int(q / bNum) a = r & a Loop return a End Sub Last edited by gangsta : 03-29-2008 at 09:56 AM. |
|
||||
|
Quote:
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Add Code | giannimaione | Questions & Help Needed | 5 | 06-01-2008 07:03 PM |
| A query to Erel | mozaharul | Questions & Help Needed | 5 | 04-28-2008 12:21 PM |
| Query on webbrowser.dll on HTC Touch WM6 | badkarma | Questions & Help Needed | 8 | 04-11-2008 12:45 PM |
| Microsoft Access Query | somersetrc | Questions & Help Needed | 2 | 11-29-2007 09:29 AM |
| Help with code | cdeane | Questions & Help Needed | 9 | 09-22-2007 05:30 PM |