You understood that script is a group of commands and it is processed in an order from the 1st line. You understood script stops by "stop" commnad. Now let's leran command that controls flow of program. It's sound like a bit difficult.
Let's stand flags in script. What?! What mean stand flags?? It means put a sign on a specific line in script. That is like when a mountanieer climbs a mountain, who put sign(s) on trail(s). Script like this
*flag1 | |
cls | |
*flag2 | |
mes "Hello, how are you?" | |
*flag3 | |
mes "Test to stand flags in script" | |
stop |
There are 3 flags are standing. These are "*flag1","*flag2" and "*flag3".You can stand a flag with your prefered name and place just putting an alphbetic name following "*"(astarisku). Rule for this,
1. do not put TAB, it's diffrent from command |
2. alaphbetic name (maximun 20 characters) follows by * |
3. same name can not exist |
You may have following question, "But what I can get with standing those flags?" If you run script above example,
Hello, how are you? |
Test to stand flags in script |
Like above result, that is same one that the command performed from first line you have already lerned. No effect those flags. Now, let change script as follows.
*flag1 | |
cls | |
goto *flag3 | |
*flag2 | |
mes "Hello, how are you?" | |
*flag3 | |
mes "Test to stand flags in script" | |
stop |
You can see mistalious command, "goto *flag3" in third line this time. Let run script without thinking now.
Only above message displayed. The command "goto" changed a flow of script. The command "goto" change execution order of script to the flag that is specified at paramerter. The falgs stood until now become useful. Execution from 1st line, jump to "flag3" in 6th line by "goto" command in 3rd line without execute 4th and 5th lines. Then, following commnad executed.
Thus, standing flag(s) brings the flow of script to somewhere else. It is for specifying the place. And this is formally called "label". Let's call label instead of flag. Therefor 6th line is labelname "*flag3". Command "goto" that jump to labelname where is specified.
And if this label is used, application will spread further. Now, let's input the following script newly.
cls | |
mes "Push a button" | |
button "PUSH",*flag1 | |
button "BYE",*flag2 | |
stop | |
*flag1 | |
mes "Oh, You have pressed, didn't you" | |
stop | |
*flag2 | |
end |
Let's run script now. The button has apperaed. If you crick the button that is written 'PUSH' the message 'Oh, You have pressed, didn't you' should come up. If you crick the button 'BYE', the window will be disappeared and stop.
1.display a button |
2.display a strings specified on the button |
3.if the button is pressed jump to the label specified |
The command 'button' has two parameters those are diffrent from other command. Those are '"PUSH"' and '*flag1' in the third line. Thus, it comes cout after like multiple parameters belongs to command. You have to put ',(comma)', this is a rule.Therefore
button | "PUSH" , | *flag1 |
| | | | | |
| | | | | |
command | parameter1 | parameter2 |
On 'button' command, you can specify as parameter 1 is text string to be displayed on a button parameter 2 is label where jump to when button is cricked.
What will happen if a button 'BYE' is pressed? It jumps to the label '*flag2' there is a 'end' command ahead. The command is quite simple. It will end script as it means. When 'end' command is executed, it will disapper a window and end an application. It becomes same thing when you press alt+F4 or choose 'close' menu.
Now, the application range spreads further now. The possibility came out that it was as that another message is displayed by pushing a button or displaying other picture. Let's review here just for a moment and memorizes perfectly. Let's go to next
command(statement) | parameter | meaning |
end | none | end script |
goto | label | jump to label that is specified |
button | text string,label | display button with a text string then jump to label that is specified when a button cricked |