TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: JAMES GOLDBLOOM
from: MICHAEL QUINLAN
date: 1996-05-30 23:55:00
subject: DAT files

James Goldbloom wrote in a message to Michael Quinlan:
 JG> Ok, this is what you will learn from this venture...  Strings are
 JG> null padded when defined in TYPE structures and the actual data
 JG> length is less than the defined length.
 JG> Hence, rtrim$(variable, any chr$(0)+" ") takes BOTH into consideration,
 JG> and also bear in mind there is more than 1 way of expressing this (see
 JG> other examples.)
Really?  If so, then when I change my example to this:
   TYPE test
      a as STRING * 10
   END TYPE
   dim b as TEST
   for i = 1 to len(b.a)
      print " ";asc(mid$(b.a,i));
   next
   b.a = "12345"
   b.a = RTRIM$(b.a,any chr$(0)+" ")
   print "["+b.a+"]"
   for i = 1 to len(b.a)
      print " ";asc(mid$(b.a,i));
   next
Do I get output like this?
  0   0   0   0   0   0   0   0   0   0
  49   50   51   52   53   32   32   32   32   32
It appears to me that the strings are initally filled with NULLs.  But once 
assigned a value, they are padded with SPACEs.
 JG> Hence, you now see why your rtrim$(variable) does not work, because
 JG> this function without additional parameters defaults to stripping a
 JG> space, ascii 32, and not a null, ascii 0.
I understand that the default for RTRIM is to trim SPACEs.  But according to 
my experience (limited) and example (above), SPACEs *ARE* what the string is 
padded with.
Can you give an example of code you have tested that works as you suggest?
Michael
--- timEd 1.10
---------------
* Origin: The University BBS; Shrewsbury Twp NJ; V34+ (1:107/411)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.