KEMBAR78
Metaprogramming | PDF | Computer Data | Computer Architecture
0% found this document useful (0 votes)
18 views5 pages

Metaprogramming

The document outlines various functions for file and record manipulation, including reading files, retrieving file information, and creating record formats. It describes how to list directory contents, read record formats, and manage transformation rules and fields. Additionally, it provides examples of how to use these functions to manipulate data structures effectively.

Uploaded by

santukrmandal4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views5 pages

Metaprogramming

The document outlines various functions for file and record manipulation, including reading files, retrieving file information, and creating record formats. It describes how to list directory contents, read record formats, and manage transformation rules and fields. Additionally, it provides examples of how to use these functions to manipulate data structures effectively.

Uploaded by

santukrmandal4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

read_file - reads a file and return the file’s content as a string.

e.g., read_file(“/tmp/tmp.txt”, position=3,num_bytes=4)

file_information - return detail information about a local filesystem object as a record of type
file_information_type (describe the properties of a windows or unix filesystem object).

m_eval file_information(“my_file”) ⇒

[record
found 1
readable 1
writeable 1
executable 1
file_type "FILE"
size 6916
blocks 8
uid 114
gid 101
inode 622711
device 769
created 1103052403
modified 1103052403
username "mkatz"
groupname "staff"]

.
m_eval 'file_information("my_file").file_type'
⇒ "FILE"

m_eval 'file_information("mfile:my_file").file_type'
⇒ "MFIL"

directory_listing - Return the list of objects from a local directory as an object of type
directory_listing_type.

directory_listing(path=”.”,pattern=”[!.]*”) ⇒ will return list of files in a vector format

[vector
"gen_rec.cat",
"Cecil-com04.ksh",
"Boogs-login.ksh",
"Hobi-tab.cat"]
read_type - read a record format file and return it as a string.

read_type(AI_DML+’/test.dml’) ⇒

"record\n string(";") first_name, string(";") last_name; string(10) userID;\nend\n"

read_transform - read a xfr and return as a string.

read_transform(AI_XFR+’/sample.xfr’)

make_field - Create a record format field.

make_field(‘newline’,’string(1)’,’\n’) ⇒ string(1) newline=’\n’;

Make_arg - make input argument for xfr


Make_transform - make xfr template

make_transform(‘reformat’,make_arg(in)) ⇒

out::reformat(in)=
Begin

End

Make_rule - make a transformation rule

make_rule(‘out.column1’,’in.column1’)

add_field - add a new field to a record format.

add_field(read_type(AI_DML+’/test.dml’), ‘newline’, ‘string(1)’,’\n’) ⇒

record
string(";") first_name;
string(";") last_name;
string(10) userID;
string(1) newline=’\n’;
End

Add_rule - add one rule to a transformation

add_rule(make_transform(‘reformat’,make_arg(in)),make_rule(‘out.column1’,’in.colu
mn1’)) ⇒
out::reformat(in)=
Begin
out.column1::in.column1;
End

Add_fields - add more than one field to a record format.

add_fields(read_type(AI_DML+’/test.dml’), vector[
make_field(‘ph_no,’string(10)’)
make_filed(‘newline’,’string(1)’,’\n’)
]⇒

record
string(";") first_name;
string(";") last_name;
string(10) userID;
string(10) ph_no;
string(1) newline=’\n’;
End

add_rules - add more than one rules to a transformation

add_rules(make_transform(‘reformat’,make_arg(in)), vector[
make_arg(‘out.column1’,’in.column1’)
make_arg(‘out.*’,’in.*’)
])

Remove_fields - remove one or more fields.

remove_filelds(read_type(AI_DML+’/test.dml’),[vector
make_field(‘last_name’,’string(;)’)
make_field(‘last_name’,’string(;)’) ] ⇒

record
string(10) userID;
string(10) ph_no;
string(1) newline=’\n’;
End

Record_info - return a vector of record field attributes.


E.g.,

record_info("record integer(8) foo; string(3) bar() = \"bar\"; end")

[vector
[record
name "foo"
dml_type "integer(8)"
default ""
condition ""
nullable "0"
nullflag "0"
form "integer"
comment NULL
scomment NULL
typename NULL
offset "0"
includes NULL],
[record
name "bar()"
dml_type "string(3)"
default "\"bar\""
condition ""
nullable "0"
nullflag "0"
form "function"
comment NULL
scomment NULL
typename NULL
offset ""
includes NULL]]

Record_info_item - creates a vector of any one attribute.

record_info_item(record_info("record integer(8) foo; string(3) bar() = \"bar\";


end"),’name’) ⇒

[vector foo, bar]

flatten_type - flatten a nested record


AB_DML_DEFS

You might also like