GNU Pascal Homepage - gpc - gpc-announce - gpc-de - gpc-doc
Diese Seite auf deutsch

Mail #14586

Back to main page of archive

Previous mail   Next mail   Unformatted/full headers
Overview  10 days   Subject   Date   Thread   Author  

From: Maurice Lombardi
Subject: Long String Generation
Date: 15 Feb 2010, 20:01:35

Kevan Hashemi a écrit :
> Dear GPC Users,
> 
> I use long strings to pass numerical data into and out of a shared 
> library I compile from Pascal. Right now, I generate a long string of 
> numbers like this.
> 
> program string_demo;
> 
> var
>   long_string:string(100000);
>   i:integer;
> 
> begin
>   long_string:='';
>   for i:=1 to 10000 do
>     writestr(long_string,long_string,i:1,' ');
> end.
> 
> Clearly, this is inefficient. It takes 200 ms on my machine. If I use an 
> array of characters instead of a string, and append each new entry to 
> the array, execution time drops to 10 ms.
> 
> I can't see a way of using GPC's writestr, concat, or trim functions to 
> accelerate my string generation. I can't alter the long_string.length 
> field directly. 

SetLength(long_string, 999999).

If I could fill up the string with spaces first, I could
> use the string as an array, then trim the spaces off the end. But 
> filling up the string with spaces requires multiple calls to writestr, 
> so I'm back where I started.
> 
> It seems to me that I'm missing an obvious solution to my problem, and I 
> thought you might point it out to me.

  Maurice

Previous mail   Next mail   Unformatted/full headers
Overview  10 days   Subject   Date   Thread   Author  


Replies

Author Subject Date
Kevan Hashemi Long String Generation 15 Feb 2010, 14:40:25
Frank Heckenbach Long String Generation 15 Feb 2010, 22:36:09
Kevan Hashemi Long String Generation 15 Feb 2010, 18:02:50

In reply to

Author Subject Date
Kevan Hashemi Long String Generation 15 Feb 2010, 12:25:50

Back to main page of archive


Note: This page contains information that does not originate from the owner of this web site, but from the authors of the mails archived. The owner of this web site is not responsible for the content of such information. Any use of that infomation requires the consent of the respective author.

Where WWW addresses (URLs) in the mails archived are marked as hyperlinks, this is only for the comfort of the reader. The content of the web pages linked to like this does not necessarily reflect the opinion of the owner of this web site or of the authors of the mails archived. The owner of this web site is not responsible for the content of such web pages. Those pages are explicitly not to be considered as part of the content of this page, but merely as references.


This page was created by Crystal 0.999 (Linux 2.4.27/i686).