Well, if my buddy Frank couldn't figure it out either, then I'll go the cursor route. I had this code saved as an example, so I'm going to adapt it to build a long vDataLine within the cursor, then append the cr at the end. I did a quick test and it does work.
Karen SET VAR vCRLF TEXT = (CHAR(13)+CHAR(10)) SET VAR vDataLine TEXT = NULL SET VAR vDataLength INT = 30 SET VAR vPastEnd INT = (.vDataLength+1) SET VAR vTotalLength = (.vDataLength+2) OUTPUT test.txt -- repeat this line for each piece of data to be placed Set var vDataLine = (SPUT(.vDataLine,'SOME TEXT',10)) Set var vDataLine = (SPUT(.vDataLine,.vCRLF,.vPastEnd)) --Make sure no trash data exists beyond CR/LF Set var vDataLine = (SGET(.vDataLine,.vTotalLength,1)) WRITE .vDataLine CONTINUE OUTPUT SCREEN -----Original Message----- From: Frank Taylor <[email protected]> To: RBASE-L Mailing List <[email protected]> Sent: Tue, Jan 6, 2015 9:09 am Subject: [RBASE-L] - Re: Fixed field file Itβs eerie that I was just working on something 2 weeks ago that needed to retain trailing space, and finally gave up and went a different direction in my code after reading the posts from July 2013 that also had no solution, but it was suggested (B.Chitiea) a function of RTspace (Retain Space) function should be requested. I wonder if anyone did bother to request this enhancement officially.. Frank Taylor β Director of Information Technology F.J. O'Hara & Sons, Inc - Araho Transfer Inc. Boston, MA - Rockland, ME - Miami, FL Direct Dial - 617-790-3093 Email: [email protected] From: [email protected] [mailto:[email protected]]On Behalf Of Javier Valencia Sent: Monday, January 05, 2015 8:12 PM To: RBASE-L Mailing List Subject: [RBASE-L] - Re: Fixed field file I have seen this issue raised several time and it happens because the SFIL function loses trailing blanks. I t would be nice to have a function: SET VAR vspad = (SPAD(β β, 100) That will keep the blanks at the end of the string.J Javier, Javier Valencia, PE O: 913-829-0888 H: 913-397-9605 C: 913-915-3137 From:[email protected] [mailto:[email protected]]On Behalf Of Karen Tellef Sent: Monday, January 05, 2015 5:43 PM To: RBASE-L Mailing List Subject: [RBASE-L] - Re: Fixed field file Thanks but nope, it still does not retain the 675 sfil-ed spaces at the end. Looks like maybe I will have to resort to using a cursor with a sfil/sput/write. I don't want to do that because there are thousands of rows to cursor through, and this one select is almost instantaneous. Karen -----Original Message----- From: Bill Downall <[email protected]> To: RBASE-L Mailing List <[email protected]> Sent: Mon, Jan 5, 2015 5:20 pm Subject: [RBASE-L] - Re: Fixed field file Karen, SELECT that way does its own CR/LF. How about: SET V v675spaces TEX = (SFIL(' ', 675)) ...Blah blah SELECT ( LJS(SGET(policy_no,12,1),50) + LJS(tmpUniqueText,50) + LJS(ssn,9) + LJS(firstname,50) + + ....... + .v675spaces )=1450 + FROM tmpMIB Bill (sent from Android mobile) On Jan 5, 2015 6:10 PM, "Karen Tellef" <[email protected]> wrote: Well, Albert's solution ALMOST works. It does indeed put a carriage return exactly where I want it, so it retains the 675 blank spaces at the end. However, it puts an extra carriage return (therefore a blank row) between each row of data. Is there a way to suppress that, like a "write.... continue" would? Here's the relevant code and how different "vCRLF" variables evaluated: SET WIDTH 1500 SET VAR vCRLF = (CHAR(013)) SET HEADINGS OFF SET SELMARGIN 1 OUTPUT MIB.TXT SELECT ( LJS(SGET(policy_no,12,1),50) + LJS(tmpUniqueText,50) + LJS(ssn,9) + LJS(firstname,50) + + ....... + (SFIL(' ',675)) + .vCRLF )=1450 + FROM tmpMIB OUTPUT SCREEN Value of vCRLF: char(013) + char(010) this puts a blank row between each data row char(013) same as above char(010) does not retain the blank spaces, does a carriage return right after last data Karen -----Original Message----- From: Albert Berry <[email protected]> To: RBASE-L Mailing List <[email protected]> Sent: Sun, Jan 4, 2015 6:18 pm Subject: [RBASE-L] - Re: Fixed field file Would something like this work to create the line? Assumption is no CRLF at the end of the variable .vDataLine. SELECT (DataLine + (SFIL(' ',675)) + .vCRLF) FROM ... Albert On 1/4/2015 1:14 PM, Karen Tellef wrote: I need to create a file with fixed field lengths. Rather than doing SFIL/SPUT I did a "select" statement and it works great and is easy to code, except... I need to have 675 blank spaces at the end of each line and I can't figure out how to do that using a "select" statement. Has anyone done that, or do I need to use SFIL/SPUT. According to my notes, if I use SFIL/SPUT I'll have to use a cursor and then do something like this (and thanks to whoever originally posted this code and I saved it): --Add CarriageReturn/LineFeed charaters to the line Set var vDataLine = (SPUT(.vDataLine,.vCRLF,.vPastEnd)) --Make sure no trash data exists beyond CR/LF Set var vDataLine = (SGET(.vDataLine,..vTotalLength,1)) --Write the line, telling RBASE not to add its own CRLF WRITE .vDataLine CONTINUE Karen -- A democracy ..." can only exist until the majority discovers it can vote itself largess out of the public treasury." Attributed to Alexander Fraser Tytler 1747-1813

