XPost: comp.lang.basic.visual, comp.lang.basic.visual.misc   
   From: mynamehere@comcast.net   
      
   "Stefanie" wrote in message   
   news:157fd$41b32ced$513b4d44$1464@news1.zonnet.nl...   
   | Hi,   
   |   
   | I have a question about declaring variables for writing data to a file   
   for   
   | random access.   
   | I have two string variables declared in a module (user-defined types).   
   | The point is that for one of them i can't define (hard coded) a fixed   
   | length because the application is reading data   
   | from another file (In that file they have the same lenght).   
   | Is it possible to use the lenght i obtain from reading that other file   
   to   
   | declare my variable or are there   
   | other possibilities.   
   |   
   | Thanks in advance,   
   |   
   | Stefanie   
   |   
      
   I think what you are after is how to write a string to an output file   
   with a specified field width, without using a fixed length string, since   
   you don't know the fixed length needed until run time.   
      
   If so, then you should be able to do something like this:   
    n = FixedLengthNeeded   
    j = Len(StringToWrite)   
      
    k = n - j ' spaces needed   
      
    If k > 0 Then   
    ' print string and pad with spaces   
    Print #FileNum, StringToWrite, Space$(k)   
    Else   
    ' clip string to maximum length   
    Print #FileNum, Left$(StringToWrite, n)   
    End If   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|