2

I'm writing a file in iSeries IFS.

My variable File_Data is a 32000A, so when I use

CallP     Write(FileD           :  
               %Addr(File_Data) : 
               %Size(File_Data) )  

I find some unuseful spaces when the Variable is not filled for 32K chars. I try with a %Trim but I get an Error.

To bypass the problem I do this:

 For       Counter = 1 To %Len(%Trim(File_Data))        
 Eval      SingleChar = %SubSt(File_Data : Counter : 1) 
 CallP     Write(FileD           :                      
                %Addr(SingleChar) :                     
                %Size(SingleChar) )                     
 EndFor                                                 

Is there a better way to do this? Becasue is very slow.

Nifriz
  • 1,033
  • 1
  • 10
  • 21

1 Answers1

4

Considering your solution uses %trim (trim both sides) but writes file_data from char 1 then there must be no space at the beginning. So you can use %trimr instead, that simplifies the problem.

What you want is tell write() the length of data to write : this should do the work

CallP     Write(FileD           :  
               %Addr(File_Data) : 
               %len(%trimr(File_Data))
          )  

But if the program you write also builds the content, then maybe you can declare file_data as varchar. It will keep track of the actual length of data and in the end you can write

CallP     Write(FileD           :  
               %Addr(File_Data:*data) : 
               %len(File_Data)
          )  
nfgl
  • 2,812
  • 6
  • 16