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 2,073 of 2,978   
   Femme Verbeek to All   
   Re: Procedure   
   09 Mar 06 03:34:25   
   
   From: fv@nospam.tcenl.com   
      
      
   You are getting the hang of it.   
     Indeed look for the ' ' chars to separate the words.   
   But I would start analysing the string from the end to the beginning and   
   copy the words directly to a single output string instead of creating an   
   array of strings.   
      
   for i:= length(s) downto 1 do ...   
       if s<>' ' then ..{increase the wordlength counter}   
                 else ..{copy wordlength bytes to the output string   
                         and set wordlength back to 0 }   
      
     You may find the copy function handy here.   
      
   The problem with the assignment is probably that the length of the text   
   will be longer than 255 characters, which is the maximum amount of chars   
   in a classic pascal string.   
      
   If you use your method of reversing words on an array of char you can   
   increase this length to a maximum of 64 kb, which is the maximum size of   
   a single blok in turbo pascal.   
      
   Look for the Blokread and blokwrite statements in the help file to see   
   how you fill your array of char with the contents of the text file.   
      
   If the file is larger than 64kb, you have to fill more buffers or one   
   buffer many times and reverse the order of dealing with them. You can   
   also use the seek procedure to go to a specific position in the file.   
      
   -- Femme   
      
   --- 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