// Pre-Expression string name // the name of the person string address // the address of the person integer age // the age of the person // Content for the first row name="Bob" address="106 NorthWoods Village Dr" age=30 // Create an extra row for the // fields defined above pushrow() // The content for the extra row name="Adam" address="100 RhineStone Circle" age=32 // Create an extra row for the // fields defined above pushrow() // The content for extra row name="Mary" address="105 Liles Rd" age=28 // Create an extra row for the // fields defined above pushrow()
// Pre-Expression // This declares a string // type that will be hidden hidden string noDisplay // Expression // Assigns any value to the string type noDisplay='Hello World But Hidden'
// Pre-Expression
// We make this variable hidden so it is
// not output to the screen
hidden integer count
count=0
hidden integer subset_num
// the size of the subnet
subset_num=100
// This function estimates and sets the # of
// records that this step will report
rowestimate(subset_num)
// Expression
if(count==subset_num)
seteof()
else
count=count + 1boolean seteof(boolean)
// Pre-Expression
integer counter
counter=0
integer subset_num
subset_num=50
// Expression
if counter < subset_num
begin
counter=counter + 1
end
else
return true // Pre-Expression // Declare and initialize an integer // variable for the record count integer recordCount recordCount=0 // Expression // Increment recordCount by one recordCount=recordCount+1
// Check if the value is null
if(NOT isnull(`address`) ) then
recordCount=recordCount+1 // Preprocessing hidden integer count count=0
// Expression
if(NOT isnull(`address`) ) then
count=count+1
// Post Processing
// Create a variable that will contain
// the final value and assign it a value
integer finalCount
finalCount=count
// Add an extra row to the output
pushrow() // Preprocessing
hidden integer count
count=0
// Add a boolean field to indicate
// if the row is pushed
boolean pushed
// Expression
if(NOT isnull(`address`) ) then
count=count+1
// Name the pushed status field "pushed"
if (pushed) then
return true
else
return false
// Post Processing
integer finalCount
finalCount=count
pushrow()// Post Processing
// Integer to have the final count
integer finalCount
finalCount=count
// Add one extra row for post processing
pushrow()
// Print result to file
print('The final value for count is: '& finalCount)// Group Pre-Expression // This variable will contain the total // sales per department real total total=0 // This variable will keep track of the // number of records for each department integer count count=0 // This variable will contain the // running average total real average average=0
// Expression
// increase the total sales
total=total+ITEM_AMOUNT
// increase the number of entries
count=count+1
// error checking that the count of entries is not 0
if count !=0 then
begin
average=total/count
average=round(average,2)
endreal = ib(string, format_str)
//Expression
//File handler to open the binary file
file input_file
//The binary value to be retrieved
real value
//The number of bytes that were read
integer bytes_read
//4-byte string buffer
string(4) buffer
input_file.open("C:\binary_file", "r")
//This reads the 4 byte string buffer
bytes_read=input_file.readbytes(4, buffer)
//The width (4) specifies 4 bytes read
//The decimal (0) specifies that the data is not divided by any power of ten
value = ib(buffer,"4.0")real = s370fib(string, format_str)
real = s370fpd(string, format_str)
integer = formatib(real, format_str, string)
//Expression //The byte size of the buffer that contains the content real format_size //The real type number real number //The real number that is retrieved real fib_format number=10.125 //The buffer that contains the formatted data string(4) buffer format_size= formatib(number, "4.3", buffer //4.3 is to specify 4 bytes to read the entire //data and 3 to multiply it by 1000 //The reason to multiply it by a 1000 is to divide it later by 1000 //To restore it back to a real number fib_format= ib(buffer, "4.3") //Verify that the formatting worked //Fib_format should be 10.125
integer = formatpd(real, format_str, string)
integer = formats370fib(real, format_str, string)
integer = formats370fpd(real, format_str, string)
real piccomp(string, format_str)
//Expression
//file handler to open files
File pd
integer rc
string(4) buffer
real comp
if (pd.open("binary_input.out", "r")) begin
rc = pd.readbytes(4, buffer)
if (4 == rc) then
comp = piccomp(buffer, "S9(8)")
pd.close()
endreal piccomp3(string, format_str)
real picsigndec(string buffer, string format_str, boolean ebcdic, boolean trailing)
//Expression
//file handler to open files
file pd
integer rc
string(6) buffer
real comp
if (pd.open("binary_input.out", "r")) begin
rc = pd.readbytes(6, buffer)
if (4 == rc) then
comp = picsigndec(buffer, "S9(4)V99",1,1) pd.close()
endinteger = formatpiccomp(Real number,string format_str, string result)
//Expression real comp comp = 10.125 integer rc rc = formatpiccomp(comp, "s99V999", buffer) //The string buffer will contain the real value comp formatted to platform COBOL COMP native endian format. ??///
integer = formatpiccomp3(Real number, string format_str, string result)
integer = formatpicsigndec(real number, string format_str, string buffer, boolean ebcdic, boolean trailing)
string array variable_name integer array variable_name boolean array variable_name date array variable_name real array variable_name
// declare an array of integer types
integer array integer_list
// set the size of the array to 5 integer_list.dim(5)
// the index that will go through the array
integer index
index=0
// Set the values of the items inside the
// array to their index number
for index=1 to 5
begin
integer_list.set(index, index);
end// Expression integer array_size string array array_lister ... ... // after performing some operations on the array // array_size will then contain // the size of the array array_size=array_lister.dim()
// Pre-Expression // This is where we declare and // initialize our variables. hidden string array column_A hidden string array column_B hidden string array column hidden integer column_A_size column_A_size=1 column_A.dim(column_A_size) hidden integer column_B_size column_B_size=1 column_B.dim(column_B_size) hidden integer commun_size commun_size=1 commun.dim(commun_size)
// Expression // Name your First_Column field as you need column_A.set(column_A_size, `A_ID`) column_A_size=column_A_size+1 column_A.dim(column_A_size) // Name the Second_Column field as you need column_B.set(column_B_size, `B_ID`) column_B_size=column_B_size+1 column_B.dim(column_B_size)
// Post Expression
// This is the step where most of the
// logic will be implemented
// index to iterate through column_A
hidden integer index_column_A
// index to iterate through column_B
hidden integer index_column_B
// index to iterate through commun array
hidden integer index_commun
// index to display the commun values that were found
hidden integer commun_display_index
// string that will contain the items
// from column A when retrieving hidden string a
// string that will contain the items
// from column B when retrieving hidden string b
// String that will contain the contents of the
// commun array when retrieving
hidden string commun_content
// This boolean variable
// is to check if a commun entry has already
// been found. If so, don't display it again
hidden boolean commun_found
// This is the variable
// that will display the common entries in the end
string commun_display
// Retrieves the entries in column A
for index_column_A=1 to column_A_size Step 1
begin
a=column_A.get(index_column_A)
for index_column_B=1 to column_B_size Step 1
begin
b=column_B.get(index_column_B)
// Compare the entries from column A with
// the entries from column B
if(compare(a,b)==0)
begin
// Check if this entry was already found once
commun_found=false
for index_commun=1 to commun_size Step 1
begin
commun_content=commun.get(index_commun)
if(compare(commun_content,a)==0) then
commun_found=true
end
// It is a new entry. Add it to the
// commun array and increment its size
if(commun_found==false)
begin
commun.set(commun_size,a)
commun_size=commun_size+1
commun.dim(commun_size)
end
end
end
end
// Display the contents of the commun array
// to the screen output
for commun_display_index=1 to commun_size Step 1
begin
pushrow()
commun_display=commun.get(commun_display_index)
end// Expression
if(isnull(`commun_display`)) then
return false
else
return true// Pre-processing
// defines a bluefusion object called bf
bluefusion bf;
// initializes the bluefusion object bf
bf = bluefusion_initialize()
// loads the English USA Locale
bf.loadqkb("ENUSA");// Expression
// define mc as the return string that contains the match code
string mc
// define the return code ret as an integer
integer ret
// define a string to hold any error message that is returned,
string error_message
// generate a match code for the string Washington D.C.,
// using the City definition at a sensitivity of 85, and
// put the result in mc
ret = bf.match code("city", 85, "Washington DC", mc);
// if an error occurs, display it; otherwise return a success message
if ret == 0 then
error_message = bf.getlasterror()
else
error_message = 'Successful'// Expression
// define stdn as the return string that contains the standardization string stdn
// define the return code ret as an integer integer ret
// define a string to hold any error message that is returned string error_message
// standardize the phone number 9195550673,
// and put the result in stnd
ret = bf.standardize("phone", "9195550673", stdn);
//if an error occurs display it; otherwise return a success message, if ret == 0 then
error_message = bf.getlasterror()
else
error_message = 'Successful'// Expression
// define iden as the return string that contains the identification
string iden
// define the return code ret as an integer
integer ret
// define a string to hold any error message that is returned
string error_message
// generate an Ind/Org identification for IBM and put
// the result in iden
ret = bf.identify("Individual/Organization", "IBM", iden);
//if an error occurs display it; otherwise return a success message,
if ret == 0 then
error_message = bf.getlasterror()
else
error_message = 'Successful'// Expression
// define gend as the return string that contains the gender
string gend
// define the return code ret as an integer
integer ret
// define a string to hold any error message that is returned
string error_message
// generate a gender identification for Michael Smith,
// and put the result in gend
ret = bf.gender("name","Michael Smith",gend);
// if an error occurs display it; otherwise return a success message,
if ret == 0 then
error_message = bf.getlasterror()
else
error_message = 'Successful'// Expression
// define case as the return string that contains the case
string case
// define the return code ret as an integer integer ret
// define a string to hold any error message that is returned
string error_message
// convert the upper case NEW YORK to propercase
ret = bf.case("Proper", 3, "NEW YORK",case);
// if an error occurs display it; otherwise return a success message,
if ret == 0 then
error_message = bf.getlasterror()
else
error_message = 'Successful'//Expression
//define pattern as the return string
string pattern
//define the return code ret as an integer
integer ret
// define a string to hold any error message that is returned
string error_message
// analyze the pattern 919-447-3000 and output the result
// as pattern
ret = bf.pattern("character", "919-447-3000", pattern);
// if an error occurs display it; otherwise return a success message,
if ret == 0 then
error_message = bf.getlasterror()
else
error_message = 'Successful' // Expression date dt dt=#2007-01-10# //Jan 10 2007
// Expression date dt dt=#2007-01-10 12:27:00# //Jan 10 2007 at 12:27:00
string formatdate(date, string)
// Expression // all have the same output until formatted explicitly date dt dt=#2007-01-13# string formata string formatb string formatc formata=formatdate(dt, "MM/DD/YY") // outputs 01/13/07 formatb=formatdate(dt, "DD MMMM YYYY") // outputs 13 January 2007 formatc=formatdate(dt, "MMM DD YYYY") // outputs Jan 13 2007
// Expression date dt dt=#10 January 2003# string year string month string day // year should be 03 year=formatdate(dt, "YY") // month should be January month=formatdate(dt, "MMMM") // day should be 10 day=formatdate(dt, "DD")
date dt // the variable that will contain the date // that we want to compare against dt=#1/1/2007# // The string variable that will contain the // dt date in a string format string dt_string // The variable that will convert the // incoming date fields to string dt_string=formatdate(dt, "MM/DD/YY") string Date_string // Notice that `DATE` is the incoming field // from the data source It is written between `` so // it does not conflict with the date data type Date_string=formatdate(`DATE`, "MM/DD/YY") // boolean variable to check if the dates matched boolean date_match // Initialize the variable to false date_match=false if(compare(dt_string, Date_string)==0)then date_match=true
// Declare Database Connection Object
dbconnection db_obj
// Declare Database Statement Object
dbstatement db_stmt
// Set connection object to desired data source
// Saved DataFlux connections can also be used
db_obj=dbconnect("DSN=DataFlux Sample")
// Prepare the SQL statement and define parameters
// to be used for the database lookup
db_stmt=db_obj.prepare("Select * from Contacts where Contact = ?")
db_stmt.setparaminfo(0,"string",30)// Declare Database Cursor and define fields returned from table
dbcursor db_curs
string Database_ID
string COMPANY
string CONTACT
string ADDRESS
// Set parameter values and execute the statement
db_stmt.setparameter(0,Name)
db_curs=db_stmt.select()
// Move through the result set adding rows to output
while db_curs.next()
begin
Database_ID=db_curs.valuestring(0)
COMPANY=db_curs.valuestring(1)
CONTACT=db_curs.valuestring(2)
ADDRESS=db_curs.valuestring(3)
pushrow()
end
db_curs.release()
// Prevent the last row from occurring twice
return false//Expression
string expression_string
expression_string="Hello World"
string decode_string
string encode_string
integer decode_return
integer encode_return
decode_return = decode("IBM1047", expression_string, decode_string)
//Decode to IBM1047 EBCDIC
encode_return = encode("IBM1047",decode_string,encode_string)
//Encode string should be "Hello World" // Pre-Expression
File f
string input
f open("C:\filename.txt", "rw")
// Expression
input=f.readline() // Post Expression
f close()// Expression
File f
File g
string input
input='hello'
f open("C:\filename.txt")
g open("C:\filepet.txt")
while (NOT isnull(input))
begin
input=f.readline()
print('The value of input is ' & input)
input=g.readline()
print('The value of input is ' & input)
end
seteof()
// Post Expression
f close()// Expression seteof()
seekbegin([position])
seekcurrent([position])
seekend([position])
// Expression File f
f open("C:\Text_File\file_content.txt", "rw")
f seekend(0)
f writeline("This is the end ")
seteof()// Post Processing f close()
// Expression string names string pets names="C:\filename.txt" pets="C:\filecopy.txt" copyfile(names, pets) seteof()
string input File a
a.open("C:\filename.txt", "r")
a.readbytes(10, input)string input
input="This string is longer than it needs to be." File b
b.open("C:\filename.txt", "rw")
b.writebytes(10, input)boolean fileexists(string)
date filedate (string, boolean)
// Expression
boolean file_test
date created
date modified
file_test=fileexists("C:\filename.txt")
created=filedate("C:\filename.txt", false)
modified=filedate("C:\filename.txt", true)
seteof() // Expression
File f
integer byte_size
f.open("C:\filename.txt", "rw")
f.seekend(0)
// The integer variable byte_size will have
// the size of the file in bytes
byte_size=f.position()boolean deletefile(string)
boolean movefile(string, string)
boolean newLocation
newLocation=movefile("C:\filename.txt","C:\Names\filename.txt")
seteof()// Expression
string str
string input
input=8 // although a string, input is coerced into an integer
if(isnumber(`Input`))
str="this is a number" // input is a number
else
str="this is a string"real pow(real,real)
// Expression real exponential // exponential is 8 exponential=pow(2,3)
// Expressions integer integer_value integer_value=1274 real real_value real_value=10.126 integer ten integer hundred integer thousand // the value for ten will be 1270 ten=round(integer_value,-1) // the value for hundred will be 1300 hundred=round(integer_value,-2) // the value for thousand will be 1000 thousand=round(integer_value,-3) real real_ten real real_hundred // the value for real_ten will be 10.1 real_ten= round(real_value, 1) // the value for real_hundred will be 10.13 real_hundred=round(real_value, 2)
string typeof(any)
// Expression
string hello
hello="hello"
boolean error
error=false
// variable that will contain the type
string type
type=typeof(hello)
// type should be string
if(type<>"string") then
error=true boolean isalpha(any)
// Expression string letters letters="lmnop" string mixed mixed="1a2b3c" string alphatype alphatype=isalpha(letters) // true string mixedtype mixedtype=isalpha(mixed) // false
string left(string, integer)
string right(string, integer)
// Expression string greeting greeting="Hello Josh and John" string hello string John string inbetween hello=left(greeting,5) // "Hello" John=right(greeting,4) // "John" inbetween=left(greeting, 10) // "Hello Josh" inbetween=right(inbetween, 4) // "Josh"
string mid(string, integer p, integer n)
string substring // substring will be the string "Josh" substring=mid(greeting, 7, 4);
integer aparse(string, string, array)
// Expression string dataflux dataflux="Dataflux:dfPower:Architect" // An array type to contain the parsed words string array words // integer to count the number of words integer count // count will have a value of 3 count=aparse(dataflux, ":", words) string first_word first_word=words.get(1) // First word will be "DataFlux" string second_word second_word=words.get(2) // Second word will be "Data Management" string third_word third_word=words.get(3) // Third Word will be "Studio" string last_entry // This will have the last entry. last_entry=words.get(count)
integer parse(string, string, ...)
// Expression
integer count
string first
string second
string third
// first contains "DataFlux"
// second contains "Data Management"
// third contains "Studio"
count=parse("DataFlux:Data Management:Studio", ":", first, second,
third); // Expression
integer ascii_value
string character_content
ascii_value=asc("a"); // ascii_value is 97
character_content=chr(97) // returns the letter "a" integer len(string)
string trim(string)
// Expression string content content=" spaces " integer content_length content=trim(content) // Remove spaces // returns 6 content_length=len(content)
string lower(string)
string upper(string)
// Expression integer difference integer comparison string hello hello="hello" string hey hey="hey" // comparison is -1 because hello comes before hey comparison = compare(hello, hey, true); // difference is 3 because there are three different letters difference = edit_distance(hello, hey);
boolean instr(string, string, integer)
boolean match_string(string, string)
// Expression
string content
content="Monday is sunny, Tuesday is rainy & Wednesday is windy"
string search
search="*Wednesday is windy" // note the * wildcard
integer found_first
integer found_next
boolean match
// Check if the search string is in the content match=match_string(content, search)
if (match) then
begin
// Will find the first occurrence of day
found_first=instr(content, "day", 1)
// Will find the second occurrence of day
found_next=instr(content, "day", 2)
end string replace(string, string, string, integer)
// Expression string starter string replace string replaceWith string final starter="It's a first! This is the first time I came in first place!" replace="first" replaceWith="second" final =replace(starter, replace, replaceWith, 2) seteof()
string pattern(string)
// Expression string result; string pattern_string; pattern_string="abcdeABCDE98765"; // The result will be aaaaaAAAAA99999 result=pattern(pattern_string);
string vareval(string)
|
field_1
|
field_2
|
field_3
|
field_4
|
field_5
|
|---|---|---|---|---|
|
1
|
Bob Brauer
|
123 Main St.
|
Cary
|
NC
|
|
2
|
Don Williams
|
4 Clover Ave.
|
Raleigh
|
NC
|
|
3
|
Mr. Jim Smith
|
44 E. Market Street
|
Wilmington
|
NC
|
|
4
|
Ms. Amber Jones
|
300 Chatham Dr.
|
Durham
|
NC
|
|
5
|
I Alden
|
99 A Dogwood Ave.
|
Apex
|
NC
|
// Pre-expression
string field_number
string field_value
// Expression
hidden integer n
for n=1 to 5
begin
field_number='field_' & n
field_value=vareval(field_number)
n=n+1
pushrow()
end
// this next statement prevents the last row from showing up twice
return false