Entry
BBCBASIC: Windows: Character: Memory: Line: Can you give simple program to read 1 line from memory?
Nov 18th, 2006 02:05
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 18 November 2020 - 01:21 am -------------------
BBCBASIC: Windows: Character: Memory: Line: Can you give simple
program to read 1 line from memory?
===
Idea:
You start from the beginning of the line
and you keep reading characters
until you encounter the end of line marker.
===
BNF
(line) is
(zero or one begin marker)
followed by (zero or more characters)
followed by (one end marker)
===
Regular expression
(line) = (begin marker)? (character)* (end marker)
===
or written in shorthand
L = B? C* E
where
L = line
B = begin of line marker
? = zero or one
C = character
* = zero or more
E = end of line marker
===
or written as a BNF diagram
+----<----+
| |
L = ->-+-(B)-+->-+->-(C)->-+->-(E)->-
| | | |
+-->--+ +---->----+
===
because there is a begin marker here,
you can write this as
L = B C* E
===
or written as a diagram
+----<----+
| |
L = ->-(B)->-+->-(C)->-+->-(E)->-
| |
+---->----+
===
or written in pseudo code
(B)
WHILE NOT (E)
(C)
ENDWHILE
(E)
===
state diagram
'line read all characters' =
+---<-----------+
| |
->-[goto begin of line]->-+-[read char]->-+->-[found end line]->-
| |
+--->-----------+
===
Steps: Overview:
1. -E.g. create the following program
--- cut here: begin --------------------------------------------------
REM --- MAIN --- REM
PROCMemoryGetLineCharacterReadAllSimple( PAGE )
END
:
:
:
REM --- LIBRARY --- REM
:
REM library: memory: get: line: character: read: all: simple
(filenamemacro=getmeasi.bbc) [kn, ri, sa, 18-11-2020 01:32:31]
DEF PROCMemoryGetLineCharacterReadAllSimple( minI% )
REM e.g. PROCMemoryGetLineCharacterReadAllSimple( PAGE )
REM e.g. END
REM e.g. :
REM e.g. :
REM e.g. :
LOCAL I%
REM goto begin of program in memory
I% = minI%
REM
REM no check for begin marker
REM
REM while not found end marker
WHILE NOT ( ?I% = 13 )
PRINT; ?I%; " "; : REM get byte
I% = I% + 1 : REM goto next byte
ENDWHILE
PRINT; ?I% : REM get end marker
ENDPROC
--- cut here: end ----------------------------------------------------
2. -Running this program will e.g. output (print) all the characters
(bytes) starting from a given memory position until the end of
line marker (e.g. for a tokenized program, this is 13)
is found
--- cut here: begin --------------------------------------------------
22 0 0 244 32 45 45 45 32 77 65 73 78 32 45 45 45 32 82 69 77 13
--- cut here: end ----------------------------------------------------
===
Internet: see also:
---
----------------------------------------------------------------------