Tab Delimited Files

Wayne Dunlop wayne.dunlop at gmail.com
Tue Jun 17 01:10:52 CDT 2008


;------------------------------------------------
;CREATION  TAB DELIMITED FILE
;------------------------------------------------

CAN CLE
SET DEF

ACCESS MY-FILE

DEF TBL-NUM        INT SIZ 2 = 9
DEF TBL            CHAR *  1 = CHAR(TBL-NUM)[2:1]

SET REP LIM 2000

;Define the tab file header, i.e. line 1.
;This header line will be positioned on top by using INITIAL HEADING.
;----------------------------------------
DEF HEADER CHAR * 50 =                &,
PACK (                                &,
     "OPERATIONCODE"       + TBL +    &,
     "OPERATIONNAME"       + TBL +    &,
     "VALUE"               + TBL +    "X" )




;Define the content of the data lines
;----------------------------------------
DEF PACKET CHAR * 50 =                &,
TRUNC(      FIELD-2      ) + TBL +    &,
TRUNC(      FIELD-2LABEL ) + TBL +    &,
TRUNC(  ASC(VALUE)       ) + TBL +    "X"

;The extra "X" is an added precaution to get rid of any trailing spaces.
;Any spaces will be located in the X field which you won't use anyaway.


:PURGE TABFILE.YYY
SET REP DEV DISC NAME TABFILE

SET NOHEAD
INITIAL HEADING HEADER

SET PAGE LEN 0
SET PAGE WID 256
SET REP SPA 0

REP PACKET

GO


---------------------------------------
example with a text field
example with a date
example with a currency (money with 2 decimals)
------------------------- --------------
DEF MY-TAB-NUM        INT SIZ 2 = 9
DEF MY-TAB            CHAR *  1 = CHAR(MY-TAB-NUM)[2:1]


def packet char * 200   =                      &,
pack (     Sometextfield           + MY-TAB +  &,
           asc(quizdate,8)[7:2]    + "/"    +  &,
           asc(quizdate,8)[5:2]    + "/"    +  &,
           asc(quizdate,8)[1:4]    + MY-TAB +  &,
           asc(moneyfield,10)[1:8] + "."    +  &,
           asc(moneyfield,10)[9:2] + MY-TAB +  &,
           "X"   )
-----
With thanks to all those Quizards who showed me how to do that in days gone
by.
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.sowder.com/pipermail/powerh-l/attachments/20080617/8a87a118/attachment.htm 


More information about the powerh-l mailing list