Previous Thread
Next Thread
Print Thread
xstrip #19321 10 Feb 12 03:17 AM
Joined: Jun 2001
Posts: 153
O
OmniLedger - Tom Reynolds Offline OP
Member
OP Offline
Member
O
Joined: Jun 2001
Posts: 153
Never used this xcall before.
Trying to use xstrip to remove LF's from a string.

If I use it like this:
XCALL XSTRIP, FLD'VAL, LF, 1
it doesn't work.

If I use it like this:
XCALL XSTRIP, FLD'VAL, "~"+LF, 1
it does?

LF is defined MAP1 LF,S,1,CHR(10)

Barry

Re: xstrip #19322 10 Feb 12 03:44 AM
Joined: Jun 2001
Posts: 11,945
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,945
Hmmm...
What version are you on?

The last changes to XSTRIP were in 5.1.1215, which is when it was officially introduced, although it actually existed prior to that, and there may have been problems with the prior version.

I created the simple test program below, and ran it successfully under A-Shell/Windows 6.0.1244.0 and also A-Shell/Linux 5.1.1182.5 :

Code
MAP1 FLD'VAL,S,10,"12"+chr(10)+"34"+chr(10)+"56"
MAP1 LF,S,1,chr(10)

? "FLD'VAL before [";FLD'VAL;"]"
XCALL XSTRIP,FLD'VAL,LF,1
? "After: [";FLD'VAL;"]"
END
Code
.RUN XSTRIP2A
FLD'VAL before [12
34
56]
After: [123456]
.
It may be sensitive to the particular layout of the variables or some other detail, in which case you may need to send or post your sample case before we can get to the bottom of it.

Re: xstrip #19323 10 Feb 12 03:54 AM
Joined: Jun 2001
Posts: 153
O
OmniLedger - Tom Reynolds Offline OP
Member
OP Offline
Member
O
Joined: Jun 2001
Posts: 153
Hi Jack
Ashell version is 5.1.1213.0 so maybe just too early! Will try it again after next update.

Following on from this another problem with XFOLD.
Capitalising start of words it doesn't seem to regard CR or LF as a word delimeter.

eg an address after XFOLD:
Omniledger Ltd
3 High Street
welwyn Garden City
herts

Too early for this one aswell?

Barry

Re: xstrip #19324 10 Feb 12 03:57 AM
Joined: Jun 2001
Posts: 153
O
OmniLedger - Tom Reynolds Offline OP
Member
OP Offline
Member
O
Joined: Jun 2001
Posts: 153
With reference to the original XSTRIP problem.
Just occured to me all my LF's were CR+LF - does that make a difference?

MAP1 FLD'VAL,S,10,"12"+chr(13)+chr(10)+"34"+chr(13)+chr(10)+"56"

Barry

Re: xstrip #19325 10 Feb 12 04:58 AM
Joined: Jun 2001
Posts: 11,945
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,945
Regarding the CRLF, my expectation would be that it would strip just the LF characters, leaving the CR characters intact. And according to my updated test program below (run on A-Shell/Linux 5.1.1182.5), it does:

Code
MAP1 FLD'VAL,S,20,"12"+chr(13)+chr(10)+"34"+chr(13)+chr(10)+"56"
MAP1 LF,S,1,chr(10)

? "FLD'VAL before [";FLD'VAL;"] (len="+len(FLD'VAL);")"

XCALL XSTRIP,FLD'VAL,LF,1

?
? "After: [";FLD'VAL;"] (len=";len(FLD'VAL);")"
END
Code
.run xstrip2a
FLD'VAL before [12
34
56] (len=10)

56] (len= 8 )
The "After" display looks weird, because the isolated CR characters are causing it to be overwritten, leaving only the last part of it visible. But the length confirms that 2 characters were removed. If you want to remove both the CR and LF, then just change the LF variable to:

MAP1 LF,S,2,CHR(13)+CHR(10)

Judging from the fact that the behavior doesn't seem to have changed (for me on this program) between 5.1.1182 and 6.0.1244, my guess is that it should be ok in your 1215 version. (Other variations of XSTRIP I cannot vouch for and would recommend updating to the new "stable" 6.0).

But none of that explains why putting a tilde in front of your LF string somehow worked better.

Regarding XFOLD, let me start another topic so as to not violate the "one topic per topic" rule...


Moderated by  Jack McGregor, Ty Griffin 

Powered by UBB.threads™ PHP Forum Software 7.7.3