errorA = DirContents( XDAUC_FOLDER & "\*.tsk", DC_FILES )
fileTSK = IniRead( XDAUC_FOLDER & "\autotsk.ini", "theme", "file" )
tskArray = DirContents( "\Windows\*.tsk", DC_FILES )
###########################################################
# Copy any/all *.tsk Files to \Windows ####################
###########################################################
If ( NOT isEmpty( errorA ) )
XCopy( XDAUC_FOLDER & "\*.tsk", "\Windows", TRUE, FALSE )
Sleep( 10000 )
EndIf
###########################################################
# Set default silent theme ################################
###########################################################
If ( NOT isEmpty( fileTSK ) )
RunWait( "\Windows\cusTSK.exe", "\Windows\" & fileTSK )
Sleep( 5000 )
tskArray = "AUTO"
RedrawToday
EndIf
###########################################################
# If no "silent" file, give choices #######################
###########################################################
If ( isEmpty( tskArray ) )
SleepMessage( 5, "There were no *.tsk files ^NL^found anywhere on the device", "Error:", TRUE )
ElseIf ( tskArray eq "AUTO" )
SleepMessage( 5, "autoTSK.ini was used^NL^to set theme.", "AUTO:", TRUE )
Else
If ( FileExists( XDAUC_FOLDER & "\temp.mscr" ) = TRUE )
Delete( XDAUC_FOLDER & "\temp.mscr" )
EndIf
WriteFile( XDAUC_FOLDER & "\temp.mscr", "ChoiceDefault( ""theme picker"", ""choose a theme:"", 0, 10, tskArray ) ^NL^", TRUE )
ForEach x, file in array( tskArray )
write = " Case(" & x & ") ^NL^ RunWait( ""\Windows\cusTSK.exe"", ""\Windows\" & file & """)^NL^ Sleep( 5000 )^NL^ RedrawToday^NL^"
writeFile( XDAUC_FOLDER & "\temp.mscr", write, TRUE )
EndForEach
WriteFile( XDAUC_FOLDER & "\temp.mscr", "EndChoice^NL^", TRUE )
Sleep( 1000 )
CallScript( XDAUC_FOLDER & "\temp.mscr" )
EndIf
If ( FileExists( XDAUC_FOLDER & "\temp.mscr" ) )
Delete( XDAUC_FOLDER & "\temp.mscr" )
EndIf