dmonckton Contributor
Joined: 09 Aug 2002 Posts: 117 Location: Lewes, U.K.
|
Posted: Tue May 04, 2004 8:51 am Post subject: Vectored Execution ... sort of |
|
|
Hi
I've come up with a solution to speeding up the process deciding which part of the script should be executed from a large number of choices.
Say the script had to choose from 50 options you could put in 50 if...then statements and jump off from them. But what if your choice if the 50th then the script would have to do 50 tests which is a waste of processing time.
My solution is to use a list containing all the labels that are targeted and go straight to that item in the list and jump from there.
Please feel free to slag my script off as this is what usually happens when I post stuff on the forum.
Code: |
Title Vectored Execution
DIALOG CREATE,New Dialog,-1,0,189,127
DIALOG ADD,COMBO,COMBO1,30,80,48,21,1
DIALOG ADD,BUTTON,BUTTON1,74,48,86,24,RUN SECTION
DIALOG ADD,TEXT,TEXT1,32,38,,,Section
DIALOG SHOW
list loadtext,COMBO1
"1
"2
"3
"4
list create,1
list loadtext,1
"section1
"section2
"section3
"section4
:Evloop
wait event
goto @event()
:BUTTON1BUTTON
%a = @dlgtext(combo1)
%a = @pred(%a)
%b = @item(1,%a)
goto %b
:section1
info Section 1
goto evloop
:section2
info Section 2
goto evloop
:section3
info Section 3
goto evloop
:section4
info Section 4
goto evloop
:Close
list close,1
exit
|
|
|