GodMode9/resources/sample/HelloSpaghetti.gm9
2018-07-23 01:03:50 +02:00

145 lines
2.8 KiB
Plaintext

# GodMode9 "Spaghetti code sample"
# Tutorial script - read / run this to learn how it works
# last changed: 20180118
# author: d0k3
# quick preview mode as default, otherwise slow
set PREVIEW_MODE quick
# choose example to try
labelsel -o -s "Choose example" spaghetti_*
goto outside
# 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
elif ask "?set PREVIEW_MODE V:/GodMode9_splash.png?"
set PREVIEW_MODE V:/GodMode9_splash.png
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
@choice_Preview_png
set PREVIEW_MODE V:/GodMode9_splash.png
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_*
goto outside
# keysel sample code
@spaghetti_keysel_example
@kchoice_X_Preview_off
set PREVIEW_MODE off
goto kchooser
@kchoice_Y_Preview_quick
set PREVIEW_MODE quick
goto kchooser
@kchoice_R_Preview_full
set PREVIEW_MODE full
goto kchooser
@kchoice_L_Preview_png
set PREVIEW_MODE V:/GodMode9_splash.png
goto kchooser
@kchoice_SELECT_Preview_custom
set PREVIEW_MODE "Your text can be here"
input -o "Enter anything:" PREVIEW_MODE
goto kchooser
@kchoice_START_Leave_script
goto outside
@kchooser
labelsel -k -o -s "Choose preview mode via key" kchoice_*
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
@outside