TIP: Click on subject to list as thread! ANSI
echo: delphi
to: HENK KOUWEN
from: BRYAN SMITH
date: 1996-11-21 21:48:00
subject: ascii files reading

On 19 Nov 96 Henk Kouwen said to All...
 HK> An other question regarding ascci files: i must read in a string var,
 HK> but it is not surrounded by quotes, example: 960101,IBM,100
You could parse the line as follows (warning, untested code) ...
Var
  j,n : integer ;  s : string ;
  dat : array[1..20] of string[80] ;  { or some suitable size }
{ read string s from input file, then ... }
n := 0 ;
while pos(',',s)  0 do
begin
  j := pos(',',s) ;  inc(n) ;
  if j = 1 then dat[n] := '' { parameter was omitted, as in 1.3,IBM,,7.4 }
  else dat[n] := copy(s,1,j-1) ; { the stuff before the first comma }
  delete(s,1,j) ; { delete up to and including first comma }
end ;
inc(n) ; dat[n] := s ; { get what remains after final comma }
{ Now test n to see if you got the expected number of pieces ! }
--- PPoint 2.00
---------------
* Origin: Kingston, Canada (1:249/109.11)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.