Simplifying Coding Requirements For the CSV Function
The following schematic is the syntax for a call to routine CSVRSLT. These parameters represent the Function Code, Field Type, Field length, Field scale, Field value, Buffer pointer, Buffer size, Buffer offset, User symbols, Conversion length, Return code, and Reason code respectively. This is a lot of parameters; even so, they are essential to a successful call to CSVRSLT.
CALL CSVRSLT [90K] USING fcncode, fldtype, fldlength, fldscale,fldvalue, bufptr, bufsize, bufoffset, usersymbols, cnvlength, retcode,reascode
CSVWORK and CSVCALL are copy members that you can create and use with your VISION:Results program. CSVWORK contains VISION:Results field definitions for most of the required parameters. CSVCALL contains code that accepts one parameter (the field value), then generates complete code for a call to CSVRSLT.
CSVWORK code is as follows:
WORKAREA FUNCCODE 8 CH CSVBUFSZ 4 BI CSVBUFOF 4 BI USRSYMBL 8 CH CONVLTH 4 BI CSVRETCD 4 BI CSVRSNCD 4 BI CSVBUF 100 CH
CSVCALL code is as follows:
MOVE 0 TO CONVLTH MOVE 0 TO CSVRETCD MOVE 0 TO CSVRSNCD CALL CSVRSLT USING FUNCCODE T'#N L'#N D'#N #N CSVBUF CSVBUFSZ CSVBUFOF USRSYMBL CONVLTH CSVRETCD CSVRSNCD
Following demonstrates the difference in required code for the use of CSVRSLT.
Required coding without CSVWORK: Required Coding with CSVWORK: WORKAREA COPY CSVWORK FUNCCODE 8 CH CSVBUF 50 CH (CSV BUFFER) CSVBUFSZ 4 BI CSVBUFOF 4 BI USRSYMBL 8 CH CONVLTH 4 BI CSVRETCD 4 BI CSVRSNCD 4 BI
CSVWORK contains the following:
COPIED WORKAREA COPIED FUNCCODE 8 CH COPIED CSVBUFSZ 4 BI COPIED CSVBUFOF 4 BI COPIED USRSYMBL 8 CH COPIED CONVLTH 4 BI COPIED CSVRETCD 4 BI COPIED CSVRSNCD 4 BI COPIED CSVBUF 100 CH
Required coding without CSVCALL: Required coding with CSVCALL MOVE 0 TO CONVLTH COPY CSVCALL #N=NAME MOVE 0 TO CSVRETCD MOVE 0 TO CSVRSNCD CALL CSVRSLT USING FUNCCODE T'NAME L'NAME D'NAME NAME CSVBUF CSVBUFSZ CSVBUFOF USRSYMBL CONVLTH CSVRETCD CSVRSNCD
The copy for CSVCALL would result in the following:
COPIED MOVE 0 TO CONVLTH COPIED MOVE 0 TO CSVRETCD COPIED MOVE 0 TO CSVRSNCD COPIED CALL CSVRSLT USING COPIED FUNCCODE T'NAME L'NAME D'NAME NAME COPIED CSVBUF CSVBUFSZ CSVBUFOF COPIED USRSYMBL CONVLTH CSVRETCD CSVRSNCD
As you can see by creating members CSVWORK and CSVCALL, building a CSV file with VISION:Results can be very easy.