Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "../include/opcode.bi"
- 'Macro for a temp string that's actually a global null string with the header
- 'modified to point ot the middle of an existing string.
- #define SetConst(_sSrc,_iStart,_iLen) *cptr(fbstr ptr, @sGlobalTemp) = type( strptr(_sSrc)+(_iStart) , _iLen , _iLen )
- Dim Shared as String sGlobalTemp
- type fbstr
- pzData as zstring ptr
- iLen as integer
- iSize as integer
- end type
- Declare Sub ParseLine (SrcLine as String)
- Dim as String Sourcefile = "test1.txt"'Command
- Dim as String SrcBuff
- If Open (SourceFile for Input as #1) Then
- Print "Error opening source file!"
- Sleep: System
- End If
- SrcBuff = Space(LOF(1))
- Get #1,, SrcBuff
- Dim as Integer LineStart = 1, LineLength = 1
- Do
- 'If there's a newline at the end of this one
- If Instr(LineStart, SrcBuff, Chr(10)) Then
- LineLength = LineStart 'start counting at begining of current line
- While (SrcBuff[LineLength] <> 10) 'Search until newline
- 'Print SrcBuff[LineLength]: SLEEP
- LineLength += 1
- Wend
- 'Otherwise this is the last line
- Else
- 'Print Instr(LineStart, SrcBuff, Chr(32))
- LineLength = Len(SrcBuff)-LineStart
- End If
- LineLength -= LineStart 'Get final length
- SetConst (SrcBuff, LineStart-1, LineLength+1)
- ParseLine sGlobalTemp
- LineStart += LineLength+1
- Sleep
- Loop Until LineStart = Len(SrcBuff)
- Sleep
- Sub ParseLine (SrcLine as String)
- Print SrcLine
- Print "---"
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement