Você está na página 1de 144

Appendix .

Report Designer Script

About Report Designer Script

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.

Characteristics of a Script Program

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

Appendix . Report Designer Script

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.)

1.1. Basic Information on Script

1.1.1. Characteristics of Fixed Form Document in Report Designer


Text contents and programs made in Report Designer exist in one file. You create a
document using the editing functions of Report Designer Editor. Then you can apply scripts
to the created document to complete the programming.
Script will be execute each time a query from the Define Query reads in one result
set(Record) from the database.
With the Script, you can make a different Query and request the data from the database, and
display those data after editing.
Script execute once if the main query is not created in Define Query
As Description above, normally in case of connecting database use the script used
document also can be used in file connection document. But, in case of File connection, it
could be used in a fixed form report only.

1.1.2. Object and Object Variable


Object
Object means a unit which has data related to a function. All of items to be expressed in
Report Designer are either an object or a part of an object.

82

Appendix . Report Designer Script

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.

Rule for naming an Object Variable


When you assign a name for the object variable, you should keep in mind the fact that
duplicate object name is not allowed in one file and that you cant place a number as
the first character of the variable name.
Also, words (Reserved word) predefined in the script cannot be used.
Rules for naming an object variable are as follows.

83

Appendix . Report Designer Script

T Exceptions to naming an object are as follows.

Assigning a name to the cell in a table and the object


In a table, you can assign variable names with sequential numbers to several cells inside a
table in batch. This option is closely related to the table characteristics that the table is
frequently used to display the repeated records, and that the cells in a table can be regularly
added.
TypeS of assigning variables in cells of a table are as follows.

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

Appendix . Report Designer Script

(1)Vertical Selection (2)Diagonal Selection (3)Random Selection


In the above example, in the case of assigning object variable name on multi columns, it
assigns object variable name which has sequence number beginning at the top left column
within blocked columns set. The order is from left to right and top to bottom.
I (1) Example, If you input a10 in the variable field of the script dialog box , serial numbers
will be 10, 11, 12 starting from the top cell. The first cell will be given a10, the second cell
a11, and the third cell a12.

85

Appendix . Report Designer Script

1.1.3. Object and Script


A user can assign a variable name to all objects in Report Designer and describe one script
per each file. And, the objects with a variable type can have a value, but the objects without
a variable type cant have a value.

Object with a variable type (Object being capable of having a value)


The objects of Text frame or Table cells can be used effectively to make a script program.

[Objects in close relation to a script]

86

Appendix . Report Designer Script

Object without a variable type (Object with the value)


Objects not being able to have variable types cannot input or output the data by using a
script.

1.1.4. Executing Report Designer Script


In case of a Fixed Form Report, the time when a script is executed

87

Appendix . Report Designer Script

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.

1.2. Script Description Procedure


Script description procedure will be as follows.
1. By selecting Database-Edit Script or pressing the button in the toolbar, open the Edit
Script Dialog box.
2. After selecting the object to describe the script, input the variable name in the
Variable Name field, and assign the variable type.

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.

1.2.2. Script Editing


For users convenience, Script Editing functions such as Block unit Copy (<Ctrl+Ins>,
<Ctrl+C>), Cut (<Ctrl+Del>, <Ctrl+X>), Paste (<Shift+Ins>, < Ctrl+V>), and Find/Replace
String(<Ctrl+F>) are provided.
Find/Replace String can be used to find a location of a character string or replace it with
other character string.

88

Appendix . Report Designer Script

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.

1.2.3. Checking Script Syntax


Report Designer interprets scripts described in the Script Input dialog box.
Script creation and Syntax checking is made on Report Designer Editor, and on Report
Designer Viewer the described script will be interpreted and according to a result of
interpretation, the script will be executed.
Assuming that Script Input dialog box opened, and the object with the script described is
selected, the time when this script is interpreted in Report Designer is as shown below.

In case of pressing OK or Verify button in the Script dialog box

In case of pressing Close button in the Script dialog box

In case of opening the document which includes the script in Report Designer

89

Appendix . Report Designer Script

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

Appendix . Report Designer Script

2. Script Syntax

2.1. Constant
Character, Number, Data and Time etc. are the constants which can be used in a script.

2.1.1. String constant


String Constants are expressed as characters other than Null Constant (Null Character: "")
and any characters except control characters can be used.

String constants must be enclosed within Quotation marks ( " )

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.

2.1.2. Number Constant

Number constant is expressed by an integer or a real number

A negative number and number below decimal point can be expressed.

The maximum significant digit of a number constant is 15


Example) 123, 123.0, -123, 16.98

91

Appendix . Report Designer Script

2.1.3. Date Constant


Date Constant is expressed inside a Quotation Marks ( ) with the delimiter, '/' like
YYYY/MM/DD, YY/MM/DD or MM/DD. The default year in the system clock is assumed
for the following format: MM/DD
Example) "1994/01/20", "94/2/5". "9/1"

In Report Designer Script, a record can be made of Date Constant from the year 1900.

2.1.4. Time Constant


Time Constant is expressed inside a Quotation marks ( ) with the delimiter, ':' like
HH:MM:SS or HH:MM. And 24 hour expression is used.
Example) "12:00", "3:53:29", "17:23"

92

Appendix . Report Designer Script

2.2. Variable

2.2.1. Kinds of Variables


The maximum length of a variable is 20 characters for English, and in Korean, 10 characters.
The variable should start with a character or ' _ '. Small letter and Capital letter are not
distinguished in the variable name. And the variable can be divided into 3 types based on
types.

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

2.2.2. Variable Type


Variable Type is the type of record kept in the variable. According to the variable type
(Variable type: String, Number, Date, Time), the variable can be divided into 4 types.
Date variable keeps the record of date from the year 1900 as a Julian Date value.
Time variable keeps the time record as the time value.

When you convert the type of a variable with a different variable type, the first priority is
given to the string variable.

2.2.3. Using Variable in Script


To use the variable in the script, you can use the variables explained in the above, and also
you can use it more effectively by using a Meta Character such as?, $, [] (Array variable), ..,
#. The benefits of Meta Characters are that you can express the number of variables at
once.
? is a meta character corresponding to one character. For example, if you express a?, it
indicates all of the variables, which have only one character after a, among variables starting
from a.
$ is a meta character corresponding to 0 or more characters. For example, if you express a$,
it indicates all of the variables, which start from a, including a.
Example) Script using ? and $
a? = 10;
s = SUM (a$);
If a variable name ends with 1 or more, it is regarded as an array variable. For example, all
of a1, a2, a3, a10 are array variables with a name including a.
Array variables can be declared to each of objects one by one and can be declared to table
cells at once after selecting them. At this time, even if the variable types are different, it
doesnt matter.
If a declaration is made as an array variable, you can describe a script by using Meta
character such as ... .. indicates all of array variables between the first array variable
and the last array variable. For example, as for m = avg(a1..a10), the average of all array
variables with a digit among 1 ~ 10 in the array variables, which start from a, will be saved
into m.

95

Appendix . Report Designer Script

2.3. Arithmetic Expression


Arithmetic Expression is an expression showed by arithmetic operators, and the following
symbols can be used for it.

+ Plus or Positive mark

Minus or Negative mark

* Multiply

/ Divide

Residual except for a quotient gotten from a front value divided by a rear value

In an arithmetic expression, Constant, Variable, Logical Expression, Relational


Expression and Internal Function can be used for an operand and the result value is
a number.

Example
a = 2 + 3 * 5;
b = (a - b) / 2 + (a + b) * 2;
Net Income = SUM (Sales$) - SUM(Cost$);

96

Appendix . Report Designer Script

2.4. Relational Expression


Relational Expression is an expression showed by relational operators, and the following
operators can be used. Relational operator can be used to compare operands quantitatively.

<=
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.

Dictionary style comparison means to compare by the order of words listed in a


dictionary.

97

Appendix . Report Designer Script

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

Appendix . Report Designer Script

2.5. Logical Expression


A logical expression is an expression using logical operator. The following symbols can be
used.

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

Appendix . Report Designer Script

2.6. String Expression

&
This connects one string to the other string. As for a function, it plays the same part as
strcat()function.

2.7. Compound Expression


The operands in a compound expression can be expressions (arithmetic expression,
relational expression or logical expression). Expression can be placed all of the
arithmetic operators, logical operators and relational operators.

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);

2.8. Priority in Operators


Operators are ( ), !, +(positive number mark), -(negative number mark), *, /, %, +, -, > , >=, <,
<=, ==, != , AND, &&, OR, and || , etc.
Among the operators, the precedence is described in the following table. The operators in
the same row will be operated by the order written without priorities..
Priority in operators is as follows.

100

Appendix . Report Designer Script

2.9. Type Conversion Rule


Type conversion rules for constants or variables in scripts are as follows.

2.9.1. Type Conversion of Constants or Variables in Operational


Expressions and Internal Functions
In general, the variables or constants used as arguments of operational expression or
Arguments of internal functions should have appropriate types according to the types of
operators or internal functions. When they are not in appropriate types, they will be
processed with automatic type conversion.
Type conversion rules of constants or variables in operational expressions and internal
function are as follows.

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

Appendix . Report Designer Script

Inaccurate Type Conversion, will be displayed. You have to manually change the
variable types appropriately.

2.9.2. Type Conversion of Constants or Variables in Substitution


Paragraphs
A substitution paragraph is a statement that substitutes a variable on the left side of the
expression with the operational result of the right side. A substitution paragraph can be
expressed as "Variable = Operational expression | Built-in function;".
When the result of operational expression or internal function on the right side is not
applicable to the variable types of the left side variable, an automatic type conversion will
be executed based on the variable type of left side

102

Appendix . Report Designer Script

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.

3.1. Local Variable Declaration


A local variable is a variable used within a script only. In the local variable declaration
statement, its types are CHAR, DATE, NUM, and TIME.

3.1.1. CHAR Statement


Syntax
CHAR Variables List;

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

Appendix . Report Designer Script

3.1.2. DATE Statement


Syntax
DATE Variables List;

Description
Declare local variable with Date variable type. Can declare array variable as well.

Example
DATE today;
DATE days[10];

104

Appendix . Report Designer Script

3.1.3. NUM Statement


Syntax
NUM Variables List;

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

Appendix . Report Designer Script

3.1.4. TIME Statement


Syntax
TIME Variables List;

Description
Declare local variable with time variable type. Can declare array variable as well.

Example
TIME now;
TIME event[10];

106

Appendix . Report Designer Script

3.2. Substitution Statement


A Substitution Statement is a command to substitute a variable with a result of an
operation. You can give values to all objects that can have values with them. For example,
if there is a text frame object, which has a variable name text frame 1 with a Character
variable type. And if a script, text frame 1 = Good morning has been executed, then Good
morning will be inputted in a text frame.

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

Appendix . Report Designer Script

3.3. Control Statement


A Control Statement is a command to execute or stop statement according to a condition.
In the control statement, there are BREAK, CONTINUE, IF-ENDIF, FOR-ENDFOR, RETURN,
CALL, SWITCH-ENDSWITCH, and WHILE ENDWHILE statements.

3.3.1. BREAK Statement


Syntax
BREAK;

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

Appendix . Report Designer Script

3.3.2. CONTINUE Statement


Syntax
CONTINUE;

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

Appendix . Report Designer Script

3.3.3. IF-ENDIF Statement


Syntax
IF (Conditional Paragraph) sentence 1 [ELSE sentence 2]
ENDIF [;]
Description
If the conditional statement is true then execute sentence 1, if it is false then execute
sentence 2.
A logical expression or relational expression can be used in a conditional statement.
You can nest If statement at sentence 2. In this case, if the result of the first IF function is
false, then look for the result of the second IF function. There should be the same number of
ENDIF statements as IF statements.

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

Appendix . Report Designer Script

3.3.4. FOR-ENDFOR Statement


Syntax
FOR ([ execution statement]; [Conditional statement]; [execution statement])
Sentence
ENDFOR [;]
Description
While conditional paragraph is true, it executes statement inside FOR statement iteratively.
Logical expression or Relational expression can be used at Conditional statement, and it can
be omitted.
The former execution clause and the latter execution clause are the conditions determining
the number of repeats for FOR Statement.
Substitution statement, control statement and local variable declaration, etc can be placed in the first
execution paragraph or the second execution paragraph.

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

Appendix . Report Designer Script

3.3.5. SWITCH-ENDSWITCH Statement


Syntax
SWITCH (operation expression)
CASE Constant:
Sentence;
[CASE Constant:
Sentence;]
[default:
Sentence;]
ENDSWITCH [;]
Description
Execute the sentence of relevant CASE paragraph when the value of operation expression is
the same as constant of CASE. The IF statement selectively executes one of two
commands according to a given condition, whereas SWITCH statement selects execution of
one among many commands according to the values of operation expression.

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

Appendix . Report Designer Script

3.3.6. WHILE-ENDWHILE Statement


Syntax
WHILE (Conditional Paragraph)
Sentence
ENDWHILE [;]
Description
Execute sentence iteratively while the result of conditional paragraph is true. Logical
expression or relational expression can be used in conditional paragraph.

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

Appendix . Report Designer Script

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. Types of Functions


The internal function of Report Designer Script, object related function, digital related
function, word related function. Date/time related function, database related function, Draw
object and properties related function are offered. Those functions are used a report to be
drawn by developers design as it is possible to edit and calculate atypical data with much
easier process.

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

AddDataBody("b");
endif
i = i+1;
endwhile
execfile close :cursor;

116

/* Expand the table with b object */

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

[Kinds and values of execution codes]

Example
changeattr (a, "FN", "Gulim");
changeattr (a, "BC", "256,256,0");
changeattr (a, "FA@FS", "B@15");

Reference
CHANGEROWATTR()

121

Appendix . Report Designer Script

122

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

[Type and value of execution value]

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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();

// ctimeis a TIME type variable

Reference
CURRENTDATE(), DATE(), TIME()

130

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

execfile declare :cursor cursor;


declareeor(_EOR_) ;

// Cursor definition

declarefield(cursor, 1, 30); // character Add a character type 30 bite length column


declarefield(cursor, 1, 30); // character Add a character type 30 bite length column
declarefield(cursor, 1, 30); // character Add a character type 30 bite length column
while(1)
// Because 3 columns declared
ret = execfile fetch :cursor into :fff, :ggg, :hhh;
if(ret != 1) // return 0 when meeting end of record
AddDataBody("EndAddDataBody");
Break;
endif
AddDataBody("fff");
xxx = :a2;
yyy = :a3;
endwhile
// Close a cursor at the end..
execfile close :cursor;

Reference
EXECFILE

134

Appendix . Report Designer Script

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

Appendix . Report Designer Script

for(i=0; i<5; i=i+1)


ret = execsql fetch :cursor into :tcname, :tpname, :tpunitprice, :tpstock;
if (ret != 1)
break;
endif
drawchart("mychart"); // mychart draw object.
endfor
execsql close :cursor;

Reference
DEFINESERIES(), DRAWSERIES(), SETSERIESTITLE()

136

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

drawline(x1, y1, x2, y2, "LS@LT@LC", "2@1@255,0,0");


// draw 4 inches red dotted row line on the top of report.

148

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

y2 = 1500;
drawtext(x1, y1, x2, y2, "TEST STRING", "FN@FS", "Tahoma@20");
// draw 4inches text frame on top of the report.

151

Appendix . Report Designer Script

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

Appendix . Report Designer Script

Example
drilldown("ordserstatistics.mrd", "/rp [Less than 10] /rdrillright ");

Reference
DRILLUP()

153

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

ret = format(timeval, hh:mm:ss, 1)


// Time Format data timeval is at noon, return value: ret = 12:00:00

Reference

162

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

/* The value of s1 is the character string corresponding to $1*/

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

EXAMPLE.DLL prepared using C

The example DLL is compiled in Microsoft Visual C++ 5.0.


/* ---------------------------------------------------------* Report Designer Example DLL *
* FILE : Example.C *
* Author : M2Soft *
* Date : 1998.05.01. by T.H. Kim *
* Compiler : Microsoft Visual C++ 5.0 *
---------------------------------------------------------- */
#include <windows.h>
#define DllExport __declspec( dllexport )
/* ---------------------------------------------------------* << Script >> << Example.c >>
* hello(str, num) --->
_M_HELLO(int argc, char *argv [])
*
~~~ ~~~ argc == 2;
* argv [0] --> "rdviewer.exe"
* argv [1] --> str
* argv [2] --> num
---------------------------------------------------------- */
DllExport double _M_HELLO (int argc, char *argv [])
{
static int count = 0;
double dret;
double *pNum;
if (argc != 3)
dret = -1;
else
{
strcpy(argv [1], "Hello World!");
pNum = (double *)argv [2];
*pNum = (double)count++;
dret = 0;
}
return dret;
}

Example.def

167

Appendix . Report Designer Script

;/* --------------------------------------------------------;* Report Designer Example DLL


;* FILE : Example.C
;* Author : M2Soft(Millenium Master)
;* Date : 1998.05.01. by T.H. Kim
;* Compiler : Microsoft Visual C++ 5.0
;--------------------------------------------------------- */
LIBRARY Example
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
_M_HELLO

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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);

// the result of ret is 765

(round at below decimal places)

ret = ROUND (i, 0); // the result of ret is 765

(round at below decimal places)

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

(round at below 10 decimal places)

Reference
TRUNC()

183

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

setdrawobjattr("LS@LT@LC", "2@1@255,0,0");

Reference
DRAWLINE(), DRAWTEXTATTR()

189

Appendix . Report Designer Script

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

Appendix . Report Designer Script

Example
setdrawtextattr("FN@FS@FA", "Arial@20@B");

Reference
DRAWTEXT(), SETDRAWOBJATTR()

191

Appendix . Report Designer Script

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

Appendix . Report Designer Script

break;
endif
b = aa;
AddDataBody("b");
i = i+1;
endwhile

/* add repeatation which include b object */

execfile close :cursor;

Reference
ADDDATABODY()

193

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

information related to Hyperlink on the TextFrame or column in Table.


In case the value is the field name, target, tooltip, paramlist, etclist are mapping by value
from DB and become final value.

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

Reference
SETHLDATA(), SETHLWINHTML(), SETHLWINPOS(), SETHLWINSIZE()

199

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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;

TextRead ("file1.txt", var, "rt");


/* Text File Read file1.txt as text status and save it in a character type variable var. That is,
Read file1.txt file in var text frame object shown in the following picture */

Reference
TEXTWRITE( )

215

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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;

// Declare character type local variable, str

str="ABCEDRG";
OBJ=TOLOWER (str);

Reference
TOUPPER()

218

Appendix . Report Designer Script

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;

// Declare character type local variable, str

str="abcdefg";
OBJ=TOUPPER (str);

Reference
TOLOWER()
2.2.1 Types of variable

219

Appendix . Report Designer Script

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);

// Value of ret is 765

(truncate at below decimal places)

ret = TRUNC (i, 0);

// Value of ret is 765

(truncate at below decimal places)

ret = TRUNC (i, 2);

// Value of ret is 765.26 (truncate at below 2 decimal places)

ret = TRUNC (i,-1); // Value of ret is 760

Reference
ROUND()

220

(truncate at below 10 decimal places)

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

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

Appendix . Report Designer Script

ret = execsql fetch :cursor into : Korean, :English, :Mathematics;


if (ret_m != 1)
break;
endif
/* Create one record with variable values of Korean, English, and Mathematics. */
updatesubvalues(1);
endwhile
updateeor();
execsql close :cursor;

Reference
UPDATEVALUES(), UPDATESUBVALUES()

224

Você também pode gostar