UseSpaceForNull property: File class

Description

Use the UseSpaceForNull property to specify whether the WriteRowset method writes <qualifier> <qualifier> (<qualifier>-space-<qualifier>) for all the Null or empty character fields of a CSV-type file layout, or if the method writes <qualifier><qualifier> (<qualifier>-<qualifier>).

This property takes a Boolean value: false if WriteRowset writes <qualifier>-<qualifier>, true if WriteRowset writes <qualifier>-space-<qualifier>. The default is False.

Note:

The state of this property has no effect on the behavior of the ReadRowset method. It also has no effect when the associated file layout is of type fixed or XML.

This property is read/write.

Example

Local File &LOGFILE;
Local File &FILE1;
Local File &FILE2;
Local Record &REC1;
Local SQL &SQL1;
Local Rowset &RS1;
Local Row &ROW1;

&LOGFILE = GetFile("C:\Temp\currency.log", "W", "UTF8", %FilePath_Absolute);
If (&LOGFILE = Null) Then
   Exit;
End-If;
If Not (&LOGFILE.SetFileLayout(FileLayout.CURRENCY_FL)) Then
   &LOGFILE.WriteLine("SetFileLayout() on LOGFILE failed.");
End-If;

&FILE1 = GetFile("C:\Temp\currency_nonspaced.csv", "W", "UTF8", %FilePath_Absolute);
If (&FILE1 = Null) Then
   &LOGFILE.WriteLine("FATAL ERROR:  GetFile() on non-spaced output file failed.");
   &LOGFILE.Close();
   Exit;
End-If;
If Not (&FILE1.SetFileLayout(FileLayout.CURRENCY_FL)) Then
   &LOGFILE.WriteLine("FATAL ERROR:  SetFileLayout() on non-spaced output file⇒
 failed.");
   &LOGFILE.Close();
   &FILE1.Close();
   Exit;
End-If;

&FILE2 = GetFile("C:\Temp\currency_spaced.csv", "W", "UTF8", %FilePath_Absolute);
If (&FILE2 = Null) Then
   &LOGFILE.WriteLine("FATAL ERROR:  GetFile() on spaced output file failed.");
   &LOGFILE.Close();
   &FILE1.Close();
   Exit;
End-If;
If Not (&FILE2.SetFileLayout(FileLayout.CURRENCY_FL)) Then
   &LOGFILE.WriteLine("FATAL ERROR:  SetFileLayout() on spaced output file⇒
 failed.");
   &LOGFILE.Close();
   &FILE1.Close();
   &FILE2.Close();
   Exit;
End-If;

&REC1 = CreateRecord(Record.CURRENCY_CD_TBL);
If (&REC1 = Null) Then
   &LOGFILE.WriteLine("FATAL ERROR:  CreateRecord() on record failed.");
   &LOGFILE.Close();
   &FILE1.Close();
   &FILE2.Close();
   Exit;
End-If;

&RS1 = CreateRowset(Record.CURRENCY_CD_TBL);
If (&RS1 = Null) Then
   &LOGFILE.WriteLine("FATAL ERROR:  CreateRowset() on record failed.");
   &LOGFILE.Close();
   &FILE1.Close();
   &FILE2.Close();
   Exit;
End-If;

&SQL1 = CreateSQL("%Selectall(:1)", &REC1);
If (&SQL1 = Null) Then
   &LOGFILE.WriteLine("FATAL ERROR:  CreateSQL() failed.");
   &LOGFILE.Close();
   &FILE1.Close();
   &FILE2.Close();
   Exit;
End-If;

If (&FILE1.UseSpaceForNull) Then
   &LOGFILE.WriteLine("UseSpaceForNull is True on non-spaced output, by default.");
Else
   &LOGFILE.WriteLine("UseSpaceForNull is False on non-spaced output, by⇒
 default.");
End-If;
If (&FILE2.UseSpaceForNull) Then
   &LOGFILE.WriteLine("UseSpaceForNull is True on spaced output, by default.");
Else
   &LOGFILE.WriteLine("UseSpaceForNull is False on spaced output, by default.");
End-If;

&FILE1.UseSpaceForNull = True;
If (&FILE1.UseSpaceForNull) Then
   &LOGFILE.WriteLine("Setting UseSpaceForNull to True succeeded on non-spaced⇒
 output.");
Else
   &LOGFILE.WriteLine("Setting UseSpaceForNull to True failed on non-spaced⇒
 output.");
End-If;
&FILE2.UseSpaceForNull = True;
If (&FILE2.UseSpaceForNull) Then
   &LOGFILE.WriteLine("Setting UseSpaceForNull to True succeeded on spaced⇒
 output.");
Else
   &LOGFILE.WriteLine("Setting UseSpaceForNull to True failed on spaced output.");
End-If;

&FILE1.UseSpaceForNull = False;
If (&FILE1.UseSpaceForNull) Then
   &LOGFILE.WriteLine("Setting UseSpaceForNull to False failed on non-spaced⇒
 output.");
Else
   &LOGFILE.WriteLine("Setting UseSpaceForNull to False succeeded on non-spaced⇒
 output.");
End-If;
&FILE2.UseSpaceForNull = False;
If (&FILE2.UseSpaceForNull) Then
   &LOGFILE.WriteLine("Setting UseSpaceForNull to False failed on spaced output.");
Else
   &LOGFILE.WriteLine("Setting UseSpaceForNull to False succeeded on spaced⇒
 output.");
End-If;

&FILE1.UseSpaceForNull = False;
&FILE2.UseSpaceForNull = True;
&I = 1;
While &SQL1.Fetch(&REC1)
   &ROW1 = &RS1.GetRow(1);
   &REC1.CopyFieldsTo(&ROW1.CURRENCY_CD_TBL);
   &FILE1.WriteRowset(&RS1, True);
   &FILE2.WriteRowset(&RS1, True);
   REM   &LOGFILE.WriteLine("Got row " | String(&I));
   &I = &I + 1;
End-While;

&FILE1.Close();
&FILE2.Close();
&LOGFILE.Close();