home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,447 of 2,978   
   Dr Engelbert Buxbaum to RadSurfer   
   Re: A naive question   
   04 Mar 05 08:54:18   
   
   From: engelbert_buxbaum@hotmail.com   
      
   RadSurfer wrote:   
      
   > TP / BP / Free Pascal / havent tried GPC yet...   
   > seem to be able to parse numerical data from text files, but not string   
   > data...   
   > which to really cripples "the language" severely.   
      
   What is limiting here is not the language, but your knowledge of it. In   
   a mixed sting/number data file you need to determine the boundaries of   
   both. So you read on char at a time and use a state maschine to   
   determine whether it belongs to a number or a text. Once you reached the   
   end of a number-string, you convert it using the "val" statement.   
      
      
   > read(f, Int, Str, Sing);  //Integer, String, Single,  NOPE!! Can't be   
   > done!   
      
   Can be done, but only if you know the lenght of the strings beforehand.   
      
   > read(f, Str1, Str2, Str3);//Only first entire line will be read !!!   
   >                            //str2, str3 will be 'Nil'   
      
   same as above. How should a run time library determine which part of the   
   text you want to be put into which variable? Is   
   'ABCDEFGHIJKLMNOPQRSTUVWXYZ' to be read as 'A', 'B',   
   'CDEFGHIJKLMNOPQRSTUVWXYZ' or as 'AB', 'CD', 'EFGHIJKLMNOPQRSTUVWXYZ' or   
   as ...   
      
   > likewise,   
   > ReadLn(f, Str1, Str2, Str3); //First line is read, others will be 'Nil'   
      
   RTFM. ReadLn reads on line of a text file and puts it into a string. If   
   the text has several lines, you use something like   
      
   WHILE NOT(eof(f)) DO         { anything left to be read? }   
      BEGIN   
        ReadLn(f, StrVar);   
        ....                    { handle the string }   
      END;   
      
   >   
   > Strangely enough, using Free Pascal, C1 : Array[1..10] of Chars   
   > likewise for C2, C3, worked in   
   > Read(F, C1, C2, C3);   but FAILS when merely declared as Strings, I   
   > have no idea why.   
      
   See above. If you use   
      
   VAR C1, C2, C3 : string[10]   
      
   it will also work with strings.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca