![]() | ![]() | ![]() | ![]() | ![]() |
#import - WRAP |
This is a specialised #import facility.
WRAP DEFINITIONS/OPTIONS |
These definitions are specific to the "WRAP" import mode. If you can't understand how they work then I suggest you try using /debug or #debug to watch what variables the import uses etc.
This definition lists zero, one or more names as used on previous "#AsIs SETUP" commands (seperated by whitespace). Clear this definition to prevent all ASIS conversions.
Note that you will probably need to override this value (maybe others as well) if you wished to expand any macros that the imported data might contain (by default this is not done).
The line is passed as a rexx statement which when executed will restore the line.
Your macro can do anything it likes as it determines what if anything get generated.
The following rexx variables are relevant:
If the contents starts with 'EOF:' then the current record and ALL following are dropped.
Example of WRAP Import |
Assume "PEOPLE.TXT" contains people data of the following form (each record spans 3 lines with blank lines being ignored and little validation of data):
Harry 18 male Lisa 20 female
Then we could create a simple HTML table as follows:
;--- Define some macros to handle the imported data ---------------------- #define InitMultiLineFieldImport \ #RexxVar RxFieldCount = 0 #define TermMultiLineFieldImport \ #if [RxFieldCount <> 0] \ #error "Incorrectly specified record, have <??RxFieldCount> of 3 fields" \ #endif #define EachLine \ ;--- "read" the line (no blank lines) ------- \ #evaluate+ '' ^ThisLine = strip({$Line})^ \ \ ;--- Save information ----------------------- \ #RexxVar RxFieldCount + 1 \ #RexxVar RxField_<??RxFieldCount> = ThisLine \ \ ;--- If end of record then output it -------- \ #if [RxFieldCount = 3] \ <TR><TD><??RxField_1> is <??RxField_3> and <??RxField_2> years old \ #RexxVar RxFieldCount = 0 \ #endif ;--- Start the table ----------------------------------------------------- <$InitMultiLineFieldImport> <BR> <CENTER> <TABLE COLS=3 BORDER=1> ;--- Import the data (leaving default at dropping blank lines) ----------- #import "PEOPLE.TXT" WRAP EachLine ;--- End The table ------------------------------------------------------- </TABLE> </CENTER> <$TermMultiLineFieldImport>
![]() | ![]() | ![]() | ![]() | ![]() |