Page 1 of 1

Loop with step

PostPosted: Mon Jul 28, 2014 2:01 am
by JoeE.
Hi everyone,

is it ok to manually add a value to the loop counter to have a kind of "FOR.. NEXT.. STEP" thing? Or does this lead to internal stack problems?

Loop "1" "100" "[step]"
SetVar "[TextEntry1]" "[TextEntry1] [step]"
Math "[step]+1" "0" "[step]"
EndLoop

Any better idea?

Thanks for your help!!
Joerg

Re: Loop with step

PostPosted: Mon Jul 28, 2014 6:07 am
by Gaev
JoeE:

This small test ...
Code: Select all
Loop "1" "7" "[Trace]"
   If "[Trace]" ">" "3"
      Math "1+[Trace]" "" "[Trace]"
   EndIf
   AlertBox "Loop" "[Trace]"
EndLoop
... worked as expected.

But if all you want to do is step through the loop in (say) increments of 2 ... this code ...
Code: Select all
Loop "1" "100" "[step]"
   SetVar "[TextEntry1]" "[TextEntry1] [step]"
   Math "[step]+1" "0" "[step]"
EndLoop
... can be done equally with ...
Code: Select all
Loop "1" "50" "[step]"
        Math "2*[step]" "[doubleStep]"
   SetVar "[TextEntry1]" "[TextEntry1] [doubleStep]"
EndLoop

Re: Loop with step

PostPosted: Tue Jul 29, 2014 11:32 am
by JoeE.
Thanks Gaev,

so, there's no stack problem? I remember from other programming languages, not to tweak the increment of (FOR NEXT) loops, because of internal stack problems. The point is, that I will have to run this loop very often, about 100000 times...

Thanks again!
Joerg

Re: Loop with step

PostPosted: Tue Jul 29, 2014 12:35 pm
by Gaev
Joerg:
The point is, that I will have to run this loop very often, about 100000 times...

If you meant something like ...
Code: Select all
Loop "1' "100000" "[loopCounter]"
... you might have to be a very patient man ... do some time tests using your code (within the Loop/EndLoop) for something like 1000 iterations ... then see if you/user can wait 100 times that amount of time.

Re: Loop with step

PostPosted: Tue Jul 29, 2014 9:57 pm
by JoeE.
Gaev,

this is true, but it's a kind of data analysys. I will have to add a progressbar :wink:

Still my question isn't answered...
Joerg

Re: Loop with step

PostPosted: Tue Jul 29, 2014 11:56 pm
by HPW
Hello,

I think you will have no stack Problem.
But I agree with Gaev that neoscript is not always the right tool for high performance Scripting, because of it's interpreted execution.
There are various language Options through plugins (newlisp,powerbasic etc.), which may offer better performance.
So based on your performance-need for data analysys , you might be not satisfied with the Overall-Performance in pure neoscript.

Regards

Re: Loop with step

PostPosted: Wed Jul 30, 2014 12:18 am
by JoeE.
...agreed :) Powerbasic is very fast indeed, but GUI handling is very complicated...
Joerg

Re: Loop with step

PostPosted: Wed Jul 30, 2014 12:29 am
by HPW
Yes, a powerbasic.dll with real compiled mashine code will always beats any interreter, but between Interpreter are some differences.

So use the right tool to get the job done. ;-)

Regards

Re: Loop with step

PostPosted: Wed Jul 30, 2014 6:48 am
by Gaev
Joerg:
it's a kind of data analysys

GUI handling is very complicated...
Perhaps you can describe the Application you had in mind ... it is still possible to exploit NeoBook for its excellent GUI ... and then outsource the "heavy lifting" to Javascript, AutoIt or PowerBasic code.

BTW, David de Argentina is the resident PowerBasic guru ... his plugins are built with PowerBasic ... perhaps he can a create custom plugin that can be called from your NeoBook Application.

Re: Loop with step

PostPosted: Wed Jul 30, 2014 12:33 pm
by David de Argentina
Hi all,

I can see you have two ways:

a) I can create a plugin for the FOR - NEXT structure

b) You can use the NeoThinBasic program: Take a look of this:
http://www.thinbasic.com/public/product ... index.html
at the left panel click on: ThinBasic Language -> Program Flow -> FOR/NEXT

You will find all you need to create your own tbasic program using this structure.

My defaulted cent,
David de Argentina