Posted: Mon 19 Sep 2005, 12:13
Lobster,
If you do not write an "if"-condition in 1 line, you must close it with "end if".
Ok:
Wrong:
Ok:
This one works:
Also, you mixed up result and choice.
result just will have one of 3 values:
1=ok
2=cancel
255= Window was destroyed.
Your "1" "2" "3" -values will be returned in the choice-variable.
You can write the example a little bit shorter, using a list.
A list is a list of strings, you can index with a number, like mylist[1] mylist[2] mylist [3].
Look at this example:
Greets, Mark
If you do not write an "if"-condition in 1 line, you must close it with "end if".
Ok:
Code: Select all
if result = 1 then print 1
Code: Select all
if result = 1 then
print 1
Code: Select all
if result = 1 then
print 1
end if
Code: Select all
#!/usr/bin/wxbasicscript
// a menue
include "/usr/lib/wxbasicscript/basefunctions.inc"
//////////////////////////////////////////////////////////////////////
// Menu of available tutorials
dialog = "--title 'Tips' "&
" --menu 'Double click for selected tip "&
" Choose a Section:' 0 0 10 "&
" '1' 'Writing and running a first script' "&
" '2' 'Calling sub programs or procedures' "&
" '3' 'Other stuff'"
result , choice = xdialog ( dialog )
if result != 0 then
dialog = "--title 'info' --msgbox 'dismissed' 0 0"
else
if choice = "1" then dialog = "--title 'info' --msgbox 'Writing and running a first script' 0 0"
if choice = "2" then dialog = "--title 'info' --msgbox 'Calling sub programs or procedures' 0 0"
if choice = "3" then dialog = "--title 'info' --msgbox 'Other stuff' 0 0"
result , choice = xdialog ( dialog )
end if
Also, you mixed up result and choice.
result just will have one of 3 values:
1=ok
2=cancel
255= Window was destroyed.
Your "1" "2" "3" -values will be returned in the choice-variable.
You can write the example a little bit shorter, using a list.
A list is a list of strings, you can index with a number, like mylist[1] mylist[2] mylist [3].
Look at this example:
Code: Select all
#!/usr/bin/wxbasicscript
// creating Menue with a list
include "/usr/lib/wxbasicscript/basefunctions.inc"
//////////////////////////////////////////////////////////////////////
// Menu of available tutorials
//--- Putting the menue-points to a list
MP = { "Writing and running a first script" , "Calling sub programs or procedures" , "Other stuff" }
dialog = "--title 'Tips' "&
" --menu 'Double click for selected tip "&
" Choose a Section:' 0 0 10 "&
" '1' '" & MP[1] & "' "&
" '2' '" & MP[2] & "' "&
" '3' '" & MP[3] & "'"
result , choice = xdialog ( dialog )
if result != 0 then
dialog = "--title 'info' --msgbox 'dismissed' 0 0"
else
//--- to use the value of the string choice as an index-number, we must convert it to a number using "val()"
result , choice = xdialog ( "--title 'info' --msgbox '" & MP[val(choice)] & "' 0 0" )
end if