Long String 
Author Message
 Long String

        Is there something like longstring? How can I break the limit of
255 characters?

[]'s

--
Andre Paim Lemos



Wed, 18 Jun 1902 08:00:00 GMT  
 Long String

:       Is there something like longstring? How can I break the limit of
: 255 characters?

you can declare an array of char and do string operations manually.  or
there's null-terminated strings, which have a limit of 65535 characters.
i've never used those in Pascal..  and there's still the readln
limitation.

---
-Assassin, misc.test moderation panel



Wed, 18 Jun 1902 08:00:00 GMT  
 Long String

Quote:

>         Is there something like longstring? How can I break the limit of
> 255 characters?

> []'s

> --
> Andre Paim Lemos


Hi there ...

Think about Null-Terminated Strings ...
In Borland Pascal 7.x you can use the Type PCHAR . The UNIT Strings has
some usefull routines dealing with NULL-Terminated Strings.
If your Compiler doesn't support Null-Terminated String's, you have to
do your Null-Terminated String yourself.
PChar = ^Char ... Use the "normal" pointerfunctions (getMem,freeMem,
etc.).
Keep in Mind, that the String has to be Null-Terminated (last element of
the String has to be nul).
Now the stringlength is only limited by the System or Os.

Bye
   Patrick

"Und die Erde war wst und leer und es ward finster ber der Tyiefe"



Wed, 18 Jun 1902 08:00:00 GMT  
 Long String


Quote:

> :  Is there something like longstring? How can I break the limit of
> : 255 characters?

> you can declare an array of char and do string operations manually.  or
> there's null-terminated strings, which have a limit of 65535 characters.
> i've never used those in pascal..  and there's still the readln
> limitation.

No. For PChars alias 'array of char' there is no other read/write
limitation than the 65528 limit in TP 7.0 {$X+}

var
  a:array[0..40000] of char;
  t:text;
  w:word;
begin
  for w:=0 to 39999 do a[w]:=chr(ord('0')+random(10));
  a[40000]:=#0;
  writeln(a)
end.



Wed, 18 Jun 1902 08:00:00 GMT  
 Long String

:>
:> you can declare an array of char and do string operations manually.  or
:> there's null-terminated strings, which have a limit of 65535 characters.
:> i've never used those in pascal..  and there's still the readln
:> limitation.

: No. For PChars alias 'array of char' there is no other read/write
: limitation than the 65528 limit in TP 7.0 {$X+}

: var
:   a:array[0..40000] of char;
:   t:text;
:   w:word;
: begin
:   for w:=0 to 39999 do a[w]:=chr(ord('0')+random(10));
:   a[40000]:=#0;
:   writeln(a)
: end.

nifty code.. but how does it address the comment on the readln
limitation?  i'm guessing you'd just make your own readln..
which is what i was hinting at by saying "do string operations
manually."  the readln limitation wouldn't apply in this situation,
but it still exists.

(there was just a thread on readln's limits.  if there was a way
around it, and mah thick skull just didn't register, then i
apologize..)

--
=-= Join us in the fight against {*filter*}! =-=



Wed, 18 Jun 1902 08:00:00 GMT  
 Long String

Quote:

>nifty code.. but how does it address the comment on the readln
>limitation?  i'm guessing you'd just make your own readln..
>which is what i was hinting at by saying "do string operations
>manually."  the readln limitation wouldn't apply in this
situation,
>but it still exists.

>(there was just a thread on readln's limits.  if there was a way
>around it, and mah thick skull just didn't register, then i
>apologize..)

The limit isn't in Readln, it's in DOS.

I tried the following program:

var
  a : Array[0..1000] of char;
  f : Text;
Begin
  assign(f, 'X.TXT');
  reset(f);
  Readln(f, a);
  Close(f);
  writeln(a);
End.

where X.TXT contains one line of 1022 and it read the first 1000
of them into a. Had a look at the code which was generated, and
the size of the array (1000) is passed to the Readln calls.

But when I changed the file name from 'X.TXT' to '' (the DOS
stdin) I could not enter more than 127 chars. Readln could handle
them, but DOS would not let them get that far.

FP



Wed, 18 Jun 1902 08:00:00 GMT  
 Long String

Quote:
>>which is what i was hinting at by saying "do string operations
>>manually."  the readln limitation wouldn't apply in this
>But when I changed the file name from 'X.TXT' to '' (the DOS
>stdin) I could not enter more than 127 chars. Readln could handle
>them, but DOS would not let them get that far.

Use CRT unit that gives some more flexibility to text I/O. Combine
example below with previous posts to get past 127 chars limit.

Robert

uses CRT;
var st     : string;
      iBuf  : array[0..256] of char;
{ Note: at least 257 bytes for }
{ string length 255 (+CRLF)  }

begin
  ReadLn(st);    { 127 chars }
  WriteLn(st);

  Close(Input); Reset(Input);
  SetTextBuf ( Input, iBuf, SizeOf(iBuf) );

  ReadLn(st);    { 255 chars }
  WriteLn(st);
end.

Check online help for SetTextBuf, AssignCRT, tTextRec or TextRec
Check manuals for indepth explanation on file I/O handling.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Help with long strings as query parameters

2. writing LONG STRINGS to SQL-Server6.5!!!!!!!

3. Longer strings

4. memory management for long strings

5. Long Strings

6. Long strings in Delphi-32

7. Long strings in Delphi-32

8. Passing long strings using EXEC

9. Oracle strings longer than 255 ??????

10. strings longer then 255 characters

11. strings longer then 255 characters

12. Delphi Newbie long command strings

 

 
Powered by phpBB® Forum Software