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,633 of 2,978   
   John Smith to All   
   Re: Getting a real number from the keybo   
   27 May 05 15:48:59   
   
   From: assemblywizard@gmail.com   
      
   To help you get up to speed:   
      
      
   THIS FROM PAGES 31 & 32 OF "BORLAND PASCAL WITH OBJECTS LANGUAGE GUIDE 7.0."   
      
   . where M is less than N is called a "packed string type" (the word "packed"   
   can be omitted because it has no effect in Borland Pascal.)   
      
   A packed string type has certain properties not shared by other array types,   
   as explained below.   
      
      
      
   An array type of the form.   
      
      
      
   Array[0..X] of char   
      
      
      
   Where X is a positive nonzero integer is called a "zero-based character   
   array.  Zero-based character arrays are used to store "null-terminated   
   strings", and when the extended syntax is enabled (using a {$X+} compiler   
   directive), a zero-based character array is compatible with a PChar value.   
   For a complete discussion of this topic, read Chapter 18, "Using   
   null-terminated string," beginning on page 217.   
      
      
      
   THIS FROM PAGE 217 OF THE SAME MANUAL:   
      
   The biggest difference between using Pascal string and null-terminated   
   strings is the extensive use of pointers in the manipulation of   
   null-terminated strings.  Borland Pascal performs operations on these   
   pointers with a set o extended syntax rules.   
      
   ..and... same page.   
      
   When extended syntax is enabled, a string literal is assignment-compatible   
   with the PChar type. This means that a string literal can be assigned to a   
   variable of type PChar. For example,   
      
   VAR   
      
      P: PChar;   
      
      
      
   Begin   
      
   P := 'Hello world.';   
      
   End;   
      
      
      
   FROM PAGE 215 of the same manual:   
      
   A null-terminated string has no length byte; instead, it consists of a   
   sequence of non-null character followed by a NULL (#0).   
      
      
      
   John   
      
   "Jim Leonard"  wrote in message   
   news:1117230578.166678.202000@g14g2000cwa.googlegroups.com...   
   > John Smith wrote:   
   >> Simply change this so one of the methods work, and the real is   
   >> returned...   
   >> by reading in the character ONE CHAR at a time...   
   >   
   > I'd be glad to -- as soon as you offer an apology.   
   >   
   > You get some hints for free, though, since it's clear you still don't   
   > know what you're doing:   
   >   
   >>    b:   array[1..80] of char;  { as a Pascal String }   
   >   
   > That's not a pascal string, and won't work with val().   
   >   
   >>    s:   string[80];            { as a string }   
   >   
   > THAT is a pascal string.  A pascal string is an array of characters   
   > that ranges from 1 to 255 characters in length.  The *first* character,   
   > index [0], isn't a character, but rather the length of the string.   
   >   
   >>    ctr := 0;  { null terminated string index }   
   >   
   > Null-terminated strings END with a null, not start with one.   
   >   
      
   --- 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