GodMode9/resources/sample/HelloSpaghetti.gm9

113 lines
2.2 KiB
Plaintext
Raw Normal View History

2017-12-29 17:25:32 +01:00
# GodMode9 "Spaghetti code sample"
# Tutorial script - read / run this to learn how it works
2018-01-18 02:23:46 +01:00
# last changed: 20180118
2017-12-29 17:25:32 +01:00
# author: d0k3
2018-01-18 02:23:46 +01:00
# quick preview mode as default, otherwise slow
set PREVIEW_MODE quick
2017-12-29 17:25:32 +01:00
# choose example to try
2018-01-18 02:23:46 +01:00
labelsel -o -s "Choose example" spaghetti_*
goto outside
2017-12-29 17:25:32 +01:00
# if-else-elif-end sample code
@spaghetti_ifelse_example
if ask "?set PREVIEW_MODE off?"
set PREVIEW_MODE off
elif ask "?set PREVIEW_MODE quick?"
set PREVIEW_MODE quick
elif ask "?set PREVIEW_MODE full?"
set PREVIEW_MODE full
2018-03-29 22:12:53 -03:00
elif ask "?set PREVIEW_MODE V:/GodMode9_splash.png?"
set PREVIEW_MODE V:/GodMode9_splash.png
2017-12-29 17:25:32 +01:00
elif ask "?set PREVIEW_MODE 'No preview for you, sorry'?"
set PREVIEW_MODE "No preview for you, sorry"
else
echo "**Nothing**"
end
if ask "Try this again?"
goto spaghetti_ifelse_example
end
goto outside
# labelsel sample code
@spaghetti_labelsel_example
@choice_Preview_off
set PREVIEW_MODE off
goto chooser
@choice_Preview_quick
set PREVIEW_MODE quick
goto chooser
@choice_Preview_full
set PREVIEW_MODE full
goto chooser
2018-03-29 22:12:53 -03:00
@choice_Preview_png
set PREVIEW_MODE V:/GodMode9_splash.png
2017-12-29 17:25:32 +01:00
goto chooser
@choice_Preview_custom
set PREVIEW_MODE "Your text can be here"
input -o "Enter anything:" PREVIEW_MODE
goto chooser
@choice_Leave_script
goto outside
@chooser
labelsel -o -s "Choose preview mode" choice_*
2018-01-18 02:23:46 +01:00
goto outside
# for-next sample code
@spaghetti_fornext_sample
echo "This will display entries\nfrom your SD card root."
if ask "Use recursive 'for'?"
for -r 0: *
# check type of current entry
set TYPE "File"
if isdir $[FORPATH]
set TYPE "Dir"
end
# output on screen
if not ask "$[TYPE]: $[FORPATH]\nShow next entry?"
goto outside
end
next
else
for 0: * # everything inside the loop pretty much identical to above
# check type of current entry
set TYPE "File"
if isdir $[FORPATH]
set TYPE "Dir"
end
# output on screen
if not ask "$[TYPE]: $[FORPATH]\nShow next entry?"
goto outside
end
if not exist $[FORPATH]
echo "WTF" # can never happen here, just a demonstration
end
next
end
goto outside
2017-12-29 17:25:32 +01:00
@outside