tiny basic as a subroutine
#5
just updated the main tiny_basic sub. Realized a few minutes ago it wasn't as verssatile as the load statement, so I updated it to number the load statement does.

Code: (Select All)
'just the one subroutine, replace the earlier version with this one.
Sub tiny_basic (icmd$, pl$())
    Dim loadlines, prox
    loadlines = UBound(pl$)

    n = 0
    For prox = 1 To loadlines
        pgm(0) = pl$(prox)
        Call initlex(0)
        If toktype = "number" And num > 0 And num <= c_maxlines Then
            n = num
        Else
            n = n + 1: textp = 1
        End If
        pgm(n) = Mid$(pgm(0), textp)
    Next prox
    curline = 0
    icmd$ = LCase$(icmd$)
    Select Case icmd$
        Case "run"
            tok = "run"
            Call docmd
        Case "list"
            tok = "list"
            Call docmd
        Case "new"
            tok = "new"
            Call docmd
    End Select

    If Command$ <> "" Then
        toktype = "string": tok = c_dquote + Command$
        Call loadstmt
        tok = "run": Call docmd
    Else
        ' Call help
    End If
    Do
        errors = false
        Line Input "tinyb> ", pgm(0)
        If pgm(0) <> "" Then
            Call initlex(0)
            If toktype = "number" Then
                Call validlinenum
                If Not errors Then pgm(num) = Mid$(pgm(0), textp)
            Else
                Call docmd
            End If
        End If
    Loop Until toktype = "exit"
    ReDim pgm(0 To c_maxlines) As String
End Sub
Reply


Messages In This Thread
tiny basic as a subroutine - by James D Jarvis - 07-28-2023, 03:37 PM
RE: tiny basic as a subroutine - by bplus - 07-28-2023, 05:20 PM
RE: tiny basic as a subroutine - by bplus - 07-28-2023, 09:17 PM
RE: tiny basic as a subroutine - by James D Jarvis - 07-28-2023, 07:02 PM
RE: tiny basic as a subroutine - by mnrvovrfc - 07-28-2023, 09:11 PM
RE: tiny basic as a subroutine - by bplus - 07-31-2023, 02:08 PM
RE: tiny basic as a subroutine - by bplus - 07-31-2023, 07:35 PM
RE: tiny basic as a subroutine - by bplus - 07-31-2023, 07:46 PM
RE: tiny basic as a subroutine - by bplus - 08-01-2023, 02:36 PM
RE: tiny basic as a subroutine - by bplus - 08-15-2023, 02:45 PM



Users browsing this thread: 4 Guest(s)