Escolar Documentos
Profissional Documentos
Cultura Documentos
The grammar of Script in Report Designer is similar to C Language. This is the program
language, which provides programming function to the Fixed Form Report created on
Report Designer.
This function is enough to change the existing concept on the document and provide high
possibility of transplantation to Korean style document creation as well. Of course, similar
attempts have been tried, and some part of this function was once adapted by another
development tool. However, its application area was very limited and otherwise it was very
inconvenient to use.
1Th, Program input/output skill is the same as document editing skill on Editor.
Considering that 60~70% of typical programming code is used to handle data input and
output when application programs are made by a third generation programming language,
this greatly increase the productivity of script programming.
2Th, Data flow expression is very natural. Changes for data in a application program can
be expressed as they are applied simply to several relevant applications.
3Th, Report Designer Script conveniently supports the development of application
programming in a Client/Server environment. Report Designer Script provides a
programmer with the environment to use the programs and data equally regardless whether
they exist in a server or in a client. It also provides the efficient client/server environment
through ODBC connection, or through a specified DLL as well.
4Th, Report Designer Script treats the document and the script equally in the Graphic
user connection environment. So, a document is a script program and a program has the
document functions. While creating a document, you can make a program at the same time.
And you can add functions of script program to an existing document, and can easily change
the program already made into the same format as the document.
5Th, Report Designer Script makes it possible to create high quality database
application program and provides the functions to make lots of application programs
in a short period of time. It makes it possible to make a simple 4GL or SQL Query
sentences.
81
As a result of combining the functions of document and program, the graphics to be printed
can have as high quality as ones to be shown on the screen. Also, it can be applied to
various areas from the artificial intelligent document in which functions for a user can be
programmed to the general data processing programs with the interface. After all, this will
increase the productivity of work and development.
1. Make Script
Scripts can be used in the Fixed Form Report among the 4 document types of Report
Designer (General Document, Table, Label, Fixed Form Report). (It is possible that it
can be used in certain sections of the General Document, Table, and Label.)
82
Report Designer function can be largely categorized into Edit function and Program function.
Two functions are closely related to the Object.
Edit function in Report Designer is to make or modify Objects, and Programming function is
to describe scripts to the existing Objects.
Object Variable
Variables used in Report Designer are categorized into Object Variable, Local Variable and
Temporary Variable. For more details on Variables, please refer to paragraph 2.2. This
section will simply cover the object variable related with the object.
Object Variable is the name that a user assigns to an object created in Report Designer.
Variables can be assigned to all objects of documents in Report Designer.
Object Variable name accepts both a lowercase and an uppercase, and can be applied to
script statement and Internal Function. As the object variable name is a global variable, the
name should be unique in a document.
In order to declare the object variable, select the object in the Edit Script dialog box and
then input variable name. And define the variable type.
Variable type of the object variable is the data type of defined variables. Variable type
consists of Char, Date, Number, or Time. However, not all variables may have a variable
type. For example, graphics objects and bitmap objects do not have a variable type.
83
In the column of product name, the object name is given by order of Product Name1,
Product Name2, Product Name3, Product Name4, and Product Name5. These are data with
same characteristics. When you assign the name through the script dialog box, if you
select the column in which the name will be given and input the product name in the
Variable input field, then the variable names will be given to cells from the first cell you
selected by same order as the above table.
It is possible to fix object variables by a vertical, diagonal or random selection as follows.
84
85
86
87
When scripts are executed whenever page content created from main query result record in
database connection or base field define result on file connection document.
In case General document, Table and Label type report include a script, the time when
a script is executed
Only in the time of opening a file first, a script will be executed.
Only after you input the variable name into the object, you can use it in the script.
3. After describing the corresponding script in the script edit window, verify it or click Close
button.
4.
1.2.1. Variable
In Report Designer, there are three ways to define the variable and use them.
1Th, Object Variable assigns a variable name to an object,
2Th, Global Variable, which is not an object variable name, can be used in the entire
program,
3Th, Local Variable can be used only within one script.
88
If you press <Ctrl+F>, while editing a script, Find/Replace dialog box will appear.
.
If you click Word Only check box, you can find the word consisting of input character string.
And, if you check Case Sensitive check box, you can find a character string in which all of
upper cases and lower cases coincide.
Making a search will start from a location where a cursor blinks in the current Edit
window. In case a cursor moves to the end, a search is made for it from the beginning again.
In case there is no more string to find in Find/Replace string option, the following dialog
box will appear.
In case of opening the document which includes the script in Report Designer
89
Viewer
When a script is interpreted, script syntax is checked. If a syntax error is found, the error
message will appear. If not, a confirmation message will appear.
Error message will notify the column number and the contents of an error and show the
character string with syntax error in the string or script between " marks.
.
90
2. Script Syntax
2.1. Constant
Character, Number, Data and Time etc. are the constants which can be used in a script.
Maximum string length is 256 characters for English characters, numbers, and
symbols. It is 128 characters Korean characters
When you include a quotation mark inside a string constant, use a wave pattern
character (~ : Escape Character).
Example) "ABC", "1234", "Soft", "&$%@#", "Product0+Product1", "~"Country~"", "~~abc"
Here, ~"Country~" expresses the string of Country, and ~~abc" expresses the
string of ~abc.
The wave pattern (~) quote can be used in front of special character used in SQL
statement when you create Query in the script.
91
In Report Designer Script, a record can be made of Date Constant from the year 1900.
92
2.2. Variable
Object variable
Object Variable is the name that a user assigns to an object created in Report Designer.
And you cannot assign the same variable name to two or more objects in one file.
In order to declare the object variable, select the object in the Script dialog box, and assign
the variable name and type..
In Report Designer, other objects except table cells and text frames (Example:
Circle, Line, Cylinder) cant have a variable type..
The variable value change can be modified in the Edit Script dialog box.
Local variable
Local Variable is the variable that is meaningful only inside a script.
An effect is not exerted on an object. And, while performing an operation, String variable and
Number variable will be always initialized to ""(Null Character) and 0 respectively. In other
words, the local variable is only valid during the period when a script is executed and,
after an execution is completed, the value is not saved.
Number, Character, Date and Time can be used as the variable type for the local variable.
And it is used as follows.
NUM i, j;
CHAR s;
DATE d;
TIME t;
93
Temporary variable
A temporary Variable is a variable generated automatically in a time when a value is
assigned to a variable other than the object variable or the local variable, as a result of script
execution. Therefore, the temporary variable is valid during the time when the file is
opened and its value will not be saved in the file.
For example, when B is not declared as an object variable (A is an object variable), if you
describe a script as B = A, then a temporary variable, B will be generated. Of course, if you
give the variable name, B to other object later, a temporary variable will be changed into an
object variable.
A temporary variable is recognized as a string variable as a specific variable type is not
declared. So, in case of using a temporary variable for drawing a comparison between
largeness and smallness, a comparison will be drawn in ASCII order.
As a comparison between largeness and smallness for String variable drawn in ASCII
order it will be 10<2. As a temporary variable is string type variable, you should pay
attention to using it in a statement for comparison between largeness and smallness.
94
When you convert the type of a variable with a different variable type, the first priority is
given to the string variable.
95
* Multiply
/ Divide
Residual except for a quotient gotten from a front value divided by a rear value
Example
a = 2 + 3 * 5;
b = (a - b) / 2 + (a + b) * 2;
Net Income = SUM (Sales$) - SUM(Cost$);
96
<=
It is true if the left operand is less or equal to the right operand. If the right side is less than
the left side, it is false.
<
It is true when the left operand is less than right operand. If the right side is less than left
side, it is false.
>=
It is true if the left operand is greater or equal to right operand. If the right is greater than
left side, it is false.
>
It is true" if the left operand is greater than right operand. If the right side is greater or equal
to left side, it is false.
==
It is true if the both of operands are equal. If the both of operands are unequal, it is false.
!=
It is true if the both of operands are unequal. If the both of operands are equal, it is false.
In a relational expression, Constant, Variable, Logical Expression, Arithmetic Express
and Internal Function can be placed as the operand. And the result value will be express
as true or false. And true and false is respectively 1 and 0.
String Constant and String Variable can be placed as the operand. In case when all
operands are String Constant or String Variable, comparison is made by order of
Dictionary. For example, when you compare report and designer, as designer comes
first in a dictionary, designer is less than report. In case when Give attention when
comparing to 2 and 100, because the result of dictionary style comparison is that 2 is
greater than 100.
97
Example
ret = (200 >= 100);
//ret Result value:True
ret = "Report Designer" > "M2Soft";
//ret Result value:False
a = 100;
b = "200";
ret = a < b;
//ret Result value:True
a = "Report Designer";
b = 100;
ret = a < b;
//ret Result value:Error
98
AND, &&
If all the operands at both sides are true then the results will be true. If only one side is
false, the results will be false.
OR, ||
If one of the operands on both sides is true then the results will be true. If both sides
are false then the results will be false.
!
Negates the result of operand coming after "!".
In a logical expression, a constant, variables, relational expression, arithmetic
expression and internal functions can be placed as the operands. The result value will
be True or False, and 1 for true and 0 for false.
Example
a = 1;
b = 0;
c = 1;
d = 0;
ret = (a && b) || (c || d);
// ret Result value:True
a = 100;
b = 200;
c = 300;
ret = ((a < 200) AND (b == 200)) OR (c == 400);
// ret Result value:True
a = "ABC";
b = 100;
ret = a || (b == 100);
// ret Result value:Error
99
&
This connects one string to the other string. As for a function, it plays the same part as
strcat()function.
Example
ret = ((a + b) > c) AND (k < b);
ret = (Birth Date > "1964/3/1") && (male && Finish Military service) &&
(SUM (Salary$) < Dependent * Living expense per capital);
100
The first column represents the necessary types according to operators or internal functions.
The first row represents the types of variables or constants that the user actually used. For
the cells with assigned numbers, a type will be converted automatically.
In order to operate numbers and characters, characters will be converted to numbers.
In order to operate numbers and dates, dates will be converted to Julian date value.
In order to operate numbers and times, times will be converted to time value.
In order to operate characters and dates, characters will be converted to dates if the
characters have YYYY:MM:DD, YY:MM:DD or MM:DD type.
In order to operate characters and times, characters will be converted to times if the
characters have HH:MM:SS or HH:MM type
You cannot operate dates and times together.
In case of not being convert by the above type conversion rule, then an error message,
101
Inaccurate Type Conversion, will be displayed. You have to manually change the
variable types appropriately.
102
3. Command Statement
Script statements are local variable declaration statement, substitution statement, and
control statement. All statements should be terminated with a ; (semicolon) except for
the statements meaning a specific block. The examples of specific block are; ENDIF (end of
IF block, ENDFOR (end of FOR block), ENDWHILE (end of WHILE block), and
ENDSWITCH (end of SWITCH block).
In the Description of statements and internal functions, [ ] means that an omission is possible,
and | means that you can use one or more of the choices selectively. The Statement
means one or more paragraphs or internal functions.
Description
Declare local variable with character variable type. Can declare array variable as well.
CHAR type variable means a string. It doesnt mean a character type variable in other
languages, i.e. a character.
Example
CHAR GRADE[10];
CHAR LEVEL;
CHAR A, B, C, D;
103
Description
Declare local variable with Date variable type. Can declare array variable as well.
Example
DATE today;
DATE days[10];
104
Description
Declare local variable with numeric variable type. Can declare array variable as well.
Example
NUM Score;
NUM Age[12];
NUM rank_a, rank_b, rank_c;
105
Description
Declare local variable with time variable type. Can declare array variable as well.
Example
TIME now;
TIME event[10];
106
3.2.1. =
Syntax
Variable = Operation Expression | Internal Expression;
Description
Substitute the variable on the left with an operation expression or internal expression on the
right
Example
Company Name = "M2Soft";
number = 123;
greater = Record1 > Record2;
first = !first;
Gang$ = 0;
The maximum value = MAX (value1..value10);
107
Description
It is used when interrupting the execution of a script or when stopping and exiting
FOR/WHILE statement, during the execution of it, even though the result of conditional
paragraph is true. It can also be used to exit SWITCH statement after executing only the
corresponding CASE block in it.
Example
char Msg;
FOR (Index = Last; Index >= Start; Index = Index - 1)
IF (name[Index] == "")
CALL error( );
BREAK; // Exit FOR paragraph.
ENDIF
ENDFOR
IF (Name[Index] == "")
Break; // Stop Execution
ENDIF
108
Description
CONTINUE Statement is used within FOR-ENDFOR and WHILE-ENDWHILE statements, a
control statement to be executed iteratively. When CONTINUE statement is executed in an
iterative execution statement, a move is made to the last of an iterative execution statement
without the execution of sentences after CONTINUE statement.
Example
FOR (Index = 1; Index <= Last; Index = Index + 1)
IF (Name[Index] == "")
CONTINUE;
ENDIF
ENDFOR
Index = 0;
WHILE ( Index < Last )
Index = Index + 1;
IF ( Name[Index] == "")
CONTINUE;
ENDIF
ENDWHILE
109
Example
IF (Tax> 100000 ) Level = "High";
ELSE Level = "Low";
ENDIF
IF (Score > 90) Grade = "A";
ELSE IF (Score > 80) Grade = "B";
ELSE IF (Score > 70) Grade = "C";
ELSE IF (Score > 60) Grade = "D";
ELSE Grade= "F";
ENDIF;
ENDIF;
ENDIF;
ENDIF
110
Example
FOR (Employee= 1; Employee <=Total Employee; Employee = Employee +1)
Gross Amount= Gross Amount + Salary[Employee];
ENDFOR
num i, j;
FOR (i = 1; ; i = i + 1)
IF (:Employee code[i] == "")
BREAK;
ENDIF
Total Salary = Total Salary + Salary [i] + Bonus[i];
FOR (j = 1; j <=Number of Family[i]; j = j + 1)
Family Allowance = Family Allowance + Allowance per capita;
ENDFOR
ENDFOR
111
Example
SWITCH ( type )
CASE 101:
total = (a+b) * 0.8;
BREAK;
CASE 102:
total = (a+b) * 0.9;
BREAK;
DEFAULT:
total = a + b;
ENDSWITCH
112
Example
Employee = 1;
Gross Amount= 0;
WHILE ( Employee <= Total Employee )
IF ( Work[Employee] != Retired )
Gross Amount = Gross Amount+ Salary[Employee];
ENDIF
Employee = Employee + 1;
ENDWHILE
113
4. Internal Function
An internal function is used within a statement, and it includes Arguments in
parentheses. Each Argument differs according to the function, and separated by a comma
(,). An internal function can use another internal function as its Argument, and you can nest
up to 10 functions.
4.1.1. ADDDATABODY()
Syntax
ADDDATABODY(argstr);
Argument
argstr
String that name of object variable, must become string type as tied by quotes
Name of object variable; normal case
EndAddDataBody: must be used in case of finished table enlargement of a table
name of object variable(pageBreak): repetition enlargement with turning page.
Return Value
Number
1: 1 is always returned.
Description
Function to add repeating part of a table when you use the table with a repetition specified
column in the script, i.e. a fixed form report
In case of creating document as the table document, the table is expanded whenever it
114
brings data from database server. However in static document which uses script , even
though it has row set to repeat, it is not expanded automatically , so it needs a function to
expand, therefore the ADDDATABODY( ) function.
You can use one of object variables applied on repetition section as a Argument of
ADDDATABODY( ) function. If there are 2 tables to contain repetition section in one page,
and when you need to expand other table while expanding one table with this function, you
should finish currently expanding table by using EndAddDataBody as a Argument, and
input variable name of other table. In order to pass page at certain moment, you should use
variable (PageBreak) as a Argument.
Example
num i, ret;
char oldee;
i = 1;
a = :a1;
cursor = "mycursor";
execfile declare :cursor cursor;
declareeor("\\eor");
declarefield(cursor, 1, 200);
declarefield(cursor, 1, 200);
declarefield(cursor, 1, 200);
declarefield(cursor, 1, 200);
declarefield(cursor, 1, 200);
while(1)
ret = execfile fetch :cursor into :aa, :bb, :cc, :dd, :ee;
if(ret != 1)
AddDataBody("EndAddDataBody"); /* Finish the currently expanding table */
break;
endif
b = aa;
c = bb;
d = cc;
e = dd;
f = ee;
if(i == 1)
oldee = ee;
endif
if(i > 1 && strcmp(ee, oldee) != 0)
AddDataBody("b(PageBreak)"); /* Table with b object on the next page */
oldee = ee;
else
115
AddDataBody("b");
endif
i = i+1;
endwhile
execfile close :cursor;
116
4.1.2. ADDDATALINE()
Syntax
ADDDATALINE(argstr);
Argument
argstr
String with name of object variable
Name of object variable : must input in type of string as tied by
Return Value
Number
1: 1 is always returned.
Description
It draws lines having the properties of the upper lines with repetition applied, when a table
contains repetition row in a static form document, i.e. a script document.
You can use summary clause, when you draw a line on every certain row in Table document.
That is, if you define condition of summary and didnt define create summary, then only line
shape above summary field appears. However, in order to use this function from a static
using script, this function is used.
Example
if(i == 5)
AddDataBody("b"); /* print repetition section where b object is located */
else
AddDataBody("b");
AddDataLine(c); /* print a line above repetition section where c object is located.*/
endif
117
4.1.3. AVG()
Syntax
AVG (arglist);
Argument
arglist
Argument list to show variables which will be calculated average value.
a1,a2,a3 : three variables of a1, a2, a3
a1a10 :ten variables of between a1~a10
Return Value
Number type
Average value of returned arguments
Description
Calculate the average of argument list. One or more Constant, Variable or operation
Expression can be used as Arguments.
.
Example
ret = AVG (0,1,2,3,4,5,6,7,8,9);
ret = AVG (a, b, c);
ret = AVG (a + b, 36/5 - 1, c * d);
ret = AVG (a$, b?);
ret = AVG (a1..a10);
tot_avg = AVG (SUM (Korean$), SUM(English$), SUM(Mathematics$));
118
4.1.4. BLANK()
Syntax
BLANK(<Variable name>);
Argument
varname
object variable name of formatted object
Return Value
Nonexistence
Description
Blank removes the format of an object with pre-defined format (Example: Text Box indicating
Date) and make it blank.
Example
. blank(date_var);
// Delete the format YYYYMMDD of Date Object date_var and convert it to blank.
119
4.1.5. CHANGEATTR()
Syntax
CHANGEATTR(varname, code, value);
Argument
varname
Object variable to change properties
code
String shows code to change properties
value
String shows execute value of code to change properties
Return Value
Nonexistence
Description
Modify the properties of a cell of Table or TextFrame(Facet properties, Font, Font color).
Value of execution code is applied as properties. Usually, in case of satisfying a condition or
when intending to change character properties, it is used.
When you need to give several execution codes at the same time, by using @ character as
a delimiter, a connection is made of every code each other. Also, the same goes for
execution values. The execution codes and values are as follows.
120
Example
changeattr (a, "FN", "Gulim");
changeattr (a, "BC", "256,256,0");
changeattr (a, "FA@FS", "B@15");
Reference
CHANGEROWATTR()
121
122
4.1.6. CHANGEROWATTR()
Syntax
CHANGEROWATTR(varname, code, value);
Argument
varname
Object variable to change properties.
code
String shows code to change properties.
value
String shows execute value of code to change properties.
Return Value
Nonexistence
Description
Modify properties of row in table(Facet Properties, Fonts, Character color)
This function modifies the properties of TextFrame of row in Table by certain value. Basically
it is the same as changeattr( ) function but this function applies to a row unit.
So you can change row of table include varname total properties by using this function.
And when you need to give several execution code at the same time use @ character as a
delimiter..
Refer to CHANGEATTR() function for execution code and value.
Example
changerowattr (a, "FN", "Gulim");
changerowattr (a, "BC", "256,256,0");
changerowattr (a, "FA@FS", "B@15");
Reference
CHANGEATTR(), CHANGETEXTATTR()
123
4.1.7. CHANGETEXTATTR()
Syntax
CHANGETEXTATTR(varname, inx, strsub, code, value, allflag)
Argument
varname
Object variable to apply.
inx
Number to show location in the varname string which is start to fine strsub. Start from 1.
strsub
string or string variable to fine out in varname string.
code
string shows code to change properties.
value
string shows execute value of code to change properties.
allflag
Number display to change all the matched strings or first one that find out.
0: change the properties of fist string that find out only
1: change all the properties of matched string.
Description
A function to change string properties of searched string which is strsub string on varname
string. Similar with changeattr function but just added string to find out(str).Properties of total
string is change, if give the str value as (null string).
Caution) As for the value of a location to find out strsub on varname string, it will be different
between Unicode version and general version. In case of Unicode version location and
length of characters relate with number of character but In general case relate with number
of bite. In case of a character by a character, the length is 1 in Unicode version but It is 2 in
general version.
There are several execution codes, link each code with separator character @ and execute
value as the same. Execute code value as shown below.
124
Example
changetextattr(CustomerID, 1, "ATR", "FA", "B", 1);
//Find out all the ATR strings in CustomerID string and change to thicker font.
Reference
CHANGEATTR(), CHANGEROWATTR()
125
4.1.8. CONNECTDB()
Syntax
CONNECTDB (connectionid, ipaddr, port, service, dbname, userid, password);
Argument
connectionid
Connection identifier . ConnectDB() id character to use in query and etc, after calling
function.
ipaddr
IP address
port
Port number of database to connect
service
Service name
dbname
DB name made from database service.
userid
User id in database service
password
Password in database service
Return Value
Number type
0 : Connection Failure
1 : Connection Success
Description
Allow to connect to several Database from one document. That is, Function to connect
another database server when databases are scattered at several servers and the
connection to the current database has been terminated. Only, The DBMS of All DB server
must be the same.
To disconnect from the database server that was connected by CONNECTDB() function,
DISCONNECT() function should be used.
Without using ODBC, This function is available only when you use direct connection library
for Report Designer v2.5 supported database (ORACLE, SYBASE, and UNISQL etc.).
126
All the Arguments may not be used and the Arguments are to be used in accordance with the
database servers properties.
Using Argument for database connecting is as shown below.
Example
// ORACLE direct connection
CONNECTDB (orar, , , oraservice, , m2, m2soft);
// SYBASEdirect connection
CONNECTDB(syb, , , sybservice, m2db, m2, m2soft);
An example of EXECSQL for detailed example.
Reference
DISCONNECTDB ( ), EXECSQL
127
4.1.9. COS()
Syntax
COS(arg)
Argument
arg
Radian style number or type of number variable
Return Value
Number type
value of cosign
Description
This is a function that calculates cosine value of trigonometrically function. Used for the
mathematical statistics or numerical value operation, not for the general purposes. The
Argument is formed as radian type.
Example
num ret, PI;
PI = 3.141592;
ret = COS (PI/2);
ret = COS (SUM (a, b, c, d));
ret = COS (PI/3 PI/6 + AVG (a, b, c, d));
Reference
SIN(), TAN()
128
4.1.10. CURRENTDATE()
Syntax
CURRENTDATE ();
Argument
Nonexistence
Return Value
Number type
Julian date value convert to number of current date.
Description
This is a function to get Julian Date of the current system.
Example
DATE d;
num cdate;
cdate = CURRENTDATE();
d = cdate + 10; /* Date value of 10 days later */
Reference
CURRENTTIME(), DATE(), TIME()
129
4.1.11. CURRENTTIME()
Syntax
CURRENTTIME();
Argument
Nonexistence
Return Value
Type of time
Time value of current time.
Description
This is a function to get the current time.
Example
time ctime
ctime = CURRENTTIME();
Reference
CURRENTDATE(), DATE(), TIME()
130
4.1.12. DATE()
Syntax
DATE(julian, kind);
Argument
julian
Number to display julian date.
kind
Kind of value to return.
YEAR : year
MONTH : month
DAY : day
WEEKDAY : weekday (1: sunday, 2: monday ..., 7: saturday)
Return Value
Number types
the returning value according to kind value.
Description
Extract a desired value(year, month, day or weekday) from Julian date value.
Example
NUM Curdate;
NUM Day;
Curdate = CURRENTDATE();
iYear = DATE(curdate, YEAR);
iMonth = DATE(curdate, MONTH);
iDay = DATE(curdate, DAY);
Day = DATE(curdate, WEEKDAY);
if (Day == 1)
sWeekDay = "Sunday";
endif
Reference
CURRENTDATE(), CURRENTTIME(), TIME()
131
4.1.13. DECLAREEOR()
Syntax
DECLAREEOR(str);
Argument
str
String to separate subdata. Basic value is //EOR//.
Return Value
Number type
0: failure
1: success
Description
When you use a script for file connection, you have to define a field using DECLAREFIELD()
function to support the subquery.
When you get data values using Execfile fetch function, you have to indicate EOR (end of
record) for a data file to recognize the end of data records corresponding to each subquery.
In this case, you can specify the EOR using DECLAREEOR() function. The default value of
EOR has been set as //EOR// without calling the function.
Example
Refer to an example of DECLAREFIELD()
Reference
DECLAREFIELD(), EXECFILE
132
4.1.14. DECLAREFIELD()
Syntax
DECLAREFIELD(cursorname, type, length) ;
Argument
cursorname
cursor name of subdata
type
field type
1: CHAR
2: NUMERIC
9: DATE
10: TIME
12: VARCHAR (when the field include opening character)
length
length of field(maximum length to display current data)
Return Value
Number type
0: failure
1: success
Description
Define field corresponding to a subquery when a script is used for file connection..
In file connection static form document, when you create a document in the same format as
a subpage, you should define a corresponded field type and length to support sub field.
If this function is called for the first time, it notifies column information that contains Argument
(cursor name, type and length) to a cursor. At second call, notifies 2nd column information.
All of the Arguments should be defined before you call fetch function.
Example
aaa = :a1;
bbb = :a2;
ccc = :a3;
ddd = :a4;
eee = :a5;
cursor = "mycursor";
133
// Cursor definition
Reference
EXECFILE
134
4.1.15. DEFINECHART()
Syntax
DEFINECHART(chartname, axisname, dataname);
Argument
chartname
variable name of chart object
axisname
string to display axis name of chart
dataname
string to display data apply at axis
Return Value
Nonexistence
Description
Function to define necessary information for chart object
Used to define chart objects in a script. After defining corresponding variables for X Axis, Y
Axis, and Z axis, you can draw a chart by using DrawChart() function that transmit each
variable values to a chart object.
Definechart(),drawchart() function was applied in primary version of Report Designer(before
3.0). You can use defineseries(), drawseries() functions which are added with teechart is
offer.
Example
definechart(mychart, "X", "Products.ProductName");
definechart(mychart, "Y", "Categories.CategoryName");
definechart(mychart, "Z", "Products.UnitsInStock");
catename = :Categories.CategoryName;
cursor = "mycursor";
query = "SELECT C.CategoryName, P.ProductName, P.UnitPrice, P.UnitsInStock FROM
Categories C, Products P
WHERE C.CategoryID = P.CategoryID AND Categories.CategoryName = :catename
ORDER BY C.CategoryName, P.ProductName";
execsql declare :cursor for :query;
135
Reference
DEFINESERIES(), DRAWSERIES(), SETSERIESTITLE()
136
4.1.16. DEFINESERIES()
Syntax
DEFINESERIES(chartname, seriesname, var1, var2, var3);
Argument
chartname
variable name of chart object
seriesname
string to display series name that chart object has. Must be tied by . Anticipate
formatted series in editor. When viewer execute, re-naming sequence at formatted
series such as S0, S1, S2 . The numbers in the above names and index of series
may alter, if series is deleted cause of calling Deleteseries() function.
var1
String shows variable name to apply at Series. Must be tied by .
var2
String shows variable name to apply at horizontal axis of Series. Must be tied by .
var3
Normally input (null string) but in case of using variable name should be tied by .
When variable name is applied and drawseries() is called, it is current variable and is
added to series and displayed on Legend if its value is different from the previous value.
Return Value
Nonexistence
Description
Function to assign data variable name which will be applied to seriesname series. Var1 is
series data value, and var2 is data value of axis that series refers to.
Example
defineseries(mychart, "S0", "stock", "productname", "");
defineseries(mychart, "S2", "order", "productname", "");
deleteseries(mychart, "S1");
setseriestitle(mychart, "S0", "stock amount");
setseriestitle(mychart, "S2", "order amount");
cid = :Categories.CategoryID;
137
category = :Categories.CategoryName;
cursor = "mycursor";
query = "select products.ProductName, products.UnitsInStock, products.UnitsOnOrder
from Products where Products.CategoryID=:cid";
execsql declare :cursor cursor for :query;
first = 1;
while(1)
ret = execsql fetch :cursor into :productname,:stock,:order;
if(ret != 1 && first == 0)
AddDataBody("EndAddDataBody");
break;
endif
drawseries(mychart, "S0");
drawseries(mychart, "S2");
AddDataBody("productname");
first = 0;
endwhile;
execsql close :cursor;
Reference
DEFINESERIESXY(), DEFINESERIESXYS(), DRAWSERIES()
138
4.1.17. DEFINESERIESXY()
Syntax
DEFINESERIESXY(chartname, seriesname, x, y, label);
Argument
chartname
variable name of chart object
seriesname
string to display series name that chart object has. Must be tied by . Anticipate
formatted series in editor. When viewer execute, re-naming sequence at formatted
series such as S0, S1, S2 . The numbers in the above names and index of series
may alter, if series is deleted cause of calling Deleteseries() function.
x
string display variable name to apply at X axis. Must be tied by .
y
string display variable name to apply at Y axis. Must be tied by .
Label
string display variable name to use as label. Must be tied by .
Return Value
Nonexistence
Description
Function to assign X axis and Y axis variable names which will be applied to seriesname. In
case of a specific series, it can not be assigned as defineseries() function cause of requiring
Y axis data. In this case using defineseriesxy().
Example
char a1, a3;
char a2, a4;
defineseriesxy(mychart, "S0", "a1", "a2", "");
defineseriesxy(mychart, "S1", "a3", "a4", "");
a1 = 0;
a2 = 0;
a3 = 0;
a4 = 7.251;
139
drawseries(mychart, "S0");
drawseries(mychart, "S1");
a1 = 0;
a2 = 0;
a3 = 23.3;
a4 = 45.1;
drawseries(mychart, "S0");
drawseries(mychart, "S1");
Reference
DEFINESERIES(), DEFINESEARIESXYZ()
140
4.1.18. DEFINESERIESXYZ()
Syntax
DEFINESERIESXYZ(chartname, seriesname, x, y, z, label);
Argument
chartname
variable name of chart object
seriesname
string to display series name that chart object has. Must be tied by . Anticipate
formatted series in editor. When viewer execute, re-naming sequence at formatted
series such as S0, S1, S2 . The numbers in the above names and index of series
may alter, if series is deleted cause of calling Deleteseries() function.
x
string display variable name to apply at X axis. Must be tied by .
y
string display variable name to apply at Y axis. Must be tied by .
z
string display variable name to apply at Z axis. Must be tied by
label
string display variable name to use as label. Must be tied by .
Return Value
Nonexistence
Description
Function to fix X axis, Y axis, Z axis variable name to apply at seriesname. In case of specify
series, It can be accord can not fix with defineseies() function cause of require Y axis data. In
this case using defineseriesxy().
Example
Refer to example of DEFINESERIESXY( ).
Reference
DEFINESERIES(), DEFINESERIESXY()
141
4.1.19. DELETESERIES()
Syntax
DELETESERIES(chartname, seriesname);
Argument
chartname
variable name of chart object
seriesname
string to display series name that chart object has. Must be tied by . Anticipate
formatted series in editor. When viewer execute, re-naming sequence at formatted
series such as S0, S1, S2 . The numbers in the above names and index of series
may alter, if series is deleted cause of calling Deleteseries() function.
Return Value
Nonexistence
Description
Function to delete seriesname series. When you designing chart of report on Editor, In case
of you made many serieses, delete unusing series on executing Viewer.
Example
Refer to an example of DEFINESERIES( ).
Reference
DEFINESERIES()
142
4.1.20. DELWSPACE()
Syntax
DELWSPACE(str, pos);
Argument
str
string to delete null space
pos
number to display location of deleting null.
-1: delete front side null of string.
-In case of non 1: delete back side of string.
Return Value
string
string with except null space.
Description
Delete white spaces (Tab, Blank and Return) ahead of or after character string. If the
position is -1, then delete blank characters from the front, otherwise delete from behind.
Blank Characters in the middle of character string cannot be deleted.
Example
a = " White Space";
ret = DELWSPACE (a,-1); // ret = "White Space"
a = "Blue Sky ";
ret = DELWSPACE (a,1); // ret = "Blue Sky"
143
4.1.21. DISCONNECTDB()
Syntax
DISCONNECTDB(connectionid);
Argument
connectionid
ID string to database connect in ConnectDB() function.
Return Value
Number type
0: failure
1: success
Description
This is a function to disconnect database connection connected using CONNECTDB()
function. Disconnect from current connected database server in order to connect with
another database when the databases are scattered across several servers.
To connect with another database server with CONNECTDB() function, disconnect from the
currently connected server first by using DISCONNECT() function.
Without using ODBC, This function is available only when you use direct connection library
for Report Designer v2.5 supported database (ORACLE, SYBASE, and UNISQL etc.).
Example
DISCONNECTDB (oras); // Use the first Argument at CONNECTDB() function
Refer to the example of EXECSQL for a detailed example.
Reference
CONNECTDB(), EXECSQL
144
4.1.22. DRAWCHART()
Syntax
DRAWCHART(chartname);
Argument
chartname
variable of chart object
Return Value
Nonexistence
Description
Draw a chart object.
Function to draw a chart after defining chart object in a script. After definition of
corresponding variables for X Axis, Y Axis, and Z axis with DefinChart() function,
DrawChart() function transmits each variable value to a chart object in order to draw a chart.
Definechart(),drawchart() function was provided in primary version of Report Designer(before
3.0). You can use defineseries(), drawseries() functions which are added as teechart is
provided in Report Designer.
Example
Refer to the example of DEFINECHART().
Reference
definechart(), defineseries(), drawseries()
145
4.1.23. DRAWIMAGE()
Syntax
DRAWIMAGE(x, y, path, width, height, opt);
Argument
x
number display X coordinates to print image.
unit of coordinates value and basic location follow using of Report Designer.1 inch as
1000
y
number display Y axis to print image.
path
string to display image path.
width
number of image width.
height
number of image height.
opt
number to display option.
0: format image with no size.
1: format image with proportional size
Return Value
Nonexistence
Description
Image file which in path, function drawing specify size width, height to specify location x, y of
report.
Example
char path;
path = http://www.m2soft.co.kr/testimage.jpg;
drawimage(100, 100, path, 2000, 1000, 0);
146
4.1.24. DRAWLINE()
Syntax
DRAWLINE(x1, y1, x2, y2, command, value);
Argument
x1
number of X coordinates which is start point to draw line.
unit of coordinates value and basic location follow using of Report Designer.1 inch as
1000
y1
number of Y coordinate which is start point to draw line
x2
number of X coordinate which is end point of drawing line
y2
number of Y coordinate which is end point of drawing line
command
string defining the shape and properties of line arrow.
value
string displaying a value according to a command
Return Value
Nonexistence
Description
Function to draw line object.
At calling this function, if some Arguments are not defined, they will follow properties defined
by SETDRAWOBJECTTR(). Command defines properties and value is assigned to the
properties.
Example
num x1, y1, x2, y2;
x1 = 1000;
y1 = 1000;
x2 = 5000;
y2 = 1000;
147
148
4.1.25. DRAWSERIES()
Syntax
DRAWSERIES(chartname, seriesname);
Argument
chartname
variable name of chart object
seriesname
string to display series name that chart object has. Must be tied by . Anticipate
formatted series in editor. When viewer execute, re-naming sequence at formatted
series such as S0, S1, S2 . The numbers in the above names and index of series
may alter, if series is deleted cause of calling Deleteseries() function.
Return Value
Nonexistence
Description
Defineseries() draws Chart Object selected by chartname and seriesname. Whenever
calling this function, one record is applied to Chart.
Example
Refer to example of DEFINESERIES( ).
Reference
DEFINESERIES(), DELETESERIES()
149
4.1.26. DRAWTEXT()
Syntax
DRAWTEXT(x1, y1, x2, y2, text, command, value)
Argument
x1
number display start point of drawing line by X coordinates.
unit of coordinates value and basic location follow using of Report Designer.1 inch as
1000
y1
number display start point of drawing line by Y coordinates.
x2
number display end point of drawing line by X coordinates.
y2
number display end point of drawing line by Y coordinates.
text
contents string of text frame
command
string define properties of text frame.
value
string display value as command
Return Value
Nonexistence
Description
This function draws TextFrame. If some Arguments are not defined at calling this function,
they will follow properties defined by SETDRAWOBJECTTR().Command defines
properties and value is assigned to theproperties.
Example
num x1, y1, x2, y2;
x1 = 1000;
y1 = 1000;
x2 = 5000;
150
y2 = 1500;
drawtext(x1, y1, x2, y2, "TEST STRING", "FN@FS", "Tahoma@20");
// draw 4inches text frame on top of the report.
151
4.1.27. DRILLDOWN()
Syntax
DRILLDOWN(mrdpath, param);
Argument
mrdpath
mrd file consisting of template to be shown by DRULLDOWN() file.
param
Report Designer Argument option to open mrd file.
additional Arguments
/rdrillright : To be shown at the right side of hyperlink Object.
/rdrillover : To be shown at the top of hyperlink Object".
Return Value
Number type
Description
This function is used in result report. If DRILLDOWN() is called twice for an Object, the
result is the same as DRILLUP() Function is applied.
This function can not be used for script of Fixed Formreport. The functions, which can be
used only for Hyperlink Objects script, are DRILLDOWN(), DRILLUP() and SORTDATA() etc.
152
Example
drilldown("ordserstatistics.mrd", "/rp [Less than 10] /rdrillright ");
Reference
DRILLUP()
153
4.1.28. DRILLUP()
Syntax
DRILLUP();
Argument
Nonexistence
Return Value
Nonexistence
Description
This function deletes Object inserted by DRILLDOWN(). If DRILLDOWN is applied to an
Object twice, the result is the same as DRILLUP() is applied.
This function can not be used for script of Fixed Formreport. The functions, which can be
used only for Hyperlink Objects script, are DRILLDOWN(), DRILLUP() and SORTDATA() etc.
Example
Refer to example of DRILLDOWN() function
Reference
DRILLDOWN()
154
4.1.29. EXECFILE
Syntax
EXECFILE DECLARE <cursor name> cursor
EXECFILE FETCH <cursor name> INTO <comma separated host variable list>;
EXECSQL CLOSE <cursor name>;
Argument
<cursor name>
sting variable to designate <cursor name>.
<cursor> is designated in DELAREclause, and is closed in CLOSE clause.
<comma separated host variable list>
In case of main data, data variable list as many as numbers of field declared in field
definition. In case of sub data, data variable list as many as declarefieldI() function is
executed.
Return Value
Number type
1: success
other : failure
Description
Used for processing of values in a file connected by a script while file connection in fixed
form document.
This function is exactly the same as EXECSQL in DB Connection document. Except, there is
no reconciliation with query paragraph in DECLARE paragraph. A query paragraph is not
needed because EXECFILE gets data directly from a text file, whereas EXECSQL attempts
to get a data directly from a database.
The logic for bringing data from Text file by using EXECFILE in static document created by
script.
DECLARE statement set cursor on the location of first record in query result table. FETCH
statement brings data from query result table by moving the cursor down one row and it
ends when cursor has reached the final record. Then, the cursor is closed by CLOSE
statement.
EXECSQL can have multi-query at the same time, but the report using EXECFILE can have
only one cursor at a time cause it brings record from the first record to the final record one
after another in text file
155
Use declarefield( ) to define field definition for each record set when you create a document
(sub page document of table document) which has Master-detail structure or prints several
record set.
Example
Refer to the example of DECLAREFIELD()
Reference
EXECSQL, DECLAREFIELD(), DECLAREEOR()
156
4.1.30. EXECSQL
Syntax
EXECSQL DECLARE <cursor name> CURSOR FOR <query> [ON <db server>];
EXECSQL FETCH <cursor name> INTO <comma separated host variable list>;
EXECSQL CLOSE <cursor name>;
EXECSQL COMMAND <query> [ON <db server>];;
Argument
<cursor name>
sting variable to designate <cursor name>.
<cursor> is designated in DELAREclause, and is closed in CLOSE clause.
<query>
string variable including query statement to fetch data.
<db server>
connection id connected other database service by using ConnectDB() function.
<comma separated host variable list>
data variable list as many as numbers of field in Select clause of <query> statement.
Return Value
Number type
1: success
other: failure
Description
Performs cursor declaration, data fetch, and exit cursor, etc. for execution of SQL paragraph.
A FETCH paragraph gets data from database, which declared in a query paragraph as
variables (object variable, local variable, temporary variable). At every execution of FETCH
paragraph, it gets one record. In order to get next data, you have to execute FETCH
paragraph one more time.
CLOSE paragraph ends the cursor declared by DECLARE paragraph.
Here, we show Description with the result query table after executing SQLstatement.
DECLARE statement sets cursor on the location of first record in query result table. FETCH
statement brings data from query result table by moving cursor down one row and it ends
157
when cursor reaches the last record. The cursor is then closed by CLOSE statement.
FETCH paragraph returns 1 for a successful execution, 0 for if theres no more data, and 1
for errors occurred, respectively. DECLARE and CLOSE paragraphs return 1 for successful
execution and 0 for errors occurred respectively.
To get data values from another database server under a scattered database server
environment, you have to make cursor to connect with a specific database server by adding
ON <db server> at the end of DECLARE paragraph. Here, The <db server> is a connection
handle made by CONNECTDB().
Notice) it is possible to index host variable in SQL Clause. However identifier using as
Number and variable of num type can be indexed and expression or function can not
be used.
Example
Example 1
num employee, num I, tord;
date tgord;
num ret_m, ret_s, tunit, tquan, tprod;
kname = :Employees.FirstName;
ename = :Employees.LastName;
sex = :Employees.TitleOfCourtesy;
phone = :Employees.HomePhone;
address = :Employees.Address;
employee = :Employees.EmployeeID;
/* like above example, in case that inputting data brought by Database-Query define Menu
as a variable by substitution sentence */
/* Use cursor and query as a SQL host variables for communication */
cursor = "mycursor";
query = "select orders.OrderID, orders.OrderDate, orders.CustomerID from orders
where orders.EmployeeID = :employee";
/*Input : infront of variable name in case that using script internal variable in condition
clause of Query statement */
execsql declare :cursor cursor for :query;
for(i=1; i<11; i=i+1)
ret_m = execsql fetch :cursor into :tord, :tgord, :tcustomerid;
if (ret_m != 1)
break;
158
endif
/* Using :tored, the host variable, you can create a dynamic query. */
cursor1 = "mycursor1";
query1 = "select O.UnitPrice, O.Quantity, O.ProductID from [order details] O
where O.orderid = :tord";
execsql declare :cursor1 cursor for :query1;
ret_s = execsql fetch :cursor1 into :tunit, :tquan, :tprod;
if (ret_s != 1)
execsql close :cursor1;
continue;
endif
/* Important: Without using variables using index inside SQL, a object variable will be
replaced after the successful fetch execution, in order not to printout incorrect values
occurred by errors / the end of a data. */
orderid[i] = tord;
gorderdate[i] = tgord;
unitprice[i] = tunit;
quantity[i] = tquan;
product[i] = tprod;
total[i] = tunit * tquan;
/* to reuse the cursor inside loop, you have to close with execsql close paragraph. */
execsql close: cursor1;
endfor
execsql close :cursor;
Example 2
num I;
date tgord;
num ret_m, ret_s;
num count;
dbname1 = mydb1;
/* For a connection to Oracle, using ServiceName, UserID, and Password in connectdb
function will be enough. */
Connectdb(dbname1, , , halla, , scott, tiger);
Cursordb = mycursordb;
Querydb = select kwnam, chasu, addr, kwcod, sogwan from cdkikw_f;
/* To connect to databases scattered, attach connection name connected by connectdb
159
function at the end while create a cursor for a query. (on :dbname1)
*/
execsql declare : cursordb cursor for :squerydb on :dbname1;
dbname2 = mydb2;
connectdb(dbname2, , , baekdu, , scott, tiger);
cursordb2 = mycursordb2;
querydb2 = select s_name, s_num, s_addr, s_code, s_birth from student;
execsql declare :cursordb2 cursor for :querydb2 on :dbname2;
while(1)
count = count + 1;
if(count == 10)
break;
endif
ret_s = execsql fetch :cursordb into :f1, :f2, :f3, :f4, :f5;
if (ret_s != 1)
AddDataBody(EndAddDataBody);
break;
endif
ret_s = execsql fetch :cursordb2 into :f6, :f7, :f8, :f9, :f10;
if (ret_s != 1)
AddDataBody(EndAddDataBody);
break;
endif
AddDataBody(f2);
Endwhile
// Close a cursor..
execsql close :cursordb;
execsql close :cursordb2;
// Close the connected database
disconnectdb(dbname1);
disconnectdb(dbname2);
160
4.1.31. FORMAT()
Syntax
FORMAT(varname, str, opt)
Argument
varname
Variable to be changed into a specific string Format. Only number, date and time
variable are supported.
str
String to designate Format.
opt
0 : Show meaningless Number. Example) 2005-12-04
1 : No show meaningless Number. Example) 2005-12- 4
Return Value
String
String to be changed as Format
Description fraction
This function changes value of variable name into String Format . Return value
is string changed as String Format . Usually Edit Format allows defining
String Format , However if you want to use two or more kinds of data at the same
place, this function is more useful. For typical example, after changing a specific
format into a string, you can connect it to other data with & operator.
Opt, meaningless number is, for example, 0 in front of 9 of 2005-09-10
so if those are removed, return value is 2005-9-10 .In case of decimal fraction,
this function removes the last 0 below decimal point.
In case that varname is number format , only String Format available in
Edit Format can be used.
Example
ret = format(dateval, yyyy-mm-dd, 0)
// if date Foramt data datival is Jan. 30, 2006
//return value: ret == 2006- 1-30
ret = format(numval, #,###.###, 1)
//If numerical Fromat data numval is 1234.56, return valye: ret == 1,234.560
161
Reference
162
4.1.32. GETGLOBAL()
Syntax
GETGLOBAL(varname);
Argument
varname
string to display global variable name, must be tied by .
Return Value
string
value of global variable
Description
This function fetches value from a specific global variable.
In Fixed Form Report, script is running per each record of main data and each script has a
independent variable(Object, Local and Temporary ). When you want to apply a specific
result value of script to the next script, it would be passed as a global variable.
SETGLOBAL() function sets a variable as a global variable, and GETGLOBAL() function
gets data from a global variable.
Example
char dname, new_dname;
dname = getglobal(g_dname);
if (new_dname != )
setglobal(g_dname, new_dname);
endif
Reference
SETGLOBAL()
163
4.1.33. GETPARAM()
Syntax
GETPARAM (arg);
Argument
arg
string to display variable name inputted by Argument
Return Value
string
value of arg variable
Description
This function loads value passed by /rp, /rv Argument into script when it is executed as
Viewer.
The Arguments at GETPARAM function is an Argument name assigned in the Report
Viewer execution. That is, when value is passed by /rp or /rpn Argument, it is $1, $2, etc.
and when value is passed by /rv Argument, it is a variable name defined in /rv Argument
definition.
When the corresponding Argument is not found, errors occur during execution. The
Argument definition is performed in the second argument of FileOpen() Method in case of
using OCX Viewer and is performed in execution Argument in case of executing EXE Viewer.
Example
CHAR s1;
s1 = GETPARAM ($1);
164
4.1.34. GOTOPAGE()
Syntax
GOTOPAGE(pageno);
Argument
pageno
Number to display page No.
Return Value
Nonexistence
Description
At crating a report with DRAWLINE(), DRAWTEXT() function, this function allows moving to
other page from current page.
pageno: page number
Reference
DRAWLINE(), DRAWTEXT()
165
4.1.35. LIBFREE()
Syntax
LIBFREE(filename);
Argument
filename
DLL file name which rode from LIBLOAD()
Return Value
Nonexistence
Description
Report Designer provide a function allowing external libraries(Dynamic Linking Library:, DLL)
in script. It is very useful because any libraries can be used. Refer to LIBLOAD().
Free DLL (Dynamic Linking Library). A file name will be used as an Argument. The
Argument should agree with the file name used as an Argument in LIBLOAD function.
In order to use DLL file, those are modified to be suitable for Report Designer.
Example
Example of Script
num n;
num ret;
char libname;
char s;
libname = "e:\testdll\release\example.dll";
Libload(libname);
ret = Hello(s, n);
messagebox(s, "string", OK);
messagebox(n, "count number", OK);
ret = Hello(s, n);
messagebox(n, "count number", OK);
ret = Hello(s, n);
messagebox(n, "count number", OK);
LibFree(libname);
166
Example.def
167
1. If you call functions in a library after the execution of LIBLOAD in a script, the returned
result should be substituted with NUM type variables.
2. If the function used in a script is Hello, it should be _M_HELLO type in DLL preparation.
In other words, all the characters should be written in capitals and _M_ should be in front of
a function name. In a script, there is no distinction between the upper and lower case, but
the function names existing on a library distinguish the upper and lower case. The reason
why you have to use capitals is to prevent using capitals together with lower cases.
3. There should be only two Arguments in DLL function definition.
int argc: represents the numbers of Arguments. It is always larger than the numbers of
Arguments when called by a script by one.
char *argv[]: The way to transmit Arguments of a function in a script. The argv[0] is always
rdviewer.exe and transmit Arguments from argv[1] one by one. Since all Arguments are
transmitted in a form of pointer, it is possible to call by reference.
5. When a string is passed from DLL functions using StrCpy, etc, it should not exceed 256
characters.
Reference
LIBLOAD()
168
4.1.36. LIBLOAD()
Syntax
LIBLOAD(filename);
Argument
filename
DLL file name to rode
Return Value
Nonexistence
Description
Report Designer provide a function allowing external libraries(Dynamic Linking Library:, DLL)
in script. It is very useful because any libraries can be used. Refer to LIBFREE().
LIBLOAD() function loads DLL (Dynamic Linking Library) file. Refer to LIBFREE() function on
its example and usage.
Example
Refer to LIBFREE() function
Reference
LIBFREE ( )
169
4.1.37. LOADIMAGE()
Syntax
LOADIMAGE(varname, path);
Argument
varname
object variable name of image to input
path
path of image file
Return Value
Nonexistence
Description
Read and display a picture file on an object.
Loads and shows image file corresponded to the file path of object assigned on value name
of Argument.
Example
char path;
path = c:\temp\image.jpg;
loadimage(a, path); // Read picture file at a object
170
4.1.38. LOG()
Syntax
LOG (num);
Argument
num
value to be applied natural Logarithm, not allowing 0.
Return Value
Number Format
Calculated natural logarithmic value of num
Description
Calculate natural logarithmic value of the Argument. Used for the mathematical statistics or
numerical value operation, not for general purposes. The Argument cannot be 0.
Example
ret = LOG (2.717);
ret = LOG (b/3.14);
Reference
LOG10()
171
4.1.39. LOG10()
Syntax
LOG10(num);
Argument
Num
Number or number format variable to be applied logarithm. No allowing 0.
Return Value
Number Format
Calculated logarithmic value of num.
Description
Calculate log function value when Argument root value is 10. Used for the mathematical
statistics or numerical value operation, not for general purposes. The Argument cannot be 0.
Example
y = LOG10 (2.717);
y = LOG10 (b/3.14);
172
4.1.40. MATCH()
Syntax
MATCH (str, strsub);
Argument
str
String or String variable.
substr
String or String variable to be found.
Return Value
Number Format
location of the found string.
-1 : No matched string
> 0 : location
Description
Check String1 whether it contains String2. Only 2 Constant, Variable or Operation
expressions can be used as Arguments. The result value will be 1 (False) if String2 is not
in String1. Otherwise the return value represents the position of String1 where String2
begins. The position of first character of String1 is 1. English characters occupy 1 digit per
character, and Asian DBCS characters occupy 2.
Example
ret = MATCH ("Korea Seoul, Korea");
// ret == 1
ret = MATCH (12345, 5);
// ret == 5
Reference
STRSTR()
173
4.1.41. MAX()
Syntax
MAX(arglist);
Argument
arglist
Argument list to get the maximum value
example) a1,a2,a3 : a1, a2, a3 three variables
a1..a10 : a1 ~ a10 ten variables
Return Value
Number
Max. value among input Arguments
Description
Calculate the maximum value in the argument list. One or more Constant, Variable or
Operation expressions may be used as Arguments.
Example
ret = MAX (0,1,2,3,4,5,6,7,8,9);
ret = MAX (a, b, c);
ret = MAX (a + b, 36/5 - 1, c * d);
ret = MAX (a$, b?);
ret = MAX (a1..a10);
Reference
MIN()
174
4.1.42. MESSAGEBOX()
Syntax
MESSAGEBOX (content, title, kind);
Argument
content
String to be displayed in Message Box
title
Title of Message Box
kind
Type of Message Box
OK : In case Message Box has only OK button.
OKCANCEL : In case Message Box has only OK and CANCEL button.
Return Value
Number
1 : In case of clicking OK"
2 : In case of clicking CANCEL
Description
Display a message.
Display a windows message box with intended contents and title. Its used to notify user of
some message or to see certain value during script execution for debugging.
Example
IF (Result == 1)
String = TRUE;
ELSE
String = FALSE;
ENDIF
MESSAGEBOX(String, Result, OK);
175
4.1.43. MIN()
Syntax
MIN(arglist);
Argument
arglist
argument list
example) a1,a2,a3 : a1, a2, a3 three variables
a1..a10 : a1 ~ a10 ten variables
Return Value
Number
Min. value among input parameters
Description
Calculate the minimum value in the argument list. 1 or more Constant, Variable or Operation
expressions can be used as Arguments.
Example
ret = MIN (0,1,2,3,4,5,6,7,8,9);
ret = MIN (a, b, c);
ret = MIN (a + b, 36/5 - 1, c * d);
ret = MIN (a$, b?);
ret = MIN (a1..a10);
Reference
MAX()
176
4.1.44. PAGE()
Syntax
page()
Argument
Nonexistence
Return Value
Number
Page number in the process of the current script.
Description
This is the function to display the page number
Reference
GOTOPAGE()
177
4.1.45. PAGEBREAK()
Syntax
PAGEBREAK()
Argument
Nonexistence
Return Value
Nonexistence
Description
This function closes the current page and creates the next page.
It is used when a report is drawn by drawline(), drawimage() etc.
Example
pagebreak();
Reference
GOTOPAGE()
178
4.1.46. POW()
Syntax
POW(num, exp)
Argument
Num
Base of exponents . Number or Number variable.
Exp
power of exponents. Number or Number variable Return Value
Number
the exponent value to be returned.
Description
Calculate the result of a power operation of Argument. This is used when calculating a
numerical value like the square of 10. Base is the first Argument, and the exponent is the
second Argument. The second Argument cannot be a negative value when the first
Argument is 0.
Example
ret = POW (3,5);
ret = POW (b/3, a/4);
Reference
SQRT()
179
4.1.47. RANDOM()
Syntax
RANDOM ([seed]);
Argument
Seed
Seed value to generate random value. It is possible not to use seed.
(NULL is available)
Return Value
Number
random value
Description
Function to get a random value The Argument is a seed that can be omitted.
Example
NUM seed, ret;
ret = RAMDOM( );
seed = RANDOM ( );
ret = RANDOM (seed);
180
4.1.48. REPLACESTR()
Syntax
REPLACESTR (org, str1, str2);
Argument
org
Original String
str1
String to be found
str2
String to be replaced
Return Value
String
Replaced String
Description
Replace str String to str2 string in original string org.
Example
ret = REPLACESTR ("Seoul Korea","Seoul","Busan");
// ret == Busan Korea
ret = RMSTR ("ABCABCABC", "CA", DD);
// ret == ABDDBDDBC
Reference
RMSTR()
181
4.1.49. RMSTR()
Syntax
RMSTR (str1, str2);
Argument
str1
Original String
str2
String to be deleted from Original String
Return Value
String
remained string after deleting string str2 from string str1.
Description
If str1 contains the same string as str2, it deletes the contained string. Result value is a string
in which the part corresponding to Argument 2 is removed from Argument 1.
Example
ret = RMSTR ("Republic of Korea, Republic of");
// ret == Korea
ret = RMSTR ("ABCABCABC","CA");
// ret == ABBBC
Reference
MATCH(), REPLACESTR()
182
4.1.50. ROUND()
Syntax
ROUND(num [,pos]);
Argument
num
Number or Number Variable to be rounded off
pos
Position to be rounded off ( -9 ~ 9 ).
Null : round at below decimal places
-1 : round at below decimal places
0 : round at below decimal places
1 : round at below 1 decimal places
Return Value
Number Format
round off to the nearest integer.
Description
Round the Argument value in accordance with the decimal places. Decimal places are valid
from -9 to 9 and it can be omitted.
Example
NUM i, ret;
i = 765.267;
ret = ROUND (i);
ret = ROUND (i, 2); // the result of ret is 765.27 (round at below 2 decimal places)
ret = ROUND (i,-1); // the result of ret is 770
Reference
TRUNC()
183
4.1.51. SETAXISAUTO()
Syntax
SETAXISAUTO(chartname, axisname, opt);
Argument
chartname
Chart Object Variable name.
axisname
String for the name of Chart axis. Axis names predefined by Editor are. Usually Left,
Right, Top, Bottom.
opt
Define whether Max. , Min Value are set by your system.
0 : Using SETAXISMAX(), SETAXISMIN() to set Max. Value, Min. value
1 : Max. Min is set by your System.
Return Value
Nonexistence
Description
Deeside to set maximum value and minimum value that specify Axis expressed on chart
automatically or not.
Example
int autoopt;
if (autoopt == 0)
setaxisauto(chart1, Left, 1);
setaxismax(chart1, Left, 100);
setaxismin(chart1, Left, 0);
endif
Reference
SETAXISMAX(), SETAXISMIN();
184
4.1.52. SETAXISMAX()
Syntax
SETAXISMAX(chartname, axisname, value);
Argument
chartname
Chart Object Variable name
axisname
String for the name of Chart axis. Axis names predefined by Editor are. usually Left,
Right, Top, Bottom.
value
Max. Value to be shown
Return Value
Nonexistence
Description
Define Min. value to be described on a specific Axis.
Example
Refer to the example of SETAXISAUTO()
Reference
SETAXISAUTO(), SETAXISMIN()
185
4.1.53. SETAXISMIN()
Syntax
SETAXISMIN(chartname, axisname, value);
Argument
chartname
Chart Object variable name
axisname
String for the name of Chart axis. Axis names predefined by Editor are usually Left,
Right, Top, Bottom.
value
Min. to be shown on Axis
Return Value
Nonexistence
Description
Define Min. value to be described on a specific Axis.
Example
Refer to SETAXISAUTO() function.
Reference
SETAXISAUTO(), SETAXISMAX()
186
4.1.54. SETCHARTTITLE()
Syntax
SETCHARTTITLE(chartname, title);
Argument
chartname
Chart Object variable name
title
Title of the chart of chartname
Return Value
Nonexistence
Description
Assign Title to the chart corresponding to chartname.
TITLE: String for "Title
187
4.1.55. SETDRAWOBJATTR()
Syntax
SETDRAWOBJATTR (command, value)
Argument
Command
String to define Shape and Properties of Object to be drawn
Value
String to show value according to command
Return Value
Nonexistence
Description
Define the default properties of an object to be drawn through DRAWLINE() etc. The
corresponding command and value are defined as shown below.
Example
188
setdrawobjattr("LS@LT@LC", "2@1@255,0,0");
Reference
DRAWLINE(), DRAWTEXTATTR()
189
4.1.56. SETDRAWTEXTATTR()
Syntax
SETDRAWTEXTATTR(command, value);
Argument
Command
String to define Properties of Text frame
Value
String to show value according to command
Return Value
Nonexistence
Description
Define default properties of Text frame to be drawn through draw text. The corresponding
command and value are defined as shown below.
190
Example
setdrawtextattr("FN@FS@FA", "Arial@20@B");
Reference
DRAWTEXT(), SETDRAWOBJATTR()
191
4.1.57. SETFIXOBJECT()
Syntax
SETFIXOBJECT (varname, flag);
Argument
Varna me
Object variable name. Should be enclosed in .
Flag
Designate Whether a specific Object is overlapped.
0 : Not overlap, Object is moved not to overlap with Table.
1 : the object is fixed . If Table is expanded, the object is overlapped with Table.
Return Value
Nonexistence
Description
AddDataBody() function expands Table as the table data is increasing (repetition).At the
moment, the function designates whether an Object can be overlapped with the Table or not.
This function sets an Object of varname variable name to flag. If Flag is 1, the Object is
overlapped with the Table as the Table is increasing. If it is 0, the Object is moved not to
overlap with the Table.
Example
num i, ret;
i = 1;
a = :a1;
setfixobject(a, 1); /* the location of Object of variable name a is not affected by Table
repetition. */
cursor = "mycursor";
execfile declare :cursor cursor;
declarefield(cursor, 1, 200);
while(1)
ret = execfile fetch :cursor into :aa
if(ret != 1)
AddDataBody("EndAddDataBody"); /* Stop Table repetition*/
192
break;
endif
b = aa;
AddDataBody("b");
i = i+1;
endwhile
Reference
ADDDATABODY()
193
4.1.58. SETGLOBAL()
Syntax
SETGLOBAL(varname, value);
Argument
Varname
string to display global variable name.
Value
data value to set global variable
Return Value
String
value of global variable
Description
Function is setting data value to specific global variable.
In fixed form report, script execute by every record of main data. Each executed script has
independent variables (object, area, temporary variable). In case of you want to reflect
executing specific result value of script to executing script by next record, using global
variable is the only way to forward data. SETGLOBAL() function sets data and
GETGLOBAL() function receives data.
Example
char dname, new_dname;
dname = getglobal(g_dname);
if (new_dname != )
setglobal(g_dname, new_dname);
setglobal(g_ename, name data);
endif
Reference
GETGLOBAL()
194
4.1.59. SETHLDATA()
Syntax
SETHLDATA(varname, target, tooltip, targettype,paramlist, etclist, window);
Argument
Varname
Object variable name for applying Hyperlink Properties
Target
Name of Connection Target
When mouse is located on the object , Connection Target is displayed on status bar.
Tooltip
Help to show when mouse is located on the object
Target type
number to display type of connecting target
0 : RDdocument
1 : web page document
2 : etc. document
3 : E-mail address
4 : current document
5 : executing script. In this case target becomes the script string to execute.
Paramlist
/rp Argument list to be used, in case that Connection target is RD Document. Data
including space should be passed after blocking with [ and ]
Etclist
Etc Argument list in case that Connection target is RD Document.
Window
number shows location of display connecting target
0 : display on the current window
1 : display on the new window
Return Value
Nonexistence
Description
Set Hyperlink information.
You can use this function to define information related to Hyperlink. Set hyperlink and
195
Example
SetHLData(hlink,http://m2soft.co.kr/test/test.mrd,This is Tooltip,
0,1 [Ded poets society], , 1);
/Click * Variable name hlink Object, then
http://m2soft.co.kr/test/test.mrd opens with Argument
- /rp 1 [Ded poets society] */
SetHLWinHTML(hlink, "c:\test\default_myocx.html");
SetHLWinOpt(hlink, 0,0,0,0);
/* when execute hyperlink which is applied new window option, pop up the new window
without menu, toolbar, state bar and make window size can not control as well.*/
SetHLWinPos(hlink, 20, 20);
SetHLWinSize(hlink, 500, 700);
Reference
SETHLWINHTML(), SETHLWINOPT(), SETHLWINPOS(), SETHLWINSIZE()
196
4.1.60. SETHLWINHTML()
Syntax
SETHLWINHTML(varname, htmlpath);
Argument
Varname
name of object variable to apply hyper link new window option
Htmlpath
template HTML document path name to use in connection
use basic template, if do not use this Argument.
Return Value
Nonexistence
Description
Set template HTML document name used by browser in Viewer of PLUGIN, OCX module.
This function can be used only when the Argument value of Displaying connection target
window in SETHLDATA() is set to display on New window (1) only.
Example
Refer to an example of SETHLDATA() function.
Reference
SETHLDATA(), SETHLWINOPT(), SETHLWINPOS(), SETHLWINSIZE()
197
4.1.61. SETHLWINOPT()
Syntax
Void SetHLWinOpt (varname, bMenu, bToolbar, bStatus, bChangeSize);
Argument
Varname
name of object variable to apply hyper link new window option
bMenu
Show Menu (0|1- Hide-0 Show-1
0 : Hide
1 : Show
bToolbar
Show Toolbar(0|1) - Hide-0 Show-1
0 : Hide
1 : Show
bStatus
Show Status bar
0 : Hide
1 : Show
bChangeSize
Resizeable
0 : not allowed
1 : allowed
Return Value
Nonexistence
Description
Assign the yes or no of showing resource of a window, when hyperlink is executed, and
resizing the window.
This function can be used only when the Argument value of Displaying connection target
window in SETHLDATA() is set to display on New window (1) only. This function can be
used within Viewer execution module.
Example
Refer to Example of SETHLDATA() Function
198
Reference
SETHLDATA(), SETHLWINHTML(), SETHLWINPOS(), SETHLWINSIZE()
199
4.1.62. SETHLWINPOS()
Syntax
SETHLWINPOS(varname, left, top);
Argument
Varname
name of object variable to apply hyper link new window option
Left
width location of new window
Top
height location of new window
Return Value
Nonexistence
Description
This function set the width and height of window opened when hyperlink is executed.
This function can be used only when the Argument value of Displaying connection target
window in SETHLDATA() is set to display on New window (1) only. This function can be
used within Viewer execution module.
Example
Refer to example of SETHLDATA() function
Reference
SETHLDATA(), SETHLWINHTML(), SETHLWINOPT(), SETHLWINSIZE()
200
4.1.63. SETHLWINSIZE()
Syntax
SETHLWINSIZE(varname, width, height);
Argument
Varname
name of object variable to apply hyper link new window option
Width
width size of new window
Height
height size of new window
Return Value
Nonexistence
Description
Set size of a window opened when Hyperlink is executed.
This function can be used only when the Argument value of Displaying connection target
window in SETHLDATA() is set to display on New window (1). This function can be used
within Viewer execution module.
Example
Refer to example of SETHLDATA() function.
Reference
SETHLDATA(), SETHLWINHTML(), SETHLWINOPT(), SETHLWINPOS()
201
4.1.64. SETSERIESTITLE()
Syntax
SETSERIESTITLE(chartname, seriesname, title);
Argument
Chartname
variable name of chart object
Seriesname
string to display series name that chart object has. Must be tied by . Anticipate
formatted series in editor. When viewer execute, re-naming sequence at formatted
series such as S0, S1, S2 . The numbers in the above names and index of series
may alter, if series is deleted cause of calling Delete series() function.
Title
string to display the name of showing series
Return Value
Nonexistence
Description
Change title of Series
Example
Refer to example of DEFINESERIES() function.
Reference
SETCHARTTITLE(), DEFINESERIES()
202
4.1.65. SIN()
Syntax
SIN(arg);
Argument
arg
radian type of number or number type variable
Return Value
Number type
sine value of arg
Description
This is a function that calculates sine value of trigonometrically function. Used for the
mathematical statistics or numerical value operation, not for general purposes. The
Argument is formed as radian type.
Example
num ret, PI;
PI = 3.141592;
ret = SIN (PI/2);
ret = SIN (PI/6);
ret = SIN (PI/2 + PI/4);
ret = SIN (PI/3 PI/6);
Reference
COS(), TAN()
203
4.1.66. SORTDATA()
Syntax
SORTDATA(fieldname, order)
Argument
Fieldname
field name of main query
Order
sort order
0 : descending power
1 : ascending sort
Return Value
Number type
0 : failure
1 : success
Description
Data of main query result re-aligning to specify field name and re-forming report.
Can not use in script of fixed form report but can use script function of hyper object only.
There are functions to be used in script of hyper object only such as DRILLDOWN(),
DRILLUP(), SORTDATA() and etc.
Causion)Can not using in case of subpage document and fixed form document.
Example
char name, order, gvar;
num ret;
name = getparam("$2"); /* recieveing variable name which is align by Argument*/
order = getparam("$3");
gvar = getglobal("nextorder");
//messagebox(gvar, "test", OK);
if (gvar == " ascending power ")
order = 1;
else
if(gvar == " descending sort ")
order = 0;
endif;
204
endif;
if (order == 1)
gvar = "descending power";
else
gvar = "ascending sort";
endif;
ret = sortdata(name, order); /* align data by recieved Argument */
if(ret)
setglobal("nextorder", gvar);
endif
Reference
DRILLDOWN(), DRILLUP()
205
4.1.67. SQRT()
Syntax
SQRT(num);
Argument
Num
number or number type variable to calculate a square root.
num is more than or equal to 0.
Return Value
Number type
square root value of num
Description
Calculate a square root of a number. X should not be a negative number.
Example
ret = SQRT (2.4);
ret = SQRT (SUM (a, b, c, 4));
Reference
POW()
206
4.1.68. STRCAT()
Syntax
STRCAT(str1, str2);
Argument
str1
string or string variable which become front of the continued string
str2
string or string variable which become end of the continued string
Return Value
Number type
string that linking strings of two Arguments
Description
Make character string by adding 2 strings. Same function as & expression. When you link
several strings at once, using &expression is much more convenience to use strcat()
function.
Example
ret = STRCAT ("abc", b);
ret = STRCAT ("", "Report Designer");
ret = STRCAT ("M2soft", STRCAT(b, STRCAT(c,"Report Designer")));
Reference
& expression
207
4.1.69. STRCMP()
Syntax
STRCMP(str1, str2);
Argument
str1
the first string to compare
str2
the second string to compare
Return Value
Number type
result value of contrast
0 : both strings are same
> 0 : str1 is more than str2
< 0 : str1 is less than str2
Description
Compare two arguments in dictionary order to check whether they are the same. Only 2
Constant, Variable or operation expressions can be used as Arguments. The result value is
0 when two strings are the same, positive number when argument 1 is greater and negative
number when argument 2 is greater.
Example
ret = STRCMP ("ABC","AB"); // ret > 0
ret = STRCMP ("157","75"); // ret < 0
a = "Report Designer";
b = "Report Designer";
ret = STRCMP (a, b);
208
// ret = 0
4.1.70. STRLEN()
Syntax
STRLEN(str);
Argument
str
string or string variable to get length
Return Value
Number type
length of string
Description
Calculate the length of a string.
Example
ret = STRLEN ("ABCDEFGHIKL"); // ret = 11
ret = STRLEN (298763);
// ret = 6
ret = STRLEN (a);
209
4.1.71. STRRCHR()
Syntax
STRRCHR(str, character);
Argument
Str
string
Character
string to find out from str string
Return Value
Number type
a location where character strings have been found from the end to the front of str string
0 : can not find out string
> 0 : location that has been found
Description
Search from an end to a front of str string and find the same string as character. Result
value is the position of string matched to character. If no string is found, O is the result value.
This function search with the first character even if character consists of one or more letters.
Caution) In Unicode version, get length of string by number of character, in general version
get length of string by number of string bite. It means even the same string can get different
length by Unicode version or not.
Example
ret = STRRCHR ("ABCABCABC","A");
ret = STRRCHR ("ABCDEF","H");
Reference
STRSTR()
210
// ret == 7
// ret == 0
4.1.72. STRSTR()
Syntax
STRSTR(str1, str2);
Argument
str1
string
str2
string to find out from string str1
Return Value
Number type
the first location to be displayed same string from both str1 and str2
0 : can not find out string
> 0 : place that find out
Description
Find a string matched to str2 from str1 while searching from the end of str1 to the beginning
Result value is, if str2 is included in str1 then the first position of containing str2 in str1 and if
str2 is not included in string.
Caution) In Unicode version, get length of string by number of character, In general version
get length of string by number of string bite. It means even the same string can get different
length by Unicode version or not.
Example
ret = STRSTR ("korea seoul", "seoul"); // ret == 6
ret = STRSTR ("ABCDEFG","CD");
// ret == 3
Reference
MATCH(), STRRCHR()
211
4.1.73. SUBSTR()
Syntax
SUBSTR(str, pos, num);
Argument
Str
string or string variable to extract specific string
Pos
number to display places from original string
start from 1
Num
number of extract string length
Return Value
String
extract string specific section from str
Description
Extract string from start position (start from 1) to the position corresponded to the number
inputted from Argument
Caution)The value of location to find out strsub on varname string. It will be different between
Unicode version and general version. In case of Unicode version location and length of
characters relate with number of character but In general case relate with number of bite. In
case of a character by a character, the length is 1 in Unicode version but It is 2 in general
version.
Example
ret = substr("BlueSky",5,3)
//result value: ret == "Sky"
Reference
STRSTR(), STRRCHR()
212
4.1.74. SUM()
Syntax
SUM(arglist);
Argument
arglist
argument list to sum
a1, a2, a3 : 3 variable as a1, a2, a3
a1..a10 : 10 variable between a1 ~ a10
Return Value
Number type
sum value of argument list variable
Description
Calculate the sum of the argument list.
Example
ret = SUM (1,2,3,4,5,6,7,8,9);
ret = SUM (a, b, c);
ret = SUM (a + b, 36/5 - 1, c * d);
ret = SUM (a$, b?);
ret = SUM (a1..a10);
Reference
AVG(), MAX(), MIN()
213
4.1.75. TAN()
Syntax
TAN(arg)
Argument
arg
radian style numeric or numeric variable
Description
This is a function that calculates tangent value of trigonometrically function.
Example
num ret, PI;
PI = 3.141592;
ret = TAN (PI/2);
ret = TAN (PI/6);
ret = TAN (PI/a + PI/4);
ret = TAN (PI/3 PI/b);
Reference
SIN(), COS()
214
4.1.76. TEXTREAD()
Syntax
TEXTREAD(filename, varname, mode);
Argument
Filename
path of text file
size of file is less than or equal to 60K
Varname
variable to save read data
Mode
mode to read file
r : Open to read only.
t : Read file as text type.
b : Read file as binary type.
Return Value
Nonexistence
Description
Read Text file as specification variable.
TEXTREAD() function can read as text frame or table that accepts text inputs. The file to
read should be a text file with size of 60K or less. To save the contents of text document in
the object as file, use TEXTWRITE() function
Example
char
var;
Reference
TEXTWRITE( )
215
4.1.77. TEXTWRITE ()
Syntax
TEXTWRITE (filename, varname, mode);
Argument
Filename
path of text file
size of file is less than or equal to 60K
Varname
variable which has text data to save into file
Mode
mode to read file
w, w+ : Open file for writing
a, a+ : Open file to append to file EOF position or create new file when there is no file
exist.
t : Write file as text status..
b : Write file as binary. Status,
Return Value
Number type
Description
Write text document content within object to file.
TEXTWRITE() saves the document at the specified object as text document. To read the
document again, use the internal function of a script, TextRead().
Example
TEXTWRITE("file2.txt", var, "w+t");
/* The contents of Text frame(or Table) object variable var will be saved as text file named
file2.txt*/
Reference
TEXTREAD()
216
4.1.78. TIME()
Syntax
TIME(timevalue, kind);
Argument
Timevalue
value of time
Kind
Kind of value to return
HOUR : Hour(24hour base)
MINUTE : Minute
SECOND : Second
Return Value
Number type
A kind of return value is changed according to the kind.
Description
Extract wanted unit value(hour, minute or second) from time value.
Example
Current time = time(currenttime(), HOUR);
// It is 12, If the current time is 12:35:24.
Reference
CURRENTDATE(), CURRENTTIME(), DATE()
217
4.1.79. TOLOWER()
Syntax
TOLOWER(str);
Argument
str
string
Return Value
String
Convert capital letter into small letter in str Argument.
Description
Convert capital letter into small letter in str Argument.
Example
CHAR str;
str="ABCEDRG";
OBJ=TOLOWER (str);
Reference
TOUPPER()
218
4.1.80. TOUPPER()
Syntax
TOUPPER(str);
Argument
str
string
Return Value
String
String in which all the small letters are converted into capital letters within str
Description
Convert all the small letters into capital letters within str Argument
Example
CHAR str;
str="abcdefg";
OBJ=TOUPPER (str);
Reference
TOLOWER()
2.2.1 Types of variable
219
4.1.81. TRUNC()
Syntax
TRUNC(num [,pos]);
Argument
Num
number or type of number variable to truncate
Pos
number display places to truncate (-9 ~ 9). Can be omitted.
-1 : truncate at below 10 decimal places
0 : truncate at below decimal places
1 : truncate at below 1 decimal places
Return Value
Number type
Result of the truncated num number at specify places
Description
Truncate the num Argument value under specified decimal places. Decimal places are valid
from -9 to 9 and can be omitted.
Example
NUM i, ret;
i = 765.267;
ret = TRUNC (i);
Reference
ROUND()
220
4.1.82. UPDATEEOR()
Syntax
UPDATEEOR();
Argument
Nonexistence
Return Value
Nonexistence
Description
You can use when the script need to use on document (general document, table document,
label document) which is not fixed form. After UPDATESUBVALUES() which is function of
saving subpage field definition data, have to mark the end of subpage data to separate
between each subpage data. In this case, use UPDATEEOR() function.
Refer to Description of updatevalues( ) function.
Example
Refer to example updatevalues( ) function.
Reference
UPDATEVALUES(), UPDATESUBVALUES()
221
4.1.83. UPDATESUBVALUES()
Syntax
UPDATESUBVALUES(subpageno);
Argument
subpageno
Number of subpage
Return Value
Nonexistence
Description
You can use when the script need to use on document (general document, table document,
label document) which is not fixed form. This function saves field definition data of subpage
and can use with UPDATEVALUES() function which saves data of base field definition. Refer
to Description of updatevalues( ) function.
Example
Refer to an example of updatevalues( ) function.
Reference
UPDATEVALUES()
222
4.1.84. UPDATEVALUES()
Syntax
UPDATEVALUES();
Argument
Nonexistence
Return Value
Nonexistence
Description
Function to use script in a document (general form, table, and label) that is not a fixed form
report.
In a document that is not a fixed form report, you may have difficulties in getting data from a
database with only one query. In such a case, you can easily get data necessary in the
document, using script at the same time. In a script, you can use several query paragraphs,
and easily modify data.
Differently from a fixed form document, in a general form document, a table document and a
label document, only a specific document type is necessary. Accordingly, a Field
Definition of a record is necessary as in a Connect File.
If UPDATEVALUES() is executed during script execution, a record is created using the
corresponding values of field name defined in the Field Definition. Using this function has
small disadvantage in that it is slow getting the result. It is because that a form is created
after all the records are created, i.e. after the completion of script execution.
Example
num ret;
cursor = mycursor;
query = select korean, english, math from courses;
/* Student is defined field name by base field definition on database field definition menu */
student = Gil-dong Hong;
updatevalues();
execsql declare :cursor cursor for :query;
/*a recode is formatting by every execution of statement in white. */
while(1)
/* Create one record with variable values of Korean, English, and Mathematics */
223
Reference
UPDATEVALUES(), UPDATESUBVALUES()
224