0001: OPEN "VOC" TO F.VOC ELSE STOP
0002: A = "DOG":@AM:@AM:@AM:@AM
0003: PRINT CONVERT(@AM,"!",A)
0004: WRITE A ON F.VOC,"DOG"
0005: READ B FROM F.VOC,"DOG" ELSE B = ''
0006: PRINT CONVERT(@AM,"!",B)
0007: *
0008: DIM R.DOG(1)
0009: MATREAD R.DOG FROM F.VOC,"DOG" THEN
0010: MATWRITE R.DOG ON F.VOC,"DOG"
0011: END
0012: READ C FROM F.VOC,"DOG" THEN
0013: PRINT CONVERT(@AM,"!",C)
0014: END
Result:
DOG!!!!
DOG!!!!
DOG!!!!
-----Original Message-----
From: andy baum<andyb...@yahoo.co.uk>
To: U2 Users List<u2-users@listserver.u2ug.org>
Sent: Wed, May 16, 2012 12:34 am
Subject: Re: [U2] Trim trailing attributes off records
The manual states :-
escription
se the MATWRITE statement to write data from the elements of a dimensioned
rray to a record in a UniVerse file. The elements of array replace any data
tored in the record. MATWRITE strips any trailing empty fields from the record.
've run the following code in every flavor account on UV 10.3
CT BP TEST.MATWRITE
TEST.MATWRITE
001 DIM REC(30000)
002 OPEN '','VOC' TO VOC THEN
003 MATREAD REC FROM VOC,'MW' THEN
004 MATWRITE REC TO VOC,'MW'
005 END
006 END
007 END
And get the following results
Before
CT VOC MW
MW
001 FIELD 1
002
003 FIELD 3
004
005
006
007
008
009
010
RUN BP TEST.MATWRITE
fter
CT VOC MW
MW
001 FIELD 1
002
003 FIELD 3
________________________________
From: Wjhonson<wjhon...@aol.com>
o: u2-users@listserver.u2ug.org
ent: Wednesday, 16 May 2012, 2:51
ubject: Re: [U2] Trim trailing attributes off records
Sure but then *that* will not trim the trailing attributes.....
f you dim it to hold every element, and then write it back you just get the
xact same problem with which you started.
xtra empty attributes.
The solution you already had, to matread it, blank rec(0), then matwrite it
hat works.
----Original Message-----
rom: Wols Lists<antli...@youngman.org.uk>
o: u2-users<u2-users@listserver.u2ug.org>
ent: Tue, May 15, 2012 5:59 pm
ubject: Re: [U2] Trim trailing attributes off records
n 15/05/12 20:50, Wjhonson wrote:
Information Flavor
o spaces in the fields, nothing in them at all, just a line of attribute
rks with nothing in between.
our trick below *does* work by the way, and it's essentially what I did.
just set Rec(0) to nothing before the MATWRITE and that did it.
But I was also surprised that Andy's trick of just matreading and then
twriting didn't work.
ou have to set Rec(0) to nothing in between
've just realised WHY that probably is ... Rec(0) is full of FMs ...
f you dimension your array to hold every element of the record
ithout* overflow, it'll work fine. I bet the MATWRITE tests if (0) is
pty, and if it's got overflow in it ...
heers,
l
----Original Message-----
rom: Wols Lists<antli...@youngman.org.uk>
o: u2-users<u2-users@listserver.u2ug.org>
ent: Tue, May 15, 2012 12:40 pm
ubject: Re: [U2] Trim trailing attributes off records
n 11/05/12 17:36, Wjhonson wrote:
I thought that too.
Tried that one.
What it actually does is store all the trailing attributes in the "header"
d
en append them back to the record when it writes it out.
Universe 10.3
at flavour? That ALWAYS worked for me on PI.
et's say your dict declares up to, say, field 20 and you know there
houldn't* be anything beyond it.
ounds actually, like you are in PI mode so ...
clare your MAT as 20 long :-)
d a line before the write which says
F CONVERT( REC(0), @FM:" ", "") EQ "" THEN REC(0) = "" ELSE PRINT
ecord ":ID:" contains extra data!"
o basically, you're dumping what you don't want into element 0. The
nvert checks that it really is nothing before zeroing it.
'm guessing it's not working for you because somehow there are actually
aces in those fields you think are blank (ED gets rid of trailing
aces ...)
ou can pull the same stunt for PICK mode, just remember the extra
tries will end up in the last element of the array.
heers,
l
-----Original Message-----
From: andy baum<andyb...@yahoo.co.uk>
To: U2 Users List<u2-users@listserver.u2ug.org>
Sent: Fri, May 11, 2012 6:30 am
Subject: Re: [U2] Trim trailing attributes off records
How about :-
OPEN 'FILENAME' TO FILEVAR ELSE
STOPM 'Cannot open FILENAME'
END
IM REC(500)
ELECT FILEVAR
LOOP
WHILE READNEXT ID
MATREADU REC FROM FILEVAR,ID THEN
MATWRITE REC TO FILEVAR,ID
END
REPEAT
ND
ATWRITE trims trailing blank attributes as it writes the data away
heers,
Andy
From: Wjhonson<wjhon...@aol.com>
o: u2-users@listserver.u2ug.org
ent: Thursday, 10 May 2012, 23:13
ubject: [U2] Trim trailing attributes off records
iven that you have a file with thousands of records, each with dozens of
railing attributes which are empty.
How can you pick up the file and drop it back down with all those empties
rimmed off?
__
_____________________________________________
-Users mailing list
-us...@listserver.u2ug.org
tp://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
2-Users mailing list
2-us...@listserver.u2ug.org
ttp://listserver.u2ug.org/mailman/listinfo/u2-users
______________________________________________
2-Users mailing list
2-us...@listserver.u2ug.org
ttp://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________