10-04-2022, 11:22 PM
Hi
here the code developed by me following the idea of ON ERROR GOTO
As you can see for the nature of ON ERROR GOTO label you need to put a part of code into MAIN and the rest of code into a FUNCTION.
I hope you like this routine.
here the code developed by me following the idea of ON ERROR GOTO
Code: (Select All)
$Debug
Dim Mode As Integer, M As Integer
For M = 12 To 1 Step -1
If M < 4 Then Mode = M - 1
If M > 3 And M < 11 Then Mode = M + 3
If M = 11 Then Mode = 256
If M = 12 Then Mode = 32
Screen _NewImage(400, 400, Mode)
Print ScreenMode
Sleep 2
Next
End
NewTry:
If Mode = 32 Then
Print "error "; Mode
Mode = 13
ElseIf Mode = 13 Then
Print "error "; Mode
Mode = 12
ElseIf Mode = 12 Then
Print "error "; Mode
Mode = 11
ElseIf Mode = 11 Then
Mode = 10
ElseIf Mode = 10 Then
Mode = 9
ElseIf Mode = 9 Then
Mode = 8
ElseIf Mode = 8 Then
Mode = 7
ElseIf Mode = 7 Then
Mode = 2
ElseIf Mode = 2 Then
Mode = 1
ElseIf Mode = 1 Then
Mode = 0
ElseIf Mode = 0 Then
Mode = 999
End If
Resume Next
End
Function ScreenMode
' it try to discover the screen MODE used for SCREEN settings
Shared Mode As Integer
On Error GoTo NewTry
' Mode = 32
If Mode = 32 Then
'32
Paint (_Width(0) / 2, _Height(0) / 2), _RGB32(255, 255, 0)
ElseIf Mode = 13 Then
'256
Paint (_Width(0) / 2, _Height(0) / 2), 56
ElseIf Mode = 12 Then
'12
Paint (_Width(0) / 2, _Height(0) / 2), 15
ElseIf Mode = 11 Then
'11
Color 1
ElseIf Mode = 10 Then
'10
Color 4
ElseIf Mode = 9 Then
'9
Paint (_Width(0) / 2, _Height(0) / 2), 16
ElseIf Mode = 8 Then
'8
Paint (_Width(0) / 2, _Height(0) / 2), 16
ElseIf Mode = 7 Then
'7
Paint (_Width(0) / 2, _Height(0) / 2), 16
ElseIf Mode = 2 Then
'2
Color 2
ElseIf Mode = 1 Then
' 1
Color 15
ElseIf Mode = 0 Then
'0
Color 31
End If
On Error GoTo 0
ScreenMode = Mode
End Function
As you can see for the nature of ON ERROR GOTO label you need to put a part of code into MAIN and the rest of code into a FUNCTION.
I hope you like this routine.