Post Reply 
Social Buttons
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Scanner
04-23-2017, 04:43 AM (This post was last modified: 04-23-2017 04:53 AM by Aurel.)
Post: #1
Simple Scanner
Here is one really simple scanner - line reader..
Code:
'code::simple scanner in o2 by Aurel
int nLines,linePos=1, tErr=0
string srcArray[1000],buff,crlf = chr(13)+chr(10)

Function scan()
string srcLine
again:
    srcLine = srcArray[linePos]

    If srcLine = "" OR srcLine=chr(9) OR srcLine= " "
        linePos=linePos+1 : goto again 'skip empty line
    End if

    'Tokenize(scrLine)                 'call tokenizer - not part of example!
     buff = buff + srcLine + crlf    'put string into test buffer
    If tErr = 1 Then Exit Function  ' if tokenization error then EXIT
    linePos = linePos+1             ' pos++
    If linePos <= nLines            'if linePos is LE than number of Lines
        scan()                         'recursive call scan()
    End if
End Function

'test
nLines=10
srcArray={ "New line 1","New line 2","New line 3"," ","New line 5","New line 6","New line 7","New line 8","New line 9","New line 10"}
scan() : print buff
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: