Read 1 character from ascii file

ajhvdb
Member Posts: 672
GtLine = Text = Size 1
1.
If I use:
File.Read(GtLine)
and the ascii line is longer then 1 position NAV generates an error.
How to read only 1 character at a time?
2.
I can do it with an instream:
Instream.Read(GtLine, 1)
But now I can't use the .seek function... (I need this too :? )
3.
Below does work, after a seek:
File.SEEK(2);
File.CREATEINSTREAM(Instream);
Instream.Read(GtLine, 1)
But I don't know if this will create new problems if it is called 20000 times?
1.
If I use:
File.Read(GtLine)
and the ascii line is longer then 1 position NAV generates an error.
How to read only 1 character at a time?
2.
I can do it with an instream:
Instream.Read(GtLine, 1)
But now I can't use the .seek function... (I need this too :? )
3.
Below does work, after a seek:
File.SEEK(2);
File.CREATEINSTREAM(Instream);
Instream.Read(GtLine, 1)
But I don't know if this will create new problems if it is called 20000 times?
0
Answers
-
If you set the file into binary mode (textmode := false) and you create one variable of type Char, you just can read one byte with File.Read(myCharVar). That's all... no problem with reading whole file in this way (good for reading file with longer lines than 1000 chars...).0
-
I've changed the var Text1 to a var Char and no errors. Thx. Now I can read those long lines...0
-
Update:
Normally while reading textfiles I would use the function ansi2ascii
but if I do this with the type Char characters are converted???
Here is my code:vPfImport.SEEK(vPiLinePosBeg); LtInput := ''; LiPos := 0; LiX := 0; WHILE (vPfImport.POS <= vPiLinePosEnd) AND (vPfImport.POS < vPfImport.LEN) DO BEGIN vPfImport.READ(LcChar); LiFilePos := vPfImport.POS; LtChar := FORMAT(LcChar); LiPos += 1; IF (LiPos >= LiFrom) AND (LiPos <= LiTo) THEN BEGIN LiX += 1; IF (LiX <= 1024) THEN BEGIN LtInput[LiX] := LtChar[1]; END; END; END; ---->> LtInput := Ansi2Ascii(LtInput, FALSE);
Without this line everything is ok, is this correct?0 -
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions