Forgot to mention, if using the technique below, you can use CHAR(32) for 
spaces since each line ends with the end of line character(s).


Regards,

Stephen Markson
The Pharmacy Examining Board of Canada
416.979.2431 x251

-----Original Message-----
From: Stephen Markson 
Sent: February-21-18 10:58 AM
To: rbase-l@googlegroups.com
Subject: RE: [RBASE-L] - Text file that retains trailing blank space

Another approach is to put the data into a varchar variable and then write the 
variable to a file.

SET V vDataFile VARCHAR=NULL
SET V vLine TEXT=NULL
.
.
.
<loop to add records to file>
SET V vLine=<text value>
SET V vDataFile=(.vDataFile+.vLine+CHAR(13))
<end of loop>
OUTPUT <datafile>
WRITE .vDataFile
OUTPUT SCREEN

You can add "+CHAR(10)" after CHAR(13) above if you need CR+LF at the end of 
each line.


Regards,

Stephen Markson
The Pharmacy Examining Board of Canada
416.979.2431 x251

-----Original Message-----
From: rbase-l@googlegroups.com [mailto:rbase-l@googlegroups.com] On Behalf Of 
James W. Kim, CPA, MBA
Sent: February-20-18 1:25 PM
To: rbase-l@googlegroups.com
Subject: Re: [RBASE-L] - Text file that retains trailing blank space

Thank you Stephen and others for the suggestions.  Most of systems I work with 
does not allow extended ASCII characters, so CHAR(160) would not work.

I have been submitting formatted text files to various federal and state 
authorities for years.  Some systems, such as EFTPS, are tolerant and simple 
SFIL and SPUT functions work well.  However, Social Security Admin EFW2 and IRS 
FIRE systems require fixed length files (512 and 750 characters long)  that are 
sparsely populated with actual data, accompanied by great deal of blank spaces.

For blank spaces, I have been using CHAR(32) which worked fine up to R:Base X 
Build: 10.0.1.20225.  However, newer updates tend to trim the
CHAR(32) hard spaces and I had to keep one of computers at build
10.0.1.20225 for the purpose of creating these upload files.  I just tried 
CHAR(00) as suggested by Razzak and the null spaces seem to stick.  So, I am 
hopeful and will upload some test files.

Thanks again,
James


On 2/20/2018 9:04 AM, Stephen Markson wrote:
> Hi James,
>
> Can you insert CHAR(160) as the 512th character? This will keep the preceding 
> spaces and will show up as a blank. I don't know though whether the program 
> that takes the file as input will tolerate that.
>
> Regards,
>
> Stephen Markson
> The Pharmacy Examining Board of Canada
> 416.979.2431 x251
>
> -----Original Message-----
> From: rbase-l@googlegroups.com [mailto:rbase-l@googlegroups.com] On 
> Behalf Of James W. Kim, CPA, MBA
> Sent: February-19-18 4:26 PM
> To: rbase-l@googlegroups.com
> Subject: [RBASE-L] - Text file that retains trailing blank space
>
> Need some help with creating text file that retains blank spaces at the end 
> of each row.
>
> I often need to create text files with fixed row length such as 512 or
> 750 characters in a row. When there are no data value near the right end of 
> each row, the unused spaces need to be filled with blank spaces.
>
> The following is an example of how such text file would be built. The example 
> creates a row that has "FLOOR 7" at 274th space in a row that has 512 
> characters.  With some previous versions of R:Base, the trailing spaces is 
> retained after insertion of data using SPUT function and line feed (CR/LF) 
> would show up at 513th position.
>
> However, the current version would remove the trailing space when data is 
> inserted using SPUT function and the (CR/LF) moves up to 281st position.
>
> Is there anyway I can force the retention of trailing spaces so that CR/LF 
> always shows up at 513th position?
>
> Thanks in advance,
>
> James
>
>
>
> -- create text variable with blank spaces SET VAR vRow TEXT = NULL SET 
> VAR vRow = (SFIL((CHAR(32)),512))
> -- use SPUT function to fill in data
> SET VAR vRow = (SPUT(.vRow, 'start', 1)) SET VAR vRow = (SPUT(.vRow, 
> 'Floor 7', 274))
>
> -- write the variable to a text file
> OUTPUT sample.txt append
> WRITE .vRow USING
> '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
> OUTPUT SCREEN
>
>

--
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rbase-l+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
--- 
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rbase-l+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to