Hello all!
It’s not a real problem for me…
But sometimes I wonder why it’s impossible to combine a “write work file” with an edit mask.
Or is there a way I don’t know about?
Regards,
Matthias
Hello all!
It’s not a real problem for me…
But sometimes I wonder why it’s impossible to combine a “write work file” with an edit mask.
Or is there a way I don’t know about?
Regards,
Matthias
Why don’t take a Printfile?
Like this Natural on Host Code?
WRITE (01) NOTITLE NOHDR USING MAP 'MYMAP'
You only have to cut off the Newpages with an external Tool
You’ll get spaces inserted between the various fields in that case, if that doesn’t matter - fine
Which other case could afford the use of a Map other than with Spaces? The Map-Editor doesn’t take fields without space between them, or?
Here’s a part of my NATURAL-code:
define data local
01 #workfile_name (A50)
01 #workfile_delimiter (A1) const <';'>
*
* ...
*
end-define
define work file 1 #workfile_name type 'ASCII'
*
* and later in the code
*
if view.logical-field
#a := 'Y'
else
#a := 'N'
end-if
*
write work file 1
view.Alpha-field
#workfile_delimiter
view.Numeric-field
#workfile_delimiter
#a
I guess it would get more complex if i would do it with a printfile…
No, that’s due to the “attribute bytes”
Looks like you want to write a csv-File. Why don’t use:
compress view.Alpha-field view.Numeric-field with delimiter ';' into #av leaving no space
On Open Systems Alpha lenght Variable is a good type for that. On Host (Nat 3.2.1) its not possible.
I agree that an edit mask specification on a field in a WRITE WORK statement would be a nice enhancement.
But for your specific requirement, change the IF to a MOVE EDITED as in
MOVE EDITED view.logical-field (EM=‘N’/‘Y’) TO #A
You can get fancy and use something like (EM=‘False’/‘True’)
MOVE EDITED view.logical-field (EM=‘N’/‘Y’) TO #A
OK, my code was just a excerpt of a bigger program. Normally I’m doing much more inside my if-statements…
But I guess you agree, that the following code would be the best solution:
write work file 1
view.date-field (EM=YYYY-MM-DD)
#workfile_delimiter
view.logical-field (EM='N'/'Y')
#workfile_delimiter
compress view.Alpha-field view.Numeric-field with delimiter ';' into #av leaving no space
By the way, to create CSV you always should use COMPRESS NUMERIC, otherwise signs and decimal points get lost.
As i said - With Nat 3.2.1 i can’t use compress because of max. Alpha 253 or A1/1:32000. But thank you for this hint. If i get in Future Nat4.2 i would know it
But on 3.2 i normaly generate a subprogramm which uses the input parameter area and write it down in csv-structure with also changing types from logical and nummeric to text.
Why don’t use:
compress view.Alpha-field view.Numeric-field with delimiter ';' into #av leaving no space
There are at least three reasons:
NAT0285 (when I run your code)
NAT0100 (if I use a logical field inside compress)
NAT0023 (if I use an Edit Mask inside compress)
Think
I’ve been a programmer for 15 years, and today I learned something new.
a new trick
MOVE EDITED view.logical-field (EM='N'/'Y') TO #A