When trying to run this code in Windows, it crashes with pop-up dialogue error "Unrecognised Instruction 0 in at line 0" - followed by a message in the app window: "Tap/click the screen to exit":
// Project: getordinals
// Created: 2015-05-20
// set window properties
SetWindowTitle( "getordinals" )
SetWindowSize( 640, 640, 0 )
// set display properties
SetVirtualResolution( 640, 640 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate(0,0)
do
printc(1)
print(GetOrdinals$(1))
printc(58)
print(GetOrdinals$(58))
printc(23)
print(GetOrdinals$(23))
printc(112)
print(GetOrdinals$(112))
Print( ScreenFPS() )
Sync()
loop
function GetOrdinals$(number)
` Accepts an integer, returns the ordinal suffix
` Handles special case three digit numbers ending
` with 11, 12 or 13 - ie, 111th, 112th, 113th, 211th, et al
If Number > 99
intEndNum = val(right(str(Number),2))
If intEndNum >= 11 And intEndNum <= 13
Select intEndNum
Case 11:
exitfunction "th"
endcase
case 12:
exitfunction "th"
endcase
case 13:
exitfunction "th"
endcase
EndSelect
EndIf
EndIf
If Number >= 21
` Handles 21st, 22nd, 23rd, et al
wrknum = val(right(str(Number),1))
Select wrknum
Case 1:
exitfunction "st"
EndCase
Case 2:
exitfunction "nd"
EndCase
Case 3:
exitfunction "rd"
EndCase
Case default:
exitfunction "th"
EndCase
EndSelect
Else
` Handles 1st to 20th
Select Number
Case 1:
exitfunction "st"
EndCase
Case 2:
exitfunction "nd"
EndCase
Case 3:
exitfunction "rd"
EndCase
Case default:
exitfunction "th"
EndCase
EndSelect
EndIf
EndFunction "Error!"
If I replace one of the "Case default" statements, it works fine:
// Project: getordinals
// Created: 2015-05-20
// set window properties
SetWindowTitle( "getordinals" )
SetWindowSize( 640, 640, 0 )
// set display properties
SetVirtualResolution( 640, 640 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate(0,0)
do
printc(1)
print(GetOrdinals$(1))
printc(58)
print(GetOrdinals$(58))
printc(23)
print(GetOrdinals$(23))
printc(112)
print(GetOrdinals$(112))
Print( ScreenFPS() )
Sync()
loop
function GetOrdinals$(number)
` Accepts an integer, returns the ordinal suffix
` Handles special case three digit numbers ending
` with 11, 12 or 13 - ie, 111th, 112th, 113th, 211th, et al
If Number > 99
intEndNum = val(right(str(Number),2))
If intEndNum >= 11 And intEndNum <= 13
Select intEndNum
Case 11:
exitfunction "th"
endcase
case 12:
exitfunction "th"
endcase
case 13:
exitfunction "th"
endcase
EndSelect
EndIf
EndIf
If Number >= 21
` Handles 21st, 22nd, 23rd, et al
wrknum = val(right(str(Number),1))
Select wrknum
Case 1:
exitfunction "st"
EndCase
Case 2:
exitfunction "nd"
EndCase
Case 3:
exitfunction "rd"
EndCase
case 0:
exitfunction "th"
endcase
case 4:
exitfunction "th"
endcase
case 5:
exitfunction "th"
endcase
case 6:
exitfunction "th"
endcase
case 7:
exitfunction "th"
endcase
case 8:
exitfunction "th"
endcase
case 9:
exitfunction "th"
endcase
EndSelect
Else
` Handles 1st to 20th
Select Number
Case 1:
exitfunction "st"
EndCase
Case 2:
exitfunction "nd"
EndCase
Case 3:
exitfunction "rd"
EndCase
Case default:
exitfunction "th"
EndCase
EndSelect
EndIf
EndFunction "Error!"
Is this a bug with "CASE DEFAULT"? - The last batch of case statements also includes a CASE DEFAULT but works fine. Very odd.