Getting the SCREEN mode
#29
Hi
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.
Reply


Messages In This Thread
Getting the SCREEN mode - by TerryRitchie - 09-29-2022, 04:04 PM
RE: Getting the SCREEN mode - by Pete - 09-29-2022, 08:25 PM
RE: Getting the SCREEN mode - by TerryRitchie - 09-29-2022, 08:36 PM
RE: Getting the SCREEN mode - by Pete - 09-29-2022, 08:45 PM
RE: Getting the SCREEN mode - by RhoSigma - 09-29-2022, 09:00 PM
RE: Getting the SCREEN mode - by mnrvovrfc - 09-29-2022, 11:06 PM
RE: Getting the SCREEN mode - by Pete - 09-30-2022, 12:04 AM
RE: Getting the SCREEN mode - by TerryRitchie - 09-30-2022, 02:30 AM
RE: Getting the SCREEN mode - by mnrvovrfc - 09-30-2022, 03:15 AM
RE: Getting the SCREEN mode - by TerryRitchie - 09-30-2022, 03:12 PM
RE: Getting the SCREEN mode - by mnrvovrfc - 09-30-2022, 04:21 PM
RE: Getting the SCREEN mode - by TerryRitchie - 09-30-2022, 04:38 PM
RE: Getting the SCREEN mode - by mnrvovrfc - 09-30-2022, 05:46 PM
RE: Getting the SCREEN mode - by RhoSigma - 09-30-2022, 08:15 AM
RE: Getting the SCREEN mode - by TerryRitchie - 09-30-2022, 03:05 PM
RE: Getting the SCREEN mode - by Pete - 09-30-2022, 02:37 AM
RE: Getting the SCREEN mode - by bplus - 09-30-2022, 02:38 AM
RE: Getting the SCREEN mode - by bplus - 09-30-2022, 02:57 AM
RE: Getting the SCREEN mode - by Pete - 09-30-2022, 03:01 AM
RE: Getting the SCREEN mode - by bplus - 09-30-2022, 03:10 AM
RE: Getting the SCREEN mode - by Pete - 09-30-2022, 03:21 PM
RE: Getting the SCREEN mode - by Pete - 09-30-2022, 04:24 PM
RE: Getting the SCREEN mode - by Pete - 09-30-2022, 04:47 PM
RE: Getting the SCREEN mode - by TerryRitchie - 09-30-2022, 04:51 PM
RE: Getting the SCREEN mode - by Pete - 09-30-2022, 05:00 PM
RE: Getting the SCREEN mode - by Pete - 09-30-2022, 05:58 PM
RE: Getting the SCREEN mode - by mnrvovrfc - 09-30-2022, 05:59 PM
RE: Getting the SCREEN mode - by TempodiBasic - 10-03-2022, 11:13 PM
RE: Getting the SCREEN mode - by TempodiBasic - 10-04-2022, 11:22 PM
RE: Getting the SCREEN mode - by SMcNeill - 10-07-2022, 09:56 AM
RE: Getting the SCREEN mode - by TempodiBasic - 10-08-2022, 02:57 AM
RE: Getting the SCREEN mode - by Kernelpanic - 10-07-2022, 03:14 PM
RE: Getting the SCREEN mode - by TempodiBasic - 10-08-2022, 03:01 AM



Users browsing this thread: 11 Guest(s)