Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Screen Savers
#62
Here is an experimental version that lets you try different math functions (SIN / COS / etc.) for Plasma and pset color. 

Press arrow up/down to change the function used by Plasma~& 
and left/right to change the function used for the pset color

Some of them cause errors, but the program traps the errors, and at the end reports on which failed. 
A couple of them fail in a really spectacular way, where the spin reverses, and everything accelerates and gets sucked into the center lika black hole! 
If only we could keep that going for a little longer it would be even neater!  Big Grin

The math for this stuff is a little beyond my comprehension, I'm just plugging numbers in to see what works. 
The result is really cool looking for certain combinations!!

I would love to see any modifications anyone has that change the look in cool ways... 

Code: (Select All)
' Eye Candy #9B by bplus, Mini-Mod
' 04-30-2022, 07:55 PM (This post was last modified: 04-30-2022, 08:19 PM by bplus.)
' https://qb64phoenix.com/forum/showthread.php?tid=219&pid=1291#pid1291

_Title "Eye Candy #9B Closer (fullscreen)(debug)" ' b+ 2022-03-09
' fullscreen mod by Steve. 2025-04-17
' mods by madscijr, 2025-04-17:
' - added Steve's mouse check (touch mouse to close, for screen saver)
' - hotkey to try different functions e.g., SIN COS TAN _COT _CSC _SEC etc.
' - catch errors, log & avoid functions which errored out
' - show report detailing which functions worked/failed

' INSTRUCTIONS:
' LEFT/RIGHT...............next/previous function #1
' UP  /DOWN ...............next/previous function #2
' SPACE....................show/hide function names/values
' ESC OR MOVE MOUSE........quit
' (any other key)..........restart cycle/new colors

Option _Explicit
DefDbl A-Z

Const fps = 80
Const cSecondsPerFunction = 30 ' # seconds before next function cycles

' KEY CODES FOR _BUTTON
Const KeyCode_Escape = 2
Const KeyCode_Spacebar = 58
Const KeyCode_Enter = 29
Const KeyCode_Up = 329
Const KeyCode_Down = 337
Const KeyCode_Left = 332
Const KeyCode_Right = 334

Type FunctionType
    Name As String ' description of the code to try
    ErrorMessage As String ' if code has failed contains error message
End Type

Type IndexType
    Name As String ' description of current code
    Index As Integer ' index of current code
    Min As Integer ' minimum index of code array to try
    Max As Integer ' maximum index of code array to try
    TriedMin As Integer ' lowest index tried
    TriedMax As Integer ' highest index tried
End Type

ReDim Shared arrFunction(0 To 50, 0 To 1) As FunctionType
ReDim Shared arrWhich(0 To 1) As IndexType ' index of current function select case checks for
ReDim Shared arrText(1 To 2, 1 To 255) As String ' (column, line)
'redim Shared arrRows(1 to 2) as integer

ReDim Shared colr(0 To 0) As _Unsigned Long
Dim Shared cN, pR, pG, pB
Dim Shared diag As Single
Dim Shared ErrCount As Integer: ErrCount = 0

Dim xmax, ymax As Integer
Dim p2 As Single
Dim xc, yc As Single
Dim a As Single
Dim r As Single
Dim sx1, sy1, sx2, sy2, sx3, sy3, dx1, dy1, dx2, dy2, dx3, dy3 As Long
Dim toggle As Integer: toggle = 0
Dim source&: source& = 0
Dim ro As Single
Dim s As Single

Dim k$
Dim LastKey$: LastKey$ = ""
Dim iLastKeyCode%: iLastKeyCode% = 0

Dim iTo#
Dim iStep#

'Dim Shared iFuncNum% ' index of current function select case checks for
Dim Shared FuncName$ ' name of current function
Dim bShowFuncName%: bShowFuncName% = _TRUE

Dim iFrameCount% ' counts frames
Dim iFramesPerFunction% ' # frames before next function cycles

Dim iValue%, iLoop%, iIndex%, iLine%

Dim message$
Dim MaxCols%, MaxRows% ' for printing text on screen
Dim ColNum, RowNum, FirstRow, LastRow, NoRow, GoodRows, BadRows As Integer
Dim NextLine$
Dim InstColor~&: InstColor~& = _RGB32(0, 0, 0)

Dim OldMouseX, OldMouseY As Integer

Dim Shared LastCode$ ' where in the code we are
Dim Shared LastChangedIndex As Integer ' which set of functions we changed
Dim Shared LastError$: LastError$ = ""

Dim bFinished As Integer: bFinished = _FALSE

' SET ERROR TRAPPING
LastCode$ = ""
LastChangedIndex = -1
LastError$ = ""
On Error GoTo ErrorHandler

' INITIALIZE
iFramesPerFunction% = cSecondsPerFunction * fps

xmax = _DesktopWidth
ymax = _DesktopHeight
Screen _NewImage(xmax, ymax, 32)
'_ScreenMove 0, 0
_FullScreen
_Display

_Delay 2 ' wait a couple seconds before getting mouse coords
While _MouseInput: Wend: OldMouseX = _MouseX: OldMouseY = _MouseY ' initial mouse placement

' for printing text
MaxCols% = (xmax / _FontWidth)
MaxRows% = (ymax / _FontHeight)
FirstRow = (MaxRows% / 2) - 2

' Center:
xc = xmax / 2
yc = ymax / 2

diag = Sqr(xc * xc + yc * yc)

ReDim colr(-100 To diag + 1000) As _Unsigned Long
p2 = _Pi * 2


arrWhich(0).Min = 0 ' min value select case checks for in Function Plasma~&
arrWhich(0).Max = 5 ' max value select case checks for in Function Plasma~&
arrWhich(0).Index = arrWhich(0).Min
arrWhich(0).TriedMin = arrWhich(0).Index ' lowest index tried
arrWhich(0).TriedMax = arrWhich(0).Index ' highest index tried


arrWhich(1).Min = LBound(arrFunction, 1)
arrWhich(1).Max = UBound(arrFunction, 1)
arrWhich(1).Index = arrWhich(1).Min
arrWhich(1).TriedMin = arrWhich(1).Index ' lowest index tried
arrWhich(1).TriedMax = arrWhich(1).Index ' highest index tried

iFrameCount% = 0

Randomize Timer

_Delay 2 ' wait a couple seconds before getting mouse coords
While _MouseInput: Wend: OldMouseX = _MouseX: OldMouseY = _MouseY ' initial mouse placement

While 1
    LastCode$ = "ReInitPlasma" ' Save code location for error handler
    ReInitPlasma
   
    ro = 950
    s = 0
    While ro > -50
        ' PROCESS KEYBOARD INPUT
        LastCode$ = "KEYBOARD" ' Save code location for error handler
        While _DeviceInput(1): Wend ' clear and update the keyboard buffer
        If _Button(KeyCode_Escape) Then
            ' ESC = QUIT
            iLastKeyCode% = KeyCode_Escape
            bFinished = _TRUE: Exit While

        ElseIf _Button(KeyCode_Up) Then
            ' TRY NEXT FUNCTION #1
            If iLastKeyCode% <> KeyCode_Up Then
                ' Remember last key pressed to prevent holding it down
                iLastKeyCode% = KeyCode_Up

                ' Move to the next function that hasn't had an error
                Do
                    arrWhich(0).Index = arrWhich(0).Index + 1
                    If arrWhich(0).Index > arrWhich(0).Max Then arrWhich(0).Index = arrWhich(0).Min
                    If arrWhich(0).Index > arrWhich(0).TriedMax Then arrWhich(0).TriedMax = arrWhich(0).Index ' highest index tried
                    If arrWhich(0).Index < arrWhich(0).TriedMin Then arrWhich(0).TriedMin = arrWhich(0).Index ' lowest index tried
                    If Len(arrFunction(arrWhich(0).Index, 0).ErrorMessage) = 0 Then Exit Do
                Loop
               
                ' Remember this was the last parameter user changed
                LastChangedIndex = 0
               
                ' Update values
                ReInitPlasma
               
                ' restart cycle
                Exit While
            End If

        ElseIf _Button(KeyCode_Down) Then
            ' TRY PREVIOUS FUNCTION #1
            If iLastKeyCode% <> KeyCode_Down Then
                ' Remember last key pressed to prevent holding it down
                iLastKeyCode% = KeyCode_Down

                ' Move to the next function that hasn't had an error
                Do
                    arrWhich(0).Index = arrWhich(0).Index - 1
                    If arrWhich(0).Index < arrWhich(0).Min Then arrWhich(0).Index = arrWhich(0).Max
                    If arrWhich(0).Index > arrWhich(0).TriedMax Then arrWhich(0).TriedMax = arrWhich(0).Index ' highest index tried
                    If arrWhich(0).Index < arrWhich(0).TriedMin Then arrWhich(0).TriedMin = arrWhich(0).Index ' lowest index tried
                    If Len(arrFunction(arrWhich(0).Index, 0).ErrorMessage) = 0 Then Exit Do
                Loop

                ' Remember this was the last parameter user changed
                LastChangedIndex = 0
               
                ' Update values
                ReInitPlasma
               
                ' restart cycle
                Exit While
            End If


        ElseIf _Button(KeyCode_Right) Then
            ' TRY NEXT FUNCTION #2
            If iLastKeyCode% <> KeyCode_Right Then
                ' Remember last key pressed to prevent holding it down
                iLastKeyCode% = KeyCode_Right

                ' Move to the next function that hasn't had an error
                Do
                    arrWhich(1).Index = arrWhich(1).Index + 1
                    If arrWhich(1).Index > arrWhich(1).Max Then arrWhich(1).Index = arrWhich(1).Min
                    If arrWhich(1).Index > arrWhich(1).TriedMax Then arrWhich(1).TriedMax = arrWhich(1).Index ' highest index tried
                    If arrWhich(1).Index < arrWhich(1).TriedMin Then arrWhich(1).TriedMin = arrWhich(1).Index ' lowest index tried
                    If Len(arrFunction(arrWhich(1).Index, 1).ErrorMessage) = 0 Then Exit Do
                Loop
               
                ' Remember this was the last parameter user changed
                LastChangedIndex = 1
               
                ' restart cycle
                Exit While
            End If

        ElseIf _Button(KeyCode_Left) Then
            ' TRY PREVIOUS FUNCTION #2
            If iLastKeyCode% <> KeyCode_Left Then
                ' Remember last key pressed to prevent holding it down
                iLastKeyCode% = KeyCode_Left

                ' Move to the next function that hasn't had an error
                Do
                    arrWhich(1).Index = arrWhich(1).Index - 1
                    If arrWhich(1).Index < arrWhich(1).Min Then arrWhich(1).Index = arrWhich(1).Max
                    If arrWhich(1).Index > arrWhich(1).TriedMax Then arrWhich(1).TriedMax = arrWhich(1).Index ' highest index tried
                    If arrWhich(1).Index < arrWhich(1).TriedMin Then arrWhich(1).TriedMin = arrWhich(1).Index ' lowest index tried
                    If Len(arrFunction(arrWhich(1).Index, 1).ErrorMessage) = 0 Then Exit Do
                Loop
               
                ' Remember this was the last parameter user changed
                LastChangedIndex = 1
               
                ' restart cycle
                Exit While
            End If

        ElseIf _Button(KeyCode_Spacebar) Then
            ' ENTER = SHOW/HIDE FUNCTION NAME
            If iLastKeyCode% <> KeyCode_Spacebar Then
                bShowFuncName% = Not (bShowFuncName%)
                iLastKeyCode% = KeyCode_Spacebar
            End If
        Else
            ' Clear last keycode pressed (since it wasn't any of those)
            iLastKeyCode% = 0

            ' Now detect using InKey$
            k$ = InKey$: _KeyClear
            If Len(k$) Then
                If k$ = "1" Then
                    If LastKey$ <> "1" Then
                        ' Remember last key pressed to prevent holding it down
                        LastKey$ = "1"

                        ' Mark current func #1 as "rejected"
                        arrFunction(arrWhich(0).Index, 0).ErrorMessage = "(rejected by user)"

                        ' Make a noise
                        Beep

                        ' Move to the next function that hasn't had an error
                        Do
                            arrWhich(0).Index = arrWhich(0).Index + 1
                            If arrWhich(0).Index > arrWhich(0).Max Then arrWhich(0).Index = arrWhich(0).Min
                            If arrWhich(0).Index > arrWhich(0).TriedMax Then arrWhich(0).TriedMax = arrWhich(0).Index ' highest index tried
                            If arrWhich(0).Index < arrWhich(0).TriedMin Then arrWhich(0).TriedMin = arrWhich(0).Index ' lowest index tried
                            If Len(arrFunction(arrWhich(0).Index, 0).ErrorMessage) = 0 Then Exit Do
                        Loop
                       
                        ' Update values
                        ReInitPlasma
                       
                        ' restart cycle
                        Exit While
                    End If
                ElseIf k$ = "2" Then
                    If LastKey$ <> "2" Then
                        ' Remember last key pressed to prevent holding it down
                        LastKey$ = "2"

                        ' Mark current func #2 as "rejected"
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = "(rejected by user)"

                        ' Make a noise
                        Beep

                        ' Move to the next function that hasn't had an error
                        Do
                            arrWhich(1).Index = arrWhich(1).Index + 1
                            If arrWhich(1).Index > arrWhich(1).Max Then arrWhich(1).Index = arrWhich(1).Min
                            If Len(arrFunction(arrWhich(1).Index, 1).ErrorMessage) = 0 Then Exit Do
                        Loop
                       
                        ' restart cycle
                        Exit While
                    End If
                Else
                    ' Clear last InKey$ pressed
                    LastKey$ = ""

                    ' ANY OTHER KEY = CHANGE COLORS
                    Exit While
                End If
            Else
                ' Clear last key pressed
                iLastKeyCode% = 0
                LastKey$ = ""
            End If
        End If
        _KeyClear ' CLEAR KEYBOARD BUFFER
       
        ' Tie dye!
        LastCode$ = "Tie dye!" ' Save code location for error handler
        Cls

        ' SINGLE                  ! or none            -2.802597E-45                  +3.402823E+38                4
        ' DOUBLE                  #                    -4.490656458412465E-324        +1.797693134862310E+308      8
        ' _FLOAT                  ##                   -1.18E-4932                    +1.18E+4932                  32(10 used)
        iTo# = p2 / 64
        iStep# = p2 / (16 * 360)

        ' TRY UNTIL WE FIND A FUNCTION #2 THAT WORKS
        Do
            LastError$ = ""
           
            LastCode$ = "For a = 0 To ..." ' Save code location for error handler
            'For a = 0 To p2 / 64 Step p2 / (16 * 360)
            For a = 0 To iTo# Step iStep#
                LastCode$ = "Select Case arrWhich(1).Index: (Set iValue%)" ' Save code location for error handler
               
                Select Case arrWhich(1).Index:
                    Case 0:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 50 * Sin(s)"
                        iValue% = 50 * Sin(s) ' 2 * s or just s

                    Case 1:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 50 * Sin(s * 2)"
                        iValue% = 50 * Sin(s * 2) ' 2 * s or just s

                    Case 2:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 50 * Sin(s * 3)"
                        iValue% = 50 * Sin(s * 3)

                    Case 3:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 50 * Sin(s * 4)"
                        iValue% = 50 * Sin(s * 4)

                    Case 4:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 50 * Sin(s * 5)"
                        iValue% = 50 * Sin(s * 5)

                    Case 5:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 50 * Cos(s * 1)"
                        iValue% = 50 * Cos(s * 1)

                    Case 6:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 50 * Cos(s * 2)"
                        iValue% = 50 * Cos(s * 2)

                    Case 7:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 50 * Cos(s * 3)"
                        iValue% = 50 * Cos(s * 3)

                    Case 8:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 50 * Cos(s * 4)"
                        iValue% = 50 * Cos(s * 4)

                    Case 9:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 25 * Cos(s * 5)"
                        iValue% = 25 * Cos(s * 5)

                    Case 10:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * Tan(s * 1)"
                        iValue% = 1 * Tan(s * 1)

                    Case 11:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * Tan(s * 2)"
                        iValue% = 1 * Tan(s * 2)

                    Case 12:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Sec(s * 2)"
                        iValue% = 1 * _Sec(s * 2)


                    Case 13:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Acos(s * 1)"
                        iValue% = 1 * _Acos(s * 1)

                    Case 14:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Acos(s * 2)"
                        iValue% = 1 * _Acos(s * 2)

                    Case 15:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Acos(s * 3)"
                        iValue% = 1 * _Acos(s * 3)

                    Case 16:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Acos(s * 4)"
                        iValue% = 1 * _Acos(s * 4)

                    Case 17:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Acos(s * 5)"
                        iValue% = 1 * _Acos(s * 5)

                    Case 18:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Acosh(s * 2)"
                        iValue% = 1 * _Acosh(s * 2)

                    Case 19:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Asin(s * 2)"
                        iValue% = 1 * _Asin(s * 2)

                    Case 20:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Asinh(s * 2)"
                        iValue% = 1 * _Asinh(s * 2)

                    Case 21:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * Atn(s * 2)"
                        iValue% = 1 * Atn(s * 2)

                    Case 22:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Tanh(s * 2)"
                        iValue% = 1 * _Tanh(s * 2)

                    Case 23:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Atanh(s * 1)"
                        iValue% = 1 * _Atanh(s * 1)

                    Case 24:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Atanh(s * 4)"
                        iValue% = 1 * _Atanh(s * 4)

                    Case 25:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Arccot(s * 1)"
                        iValue% = 1 * _Arccot(s * 1)

                    Case 26:
                        ' STARTED GOING BACKWARDS! BUT CRASHED!
                        ' HOW CAN WE KEEP THESE GOING SO IT SUCKS EVERYTHING IN LIKE A BLACK HOLE?
                        ' THAT WOULD LOOK REALLY COOL! :-D
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Coth(s * .009) <- GOES BACKWARDS THEN CRASHES"
                        iValue% = 1 * _Coth(s * .009)

                    Case 27:
                        ' STARTED GOING BACKWARDS! BUT CRASHED!
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Coth(s * .008) <- GOES BACKWARDS THEN CRASHES"
                        iValue% = 1 * _Coth(s * .008)

                    Case 28:
                        ' STARTED GOING BACKWARDS! BUT CRASHED!
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Coth(s * .007) <- GOES BACKWARDS THEN CRASHES"
                        iValue% = 1 * _Coth(s * .007)

                    Case 29:
                        ' STARTED GOING BACKWARDS! BUT CRASHED!
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Coth(s * .006) <- GOES BACKWARDS THEN CRASHES"
                        iValue% = 1 * _Coth(s * .006)

                    Case 30:
                        ' STARTED GOING BACKWARDS! BUT CRASHED!
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Coth(s * .005) <- GOES BACKWARDS THEN CRASHES"
                        iValue% = 1 * _Coth(s * .005)

                    Case 31:
                        ' STARTED GOING BACKWARDS! BUT CRASHED!
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Coth(s * .002) <- GOES BACKWARDS THEN CRASHES"
                        iValue% = 1 * _Coth(s * .002)

                    Case 32:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Coth(s * .001)"
                        iValue% = 1 * _Coth(s * .001)

                    Case 33:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Sech(s * .001)"
                        iValue% = 1 * _Sech(s * .001)

                    Case 34:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Sech(s * .005)"
                        iValue% = 1 * _Sech(s * .005)

                    Case 35:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Sech(s * .05)"
                        iValue% = 1 * _Sech(s * .05)

                    Case 36:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 1 * _Sech(s * .1)"
                        iValue% = 1 * _Sech(s * .1)

                    Case 37:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = (s / 50) * 25"
                        iValue% = (s / 50) * 25

                    Case 38:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = (s / 500) * 25"
                        iValue% = (s / 500) * 25

                    Case 39:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = (s / 500) * p2 ^ .25"
                        iValue% = (s / 500) * p2 ^ .25

                    Case 40:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = (s / 500) * p2 ^ (a * .25)"
                        iValue% = (s / 500) * p2 ^ (a * .25)

                    Case 41:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = (s / 500) * p2 ^ a"
                        iValue% = (s / 500) * p2 ^ a

                    Case 42:
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = (a / 50000) * s ^ (p2 * .25)"
                        iValue% = (a / 50000) * s ^ (p2 * .25)

                    Case Else:
                        arrWhich(1).Index = 0
                        arrFunction(arrWhich(1).Index, 1).ErrorMessage = ""
                        arrFunction(arrWhich(1).Index, 1).Name = "iValue% = 50 * Sin(s)"
                        iValue% = 50 * Sin(s) ' 2 * s or just s

                End Select
               
                ' DID IT FAIL?
                If Len(LastError$) = 0 Then
                   
                    ' WE MADE IT PAST THE FUNCTION SELECTION
                    LastCode$ = "For r = 0 To diag"
                    For r = 0 To diag
                        LastCode$ = "PSet" ' Save code location for error handler
                        PSet (xc + r * Cos(a), yc + r * Sin(a)), colr(r + iValue% + ro)

                        ' DID IT FAIL?
                        If Len(LastError$) > 0 Then Exit For
                    Next r
                End If

                ' DID IT FAIL?
                If Len(LastError$) = 0 Then
                    LastCode$ = "s = s + p2 / 180" ' Save code location for error handler
                    s = s + p2 / 180
                End If

                ' DID IT FAIL?
                If Len(LastError$) > 0 Then Exit For
               
            Next a
           
            ' IT DIDN'T FAIL, WE CAN EXIT
            If Len(LastError$) = 0 Then
                Exit Do
            Else
                ' Move to the next function that hasn't had an error
                Do
                    arrWhich(1).Index = arrWhich(1).Index + 1
                    If arrWhich(1).Index > arrWhich(1).Max Then arrWhich(1).Index = arrWhich(1).Min
                    If arrWhich(1).Index > arrWhich(1).TriedMax Then arrWhich(1).TriedMax = arrWhich(1).Index ' highest index tried
                    If arrWhich(1).Index < arrWhich(1).TriedMin Then arrWhich(1).TriedMin = arrWhich(1).Index ' lowest index tried
                    If Len(arrFunction(arrWhich(1).Index, 0).ErrorMessage) = 0 Then Exit Do
                Loop
            End If
        Loop
       
        ' MAP TRIANGLES SECTION
        LastCode$ = "MAP TRIANGLES SECTION" ' Save code location for error handler
        sx1 = xc
        sy1 = yc

        sx2 = xc + diag * Cos(.002)
        sy2 = yc + diag * Sin(.002)

        sx3 = xc + diag * Cos(p2 / 64 - .002)
        sy3 = yc + diag * Sin(p2 / 64 - .002)

        For a = p2 / 64 To p2 - p2 / 64 Step p2 / 64
            dx1 = xc
            dy1 = yc
            dx2 = xc + diag * Cos(a)
            dy2 = yc + diag * Sin(a)
            dx3 = xc + diag * Cos(a + p2 / 64)
            dy3 = yc + diag * Sin(a + p2 / 64)
            _MapTriangle (sx1, sy1)-(sx2, sy2)-(sx3, sy3), source& To(dx1, dy1)-(dx2, dy2)-(dx3, dy3), 0
        Next a

        'Line (0, 0)-(xc - 1.5 * yc, _Height), &HFF000000, BF
        'Line (xc + 1.5 * yc, 0)-(_Width, _Height), &HFF000000, BF

        ' COPY IMAGE TO SCREEN
        LastCode$ = "_PutImage" ' Save code location for error handler
        _PutImage (0, 0)-(_Width, _Height), , , (xc - 1.5 * yc, 0)-(xc + 1.5 * yc, _Height)

        ' SHOW THE CURRENT GEOMETRY FUNCTIONS BEING USED + VALUES FOR DEBUGGING
        If bShowFuncName% = _TRUE Then
            LastCode$ = "If bShowFuncName% = _TRUE Then" ' Save code location for error handler
           
            Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)

            RowNum = 0: ColNum = 1
            RowNum = RowNum + 1: Locate RowNum, ColNum: Print "INSTRUCTIONS:";
            RowNum = RowNum + 1: Locate RowNum, ColNum: Print "LEFT/RIGHT...............next/previous function #1";
            RowNum = RowNum + 1: Locate RowNum, ColNum: Print "UP  /DOWN ...............next/previous function #2";
            RowNum = RowNum + 1: Locate RowNum, ColNum: Print "SPACE....................show/hide function names/values";
            RowNum = RowNum + 1: Locate RowNum, ColNum: Print "ESC OR MOVE MOUSE........quit";
            RowNum = RowNum + 1: Locate RowNum, ColNum: Print "(any other key)..........restart cycle/new colors";

            message$ = "Function #1=" + arrFunction(arrWhich(0).Index, 0).Name + _
                ", " + _
                _ToStr$(arrWhich(0).Index) + _
                " of " + _
                "(" + _
                _ToStr$(arrWhich(0).TriedMin) + _
                "-" + _
                _ToStr$(arrWhich(0).TriedMax) + _
                ")" + _
                " " + _
                "[" + _
                _ToStr$(lbound(arrFunction,1)) + _
                ".." + _
                _ToStr$(ubound(arrFunction,1)) + _
                "]" + _
                ""
            RowNum = FirstRow
            ColNum = (MaxCols% / 2) - (Len(message$) / 2)
            Locate RowNum, ColNum
            Print message$;

            message$ = "Function #2=" + arrFunction(arrWhich(1).Index, 1).Name + _
                ", " + _
                _ToStr$(arrWhich(1).Index) + _
                " of " + _
                "(" + _
                _ToStr$(arrWhich(1).TriedMin) + _
                "-" + _
                _ToStr$(arrWhich(1).TriedMax) + _
                ")" + _
                " " + _
                "[" + _
                _ToStr$(lbound(arrFunction,1)) + _
                ".." + _
                _ToStr$(ubound(arrFunction,1)) + _
                "]" + _
                ""
            RowNum = RowNum + 1
            ColNum = (MaxCols% / 2) - (Len(message$) / 2)
            Locate RowNum, ColNum
            Print message$;

            ' SHOW iValue%
            message$ = "iValue%=" + _ToStr$(iValue%)
            RowNum = RowNum + 1
            ColNum = (MaxCols% / 2) - (Len(message$) / 2)
            Locate RowNum, ColNum
            Print message$;
           
            ' SHOW ro
            message$ = "ro=" + _ToStr$(ro)
            RowNum = RowNum + 1
            ColNum = (MaxCols% / 2) - (Len(message$) / 2)
            Locate RowNum, ColNum
            Print message$;
           
            ' SHOW error count
            message$ = "ErrCount=" + _ToStr$(ErrCount)
            RowNum = RowNum + 1
            ColNum = (MaxCols% / 2) - (Len(message$) / 2)
            Locate RowNum, ColNum
            Print message$;
        End If
   
        LastCode$ = "toggle" ' Save code location for error handler
        toggle = 1 - toggle
        If toggle Then
            '_Dest 0
            'message$ = "TOP LEFT": _PrintString (0, 0), message$
            'message$ = "TOP RIGHT": _PrintString (_DesktopWidth - (Len(message$) * _FontWidth), 0), message$
            'message$ = "BOTTOM LEFT": _PrintString (0, (_DesktopHeight - _FontWidth)), message$
            'message$ = "BOTTOM RIGHT": _PrintString (_DesktopWidth - (Len(message$) * _FontWidth), (_DesktopHeight - _FontWidth)), message$
            _Display
        End If

        ' Auto-cycle through functions (SIN, COS, TAN, etc.)
        ' after iFramesPerFunction% repetitions (# cycles for the given # seconds)
        LastCode$ = "Auto-cycle through functions" ' Save code location for error handler
        iFrameCount% = iFrameCount% + 1
        If iFrameCount% > iFramesPerFunction% Then
            iFrameCount% = 0

            ' Move to the next function that hasn't had an error
            Do
                arrWhich(0).Index = arrWhich(0).Index + 1
                If arrWhich(0).Index > arrWhich(0).Max Then arrWhich(0).Index = arrWhich(0).Min
                If arrWhich(0).Index > arrWhich(0).TriedMax Then arrWhich(0).TriedMax = arrWhich(0).Index ' highest index tried
                If arrWhich(0).Index < arrWhich(0).TriedMin Then arrWhich(0).TriedMin = arrWhich(0).Index ' lowest index tried
                If Len(arrFunction(arrWhich(0).Index, 0).ErrorMessage) = 0 Then Exit Do
            Loop

            ReInitPlasma
        End If
       
        LastCode$ = "mouse, ro, limit" ' Save code location for error handler
       
        ' If user moves mouse or presses Esc then quit
        While _MouseInput: Wend: If _MouseX <> OldMouseX Or _MouseY <> OldMouseY Or _KeyDown(27) Then bFinished = _TRUE: Exit While
       
        ' Count down to color change
        ro = ro - 1
       
        _Limit fps
    Wend
    If bFinished = _TRUE Then Exit While
Wend

' SHOW RESULTS
_FullScreen _Off
Screen _NewImage(1024, 768, 32)
_AutoDisplay
_ScreenMove 0, 0
Cls

' REPORT FINDINGS:
' ReDim Shared arrFunction(0 To 21, 0 To 1) As FunctionType
' ReDim Shared arrWhich(0 To 1) As IndexType ' index of current function select case checks for

' PRINT REPORT
message$ = ""
For iLoop% = LBound(arrWhich) To UBound(arrWhich)
    iValue% = iValue% + 1
    message$ = message$ + "Function set #" + _ToStr$(iValue%) + ":" + Chr$(13)
    For iIndex% = LBound(arrFunction, 1) To UBound(arrFunction, 1)
        If Len(arrFunction(iIndex%, iLoop%).Name) > 0 Then
            ' SHOW NEXT FUNCTION NAME
            message$ = message$ + _ToStr$(iIndex%) + ". " + arrFunction(iIndex%, iLoop%).Name + Chr$(13)
           
            ' SHOW NEXT FUNCTION ERROR (IF ANY)
            If Len(arrFunction(iIndex%, iLoop%).ErrorMessage) > 0 Then
                message$ = message$ + String$(len(_ToStr$(iIndex%) + ". "), " ") + _
                    arrFunction(iIndex%, iLoop%).ErrorMessage + chr$(13)
            End If
        End If
    Next iIndex%
    message$ = message$ + Chr$(13)
Next iLoop%

ShowInstructions message$

System

' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' BEGIN GLOBAL ERROR HANDLER
' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ErrorHandler:

' COUNT THE ERROR
ErrCount = ErrCount + 1

' SHOW THE CURRENT ERROR
LastError$ = "Error #" + _ToStr$(Err) + " at line " + _ToStr$(_ErrorLine) + "."

'WHERE IN THE PROGRAM WE WERE WHEN ERROR HAPPENED: LastCode$
'WHICH SET OF FUNCTIONS VALUE LAST CHANGED IN: LastChangedIndex = 0

' WHAT CHANGED BEFORE THE ERROR?
If LastChangedIndex >= LBound(arrWhich) And LastChangedIndex <= UBound(arrWhich) Then
    ' Log the error for the current function type
    arrFunction(arrWhich(LastChangedIndex).Index, LastChangedIndex).ErrorMessage = LastError$
   
    ' Move to the next function that hasn't had an error
    Do
        arrWhich(LastChangedIndex).Index = arrWhich(LastChangedIndex).Index + 1
        If arrWhich(LastChangedIndex).Index > arrWhich(LastChangedIndex).Max Then arrWhich(LastChangedIndex).Index = 0
        If arrWhich(LastChangedIndex).Index > arrWhich(LastChangedIndex).TriedMax Then arrWhich(LastChangedIndex).TriedMax = arrWhich(LastChangedIndex).Index ' highest index tried
        If arrWhich(LastChangedIndex).Index < arrWhich(LastChangedIndex).TriedMin Then arrWhich(LastChangedIndex).TriedMin = arrWhich(LastChangedIndex).Index ' lowest index tried
        If Len(arrFunction(arrWhich(LastChangedIndex).Index, LastChangedIndex).ErrorMessage) = 0 Then Exit Do
    Loop
End If

Resume Next

' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' END GLOBAL ERROR HANDLER
' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Sub ReInitPlasma
    Dim iLoop%

    resetPlasma
    For iLoop% = -100 To diag + 1000
        Do
            LastError$ = ""
            colr(iLoop%) = Plasma~&(arrWhich(0).Index)
            If Len(LastError$) = 0 Then Exit Do
        Loop
    Next iLoop%

End Sub ' ReInitPlasma

' /////////////////////////////////////////////////////////////////////////////

Function Plasma~& (fn%)
    LastCode$ = "Plasma~&" ' Save code location for error handler
   
    cN = cN + .2
    Select Case fn%:
        Case 0:
            FuncName$ = "SIN": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * Sin(pR * cN), 127 + 127 * Sin(pG * cN), 127 + 127 * Sin(pB * cN))
        Case 1:
            FuncName$ = "COS": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * Cos(pR * cN), 127 + 127 * Cos(pG * cN), 127 + 127 * Cos(pB * cN))
        Case 2:
            FuncName$ = "TAN": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * Tan(pR * cN), 127 + 127 * Tan(pG * cN), 127 + 127 * Tan(pB * cN))
        Case 3:
            FuncName$ = "_COT": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Cot(pR * cN), 127 + 127 * _Cot(pG * cN), 127 + 127 * _Cot(pB * cN))
        Case 4:
            FuncName$ = "_CSC": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Csc(pR * cN), 127 + 127 * _Csc(pG * cN), 127 + 127 * _Csc(pB * cN))
        Case 5:
            FuncName$ = "_SEC": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Sec(pR * cN), 127 + 127 * _Sec(pG * cN), 127 + 127 * _Sec(pB * cN))

            ' ****************************************************************************************************************************************************************
            ' THESE JUST PRODUCE WHITE ON WHITE OR BLACK ON BLACK:
        Case 6:
            FuncName$ = "_ARCSEC": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Arcsec(pR * cN), 127 + 127 * _Arcsec(pG * cN), 127 + 127 * _Arcsec(pB * cN))
        Case 7:
            FuncName$ = "_COSH": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Cosh(pR * cN), 127 + 127 * _Cosh(pG * cN), 127 + 127 * _Cosh(pB * cN))
        Case 8:
            FuncName$ = "_SINH": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Sinh(pR * cN), 127 + 127 * _Sinh(pG * cN), 127 + 127 * _Sinh(pB * cN))
        Case 9:
            FuncName$ = "_ACOS": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Acos(pR * cN), 127 + 127 * _Acos(pG * cN), 127 + 127 * _Acos(pB * cN))
        Case 10:
            FuncName$ = "_ACOSH": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Acosh(pR * cN), 127 + 127 * _Acosh(pG * cN), 127 + 127 * _Acosh(pB * cN))
        Case 11:
            FuncName$ = "_ASIN": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Asin(pR * cN), 127 + 127 * _Asin(pG * cN), 127 + 127 * _Asin(pB * cN))
        Case 12:
            FuncName$ = "_ASINH": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Asinh(pR * cN), 127 + 127 * _Asinh(pG * cN), 127 + 127 * _Asinh(pB * cN))
        Case 13:
            FuncName$ = "_ATANH": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Atanh(pR * cN), 127 + 127 * _Atanh(pG * cN), 127 + 127 * _Atanh(pB * cN))
        Case 14:
            FuncName$ = "_TANH": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Tanh(pR * cN), 127 + 127 * _Tanh(pG * cN), 127 + 127 * _Tanh(pB * cN))
        Case 15:
            FuncName$ = "ATN": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * Atn(pR * cN), 127 + 127 * Atn(pG * cN), 127 + 127 * Atn(pB * cN))
        Case 16:
            FuncName$ = "_ARCCOT": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Arccot(pR * cN), 127 + 127 * _Arccot(pG * cN), 127 + 127 * _Arccot(pB * cN))
        Case 17:
            FuncName$ = "_ARCCSC": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Arccsc(pR * cN), 127 + 127 * _Arccsc(pG * cN), 127 + 127 * _Arccsc(pB * cN))

            ' ****************************************************************************************************************************************************************
            ' THESE CAUSE PROGRAM TO CRASH:
        Case 18:
            FuncName$ = "_COTH": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Coth(pR * cN), 127 + 127 * _Coth(pG * cN), 127 + 127 * _Coth(pB * cN))
        Case 19:
            FuncName$ = "_CSCH": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Csch(pR * cN), 127 + 127 * _Csch(pG * cN), 127 + 127 * _Csch(pB * cN))
        Case 20:
            FuncName$ = "_SECH": arrFunction(fn%, 0).Name = FuncName$: arrFunction(fn%, 0).ErrorMessage = ""
            Plasma~& = _RGB32(127 + 127 * _Sech(pR * cN), 127 + 127 * _Sech(pG * cN), 127 + 127 * _Sech(pB * cN))

        Case Else:
            Plasma~& = _RGB32(127 + 127 * Sin(pR * cN), 127 + 127 * Sin(pG * cN), 127 + 127 * Sin(pB * cN))
    End Select
End Function ' Plasma~&

' /////////////////////////////////////////////////////////////////////////////
' ORIGINAL:

Function Plasma1~& ()
    cN = cN + .2
    Plasma1~& = _RGB32(127 + 127 * Sin(pR * cN), 127 + 127 * Sin(pG * cN), 127 + 127 * Sin(pB * cN))
End Function

' /////////////////////////////////////////////////////////////////////////////

Sub resetPlasma ()
    pR = Rnd ^ 2: pG = Rnd ^ 2: pB = Rnd ^ 2
End Sub

' /////////////////////////////////////////////////////////////////////////////

Function RandomNumber% (Min%, Max%)
    Dim NumSpread%
    NumSpread% = (Max% - Min%) + 1
    RandomNumber% = Int(Rnd * NumSpread%) + Min% ' GET RANDOM # BETWEEN Max% AND Min%
End Function ' RandomNumber%

' /////////////////////////////////////////////////////////////////////////////
' Split and join strings
' https://www.qb64.org/forum/index.php?topic=1073.0
'
' FROM luke, QB64 Developer
' Date: February 15, 2019, 04:11:07 AM
'
' Given a string of words separated by spaces (or any other character),
' splits it into an array of the words. I've no doubt many people have
' written a version of this over the years and no doubt there's a million
' ways to do it, but I thought I'd put mine here so we have at least one
' version. There's also a join function that does the opposite
' array -> single string.
'
' Code is hopefully reasonably self explanatory with comments and a little demo.
' Note, this is akin to Python/JavaScript split/join, PHP explode/implode.

'Split in$ into pieces, chopping at every occurrence of delimiter$. Multiple consecutive occurrences
'of delimiter$ are treated as a single instance. The chopped pieces are stored in result$().
'
'delimiter$ must be one character long.
'result$() must have been REDIMmed previously.

' Modified to handle multi-character delimiters

Sub split (in$, delimiter$, result$())
    Dim start As Integer
    Dim finish As Integer
    Dim iDelimLen As Integer
    ReDim result$(-1)

    iDelimLen = Len(delimiter$)

    start = 1
    Do
        'While Mid$(in$, start, 1) = delimiter$
        While Mid$(in$, start, iDelimLen) = delimiter$
            'start = start + 1
            start = start + iDelimLen
            If start > Len(in$) Then
                Exit Sub
            End If
        Wend
        finish = InStr(start, in$, delimiter$)
        If finish = 0 Then
            finish = Len(in$) + 1
        End If

        ReDim _Preserve result$(0 To UBound(result$) + 1)

        result$(UBound(result$)) = Mid$(in$, start, finish - start)
        start = finish + 1
    Loop While start <= Len(in$)
End Sub ' split

' /////////////////////////////////////////////////////////////////////////////

Sub ShowInstructions (in$)
    'Dim in$: in$ = GetInstructions$
    Dim iLoop As Integer
    Dim iCount As Integer: iCount = 0
    Dim iRows As Integer: iRows = _Height(0) \ _FontHeight ' GET # OF AVAILABLE TEXT ROWS
    ReDim arrLines(-1) As String
    Cls
    split in$, Chr$(13), arrLines() ' SPLIT OUTPUT INTO LINES
    For iLoop = LBound(arrLines) To UBound(arrLines)
        ' WHEN MAX LINES ARE DISPLAYED, PAUSE AND WAIT FOR USER TO PRESS <ENTER>
        If arrLines(iLoop) <> Chr$(10) Then
            Print arrLines(iLoop)
            iCount = iCount + 1
            If iCount > (iRows - 5) Then
                Input "PRESS <ENTER> TO CONTINUE"; in$
                iCount = 0
            End If
        Else
            ' Chr$(10) MEANS PAUSE, WAIT FOR USER, RESET LINE COUNTER
            Input "PRESS <ENTER> TO CONTINUE"; in$
            iCount = 0
        End If
    Next iLoop
    Input "PRESS <ENTER> TO CONTINUE"; in$
End Sub ' ShowInstructions

' /////////////////////////////////////////////////////////////////////////////
' Geometry functions we tried with Plasma~&:

' PRODUCE COLORS:
' SIN (function) returns the sine of a radian angle.
' COS (function) returns the cosine of a radian angle value.
' TAN (function) returns the ratio of SINe to COSine or tangent value of an angle measured in radians.
' _COT (function) the mathematical function cotangent defined by 1/TAN.
' _CSC (function) the mathematical function cosecant defined by 1/SIN.
' _SEC (function) the mathematical function secant defined by 1/COS.

' JUST RESULTS IN WHITE ON WHITE OR BLACK ON BLACK:
' _ACOS (function) arccosine function returns the angle in radians based on an input COSine value range from -1 to 1.
' _COSH (function) Returns the hyperbolic cosine of x radians.
' _ACOSH (function) Returns the nonnegative arc hyperbolic cosine of x, expressed in radians.
' _ARCSEC (function) is the inverse function of the secant.
' _ARCCSC (function) is the inverse function of the cosecant.
' _SINH (function) Returns the hyperbolic sine of x radians.
' _ASIN (function) Returns the principal value of the arc sine of x, expressed in radians.
' _ASINH (function) Returns the arc hyperbolic sine of x, expressed in radians.
' ATN (function) or arctangent returns the angle in radians of a numerical tangent value.
' _TANH (function) Returns the hyperbolic tangent of x radians.
' _ATANH (function) Returns the arc hyperbolic tangent of x, expressed in radians.
' _ARCCOT (function) is the inverse function of the cotangent.

' CAUSE ERRORS:
' _COTH (function) Returns the hyperbolic cotangent.
' _CSCH (function) Returns the hyperbolic cosecant.
' _SECH (function) Returns the hyperbolic secant.

' OTHER GEOMETRY FUNCTIONS:
' _ATAN2 (function) Returns the principal value of the arc tangent of y/x, expressed in radians.
' _HYPOT (function) Returns the hypotenuse of a right-angled triangle whose legs are x and y.

' OTHER MATH FUNCTIONS:
' _D2R (function) converts degrees to radian angle values.
' _G2R (function) converts gradient to radian angle values.
' _R2D (function) converts radians to degree angle values.
' _R2G (function) converts radians to gradient angle values.
' _D2G (function) converts degrees to gradient angle values.
' _G2D (function) converts gradient to degree angle values.

' EXP (function) returns the value of e to the exponential power specified.
' LOG (function) returns the natural logarithm of a specified numerical value
' SGN (function) returns -1 for negative, 0 for zero, and 1 for positive numerical values.
' SQR (function) returns the square root of a non-negative number.
Reply


Messages In This Thread
Screen Savers - by bplus - 04-27-2022, 12:29 AM
RE: Screen Savers - by Dav - 04-27-2022, 02:26 PM
RE: Screen Savers - by bplus - 04-27-2022, 02:33 PM
RE: Screen Savers - by bplus - 04-30-2022, 11:55 PM
RE: Screen Savers - by madscijr - 04-17-2025, 01:22 PM
RE: Screen Savers - by Dav - 05-01-2022, 07:22 PM
RE: Screen Savers - by bplus - 05-01-2022, 08:26 PM
RE: Screen Savers - by bplus - 05-02-2022, 12:00 AM
RE: Screen Savers - by madscijr - 04-12-2025, 05:56 AM
RE: Screen Savers - by Coolman - 05-02-2022, 09:42 AM
RE: Screen Savers - by bplus - 05-03-2022, 02:13 AM
RE: Screen Savers - by bplus - 05-09-2022, 01:32 PM
RE: Screen Savers - by bplus - 05-19-2022, 07:22 PM
RE: Screen Savers - by bplus - 05-21-2022, 11:22 PM
RE: Screen Savers - by Pete - 05-21-2022, 11:27 PM
RE: Screen Savers - by bplus - 05-21-2022, 11:38 PM
RE: Screen Savers - by Pete - 05-22-2022, 04:39 AM
RE: Screen Savers - by bplus - 06-17-2022, 01:10 PM
RE: Screen Savers - by johnno56 - 06-18-2022, 12:23 AM
RE: Screen Savers - by Kernelpanic - 06-18-2022, 11:48 AM
RE: Screen Savers - by bplus - 06-18-2022, 01:47 AM
RE: Screen Savers - by bplus - 06-18-2022, 12:33 PM
RE: Screen Savers - by SierraKen - 06-20-2022, 09:50 PM
RE: Screen Savers - by bplus - 06-21-2022, 12:15 AM
RE: Screen Savers - by bplus - 06-29-2022, 04:52 PM
RE: Screen Savers - by SierraKen - 06-29-2022, 06:10 PM
RE: Screen Savers - by vince - 07-01-2022, 10:32 PM
RE: Screen Savers - by bplus - 07-01-2022, 11:05 PM
RE: Screen Savers - by bplus - 07-04-2022, 06:54 PM
RE: Screen Savers - by Kernelpanic - 07-04-2022, 09:11 PM
RE: Screen Savers - by bplus - 07-04-2022, 09:54 PM
RE: Screen Savers - by Kernelpanic - 07-05-2022, 02:14 PM
RE: Screen Savers - by bplus - 07-19-2022, 08:28 PM
RE: Screen Savers - by bplus - 08-28-2022, 12:55 AM
RE: Screen Savers - by TempodiBasic - 08-29-2022, 09:26 AM
RE: Screen Savers - by bplus - 09-06-2022, 12:35 AM
RE: Screen Savers - by SierraKen - 09-08-2022, 07:37 PM
RE: Screen Savers - by bplus - 09-09-2022, 02:22 AM
RE: Screen Savers - by SpriggsySpriggs - 09-15-2022, 04:38 PM
RE: Screen Savers - by bplus - 09-15-2022, 05:20 PM
RE: Screen Savers - by bplus - 01-31-2023, 04:21 PM
RE: Screen Savers - by vince - 02-01-2023, 07:27 AM
RE: Screen Savers - by bplus - 02-01-2023, 05:05 PM
RE: Screen Savers - by bplus - 03-13-2023, 10:51 PM
RE: Screen Savers - by vince - 03-31-2023, 11:09 PM
RE: Screen Savers - by bplus - 04-01-2023, 12:09 AM
RE: Screen Savers - by bplus - 05-14-2024, 03:00 PM
RE: Screen Savers - by PhilOfPerth - 05-15-2024, 08:24 AM
RE: Screen Savers - by bplus - 05-15-2024, 11:15 PM
RE: Screen Savers - by bplus - 08-20-2024, 12:00 AM
RE: Screen Savers - by bplus - 02-08-2025, 01:20 AM
RE: Screen Savers - by bplus - 04-12-2025, 10:49 AM
RE: Screen Savers - by madscijr - 04-12-2025, 05:01 PM
RE: Screen Savers - by SMcNeill - 04-17-2025, 01:32 PM
RE: Screen Savers - by madscijr - 04-17-2025, 04:42 PM
RE: Screen Savers - by SMcNeill - 04-17-2025, 05:03 PM
RE: Screen Savers - by NakedApe - 04-17-2025, 01:34 PM
RE: Screen Savers - by bplus - 04-17-2025, 02:59 PM
RE: Screen Savers - by madscijr - 04-17-2025, 05:54 PM
RE: Screen Savers - by SMcNeill - 04-17-2025, 05:59 PM
RE: Screen Savers - by madscijr - 04-17-2025, 06:58 PM
RE: Screen Savers - by madscijr - 04-18-2025, 03:07 AM
RE: Screen Savers - by madscijr - 04-18-2025, 07:55 PM
RE: Screen Savers - by aadityap0901 - 10-31-2025, 10:15 AM
RE: Screen Savers - by Unseen Machine - 11-01-2025, 01:41 AM
RE: Screen Savers - by aadityap0901 - 11-01-2025, 08:35 AM
RE: Screen Savers - by bplus - 01-09-2026, 03:40 PM
RE: Screen Savers - by ahenry3068 - 01-09-2026, 06:36 PM
RE: Screen Savers - by bplus - 01-09-2026, 08:33 PM
RE: Screen Savers - by bplus - 01-11-2026, 03:28 AM
RE: Screen Savers - by bplus - 01-11-2026, 11:44 AM
RE: Screen Savers - by ahenry3068 - 01-11-2026, 02:35 PM
RE: Screen Savers - by bplus - 01-11-2026, 03:15 PM
RE: Screen Savers - by ahenry3068 - 01-11-2026, 09:58 PM
RE: Screen Savers - by bplus - 01-13-2026, 12:51 AM

Forum Jump:


Users browsing this thread: