Advertisement
Ham62

Untitled

Mar 13th, 2017
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "../include/opcode.bi"
  2. 'Macro for a temp string that's actually a global null string with the header
  3. 'modified to point ot the middle of an existing string.
  4. #define SetConst(_sSrc,_iStart,_iLen) *cptr(fbstr ptr, @sGlobalTemp) = type( strptr(_sSrc)+(_iStart) , _iLen , _iLen )
  5. Dim Shared as String sGlobalTemp
  6. type fbstr
  7.   pzData as zstring ptr
  8.   iLen as integer
  9.   iSize as integer
  10. end type
  11. Declare Sub ParseLine (SrcLine as String)
  12. Dim as String Sourcefile = "test1.txt"'Command
  13. Dim as String SrcBuff
  14.  
  15. If Open (SourceFile for Input as #1) Then
  16.     Print "Error opening source file!"
  17.     Sleep: System
  18. End If
  19.  
  20. SrcBuff = Space(LOF(1))
  21. Get #1,, SrcBuff
  22.  
  23. Dim as Integer LineStart = 1, LineLength = 1
  24. Do
  25.     'If there's a newline at the end of this one
  26.     If Instr(LineStart, SrcBuff, Chr(10)) Then
  27.         LineLength = LineStart  'start counting at begining of current line
  28.         While (SrcBuff[LineLength] <> 10)  'Search until newline
  29.             'Print SrcBuff[LineLength]: SLEEP
  30.             LineLength += 1
  31.         Wend
  32.     'Otherwise this is the last line
  33.     Else
  34.         'Print Instr(LineStart, SrcBuff, Chr(32))
  35.         LineLength = Len(SrcBuff)-LineStart
  36.     End If
  37.     LineLength -= LineStart 'Get final length
  38.  
  39.     SetConst (SrcBuff, LineStart-1, LineLength+1)
  40.    
  41.     ParseLine sGlobalTemp
  42.    
  43.     LineStart += LineLength+1
  44.     Sleep
  45. Loop Until LineStart = Len(SrcBuff)
  46. Sleep
  47.  
  48. Sub ParseLine (SrcLine as String)
  49.     Print SrcLine
  50.     Print "---"
  51. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement