Source language: Translate to:

Loop with step

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Loop with step

Postby JoeE. » Mon Jul 28, 2014 2:01 am

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
JoeE.
 
Posts: 9
Joined: Wed Jan 12, 2011 6:08 am

Re: Loop with step

Postby Gaev » Mon Jul 28, 2014 6:07 am

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
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Loop with step

Postby JoeE. » Tue Jul 29, 2014 11:32 am

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
JoeE.
 
Posts: 9
Joined: Wed Jan 12, 2011 6:08 am

Re: Loop with step

Postby Gaev » Tue Jul 29, 2014 12:35 pm

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.
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Loop with step

Postby JoeE. » Tue Jul 29, 2014 9:57 pm

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
JoeE.
 
Posts: 9
Joined: Wed Jan 12, 2011 6:08 am

Re: Loop with step

Postby HPW » Tue Jul 29, 2014 11:56 pm

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
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Loop with step

Postby JoeE. » Wed Jul 30, 2014 12:18 am

...agreed :) Powerbasic is very fast indeed, but GUI handling is very complicated...
Joerg
JoeE.
 
Posts: 9
Joined: Wed Jan 12, 2011 6:08 am

Re: Loop with step

Postby HPW » Wed Jul 30, 2014 12:29 am

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
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Loop with step

Postby Gaev » Wed Jul 30, 2014 6:48 am

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.
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Loop with step

Postby David de Argentina » Wed Jul 30, 2014 12:33 pm

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
User avatar
David de Argentina
 
Posts: 1560
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest