ComWin 300 Programmers Reference
ComWin 300 Programmers Reference
HiPath 4000
ComWin 300
Programmers Guide / Reference
Guide
*1PP30357-B9800-B10-101 EN*
1P P30357-B9800-B10-101 EN
The information in this document contains only general descriptions or general fea-
tures, which may not be available as described for actual application and/or which can
change due to further product development.
The desired features are therefore only binding if formally specified at the closing of
the contract.
This device has been manufactured in accordance with our certified envi-
ronmental management system (ISO 14001). This process ensures that en-
ergy consumption and the use of primary raw materials are kept to a mini-
mum, thus reducing waste production.
Siemens AG 2002 ● Information and Communication Networks, Hofmannstraße 51, D-81359 München, Germany
Reference No.: P30357-B9800-B10-101 EN
Printed in the Federal Republic of Germany.
Subject to availability. Right of modification reserved.
HiPath is a trademark of Siemens AG that is registered in several jurisdictions.
cbl-phb.bk Page 1 Monday, March 22, 2004 10:24 AM
oi_TOC.fm
Content 0
oi_TOC.fm
2.1.38 quotstring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.1.39 comment (structured) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.1.40 comment (single line) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.2 Summary of keywords. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.3 Advanced topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.3.1 Working with arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.3.2 Working with reference variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
2.3.3 Using the OLE interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
2.3.4 Using the DLL interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3 CBL - Programmer’s Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.1 Interface to the Interpreter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.1.1 Command line parameters: Args . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.1.2 Interpreter functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.2 General functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.2.1 cbl_sysfunc_ (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.2.2 cbl_chain (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
3.2.3 cblFile (ole_class). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
3.2.4 cblIniFile (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.2.5 cblZipFile (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
3.2.6 cbl_dialogs (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
3.2.7 cblXmlFile (ole_class). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
3.3 Interfaces to the ComWin-Frame components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.3.1 Comedit (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.3.2 ComwinControl (ole_class). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
3.3.3 ComwinFrame (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
3.3.4 ComwinCBL (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
3.3.5 ComWinFT (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
3.3.6 ComWinPPP (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
3.3.7 ComWinAccessServer (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
3.3.8 ComWinAccessSession (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
3.3.9 ComWinAccessFileman (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
3.3.10 ComWinAccessDatabase (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
3.3.11 ComWinAccessQuery (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
3.3.12 ComWinFM (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
3.4 Designing forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
3.4.1 Form Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
3.4.2 The form class cblForm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
3.4.3 Form controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
3.4.4 Definition of menus. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
3.4.5 Form examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
3.4.6 Modal dialog example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
3.5 CBL - National Language Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
3.5.1 CBL-intrinsic text tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
3.5.2 NLS texts from H.O.T. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
oi_TOC.fm
oi_TOC.fm
3.1.21 for_stmt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.1.22 while_stmt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.1.23 do_while_stmt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.1.24 try_catch_stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.1.25 throw_stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.1.26 with_stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.1.27 return_stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.1.28 break_stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.1.29 .try_catch_stmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.1.30 block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.1.31 expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.1.32 binop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.1.33 type_identifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.1.34 identifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.1.35 alpha. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.1.36 digit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.1.37 number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.1.38 hex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.1.39 quotstring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.1.40 comment (structured) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.1.41 comment (single line) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.2 Summary of keywords. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.3 Advanced topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.3.1 Working with arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.3.2 Working with reference variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.3.3 Using the OLE interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.3.4 Using the DLL interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.3.5 Working with the SOAP Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.3.6 Import of XSD Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
3.3.7 Import of ASN.1-Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4 CBL - Programmer’s Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.1 Interface to the Interpreter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.1.1 Command line parameters: Args . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.1.2 Interpreter functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.2 General functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4.2.1 cbl_sysfunc_ (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4.2.2 cbl_chain (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
4.2.3 cblFile (ole_class). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
4.2.4 cblIniFile (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
4.2.5 cblZipFile (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
4.2.6 cbl_dialogs (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
4.2.7 cblXmlFile (ole_class). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
4.3 Interfaces to the HiPath 4000 Expert AccessFrame components. . . . . . . . . . . . . . . . . 96
4.3.1 Comedit (ole_class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
oi_TOC.fm
oi_TOC.fm
cbl-phb.fm
HiPath 4000 Expert Access Architecture
ComWin.Frame html/class
files
ComWin. ComWin.
MMLEdit Connect
ComWin.
CBL
Interpreter PBX
pdb cbl
files files
The HiPath 4000 Expert Access architecture is characterized by several program components
which communicate via the OLE automation interface. This interface makes it possible to exe-
cute a procedure or access a property contained in another program. The other program must
offer this procedure or property.
The main components of the HiPath 4000 Expert Access Framework are:
● HiPath 4000 Expert Access - CBL Interpreter: An interpreter and debugger for the new
programming language "CBL" as an alternative to the MACRO language of PC-
Comtes.
● HiPath 4000 Expert Access - Connect: The program controlling and keeping connec-
tions to one or more switches. Complete (and of course enhanced) functionality of PC-
Comtes
● HiPath 4000 Expert Access - MML Editor: The MML command editor. ("Comedit-Win-
dow of PC-Comtes")
cbl-phb.fm
● HiPath 4000 Expert Access - Frame: A frame application which can be seen as HiPath
4000 Expert Access-entry point for applications which want use HiPath 4000 Expert
Access as Server (via OLE or HTTP-interface).
● HiPath 4000 Expert Access - FileTransfer: An OLE server application with which files
can be transported using various protocols.
● HiPath 4000 Expert Access - GuiBuilder: The prototype of a tool to support the crea-
tion of CBL programs, see "Designing forms" on page 146.
The CBL intrinsic OLE interface can be used to contact 3rd Party or owner written programs as
well (e. g. Microsoft Word, Excel, Netscape Navigator).
The HTTP-Server which is part of the CBL frame is not in the focus of this document. It offers
the opportunity to communicate between Java applets and CBL programs.
Focus for this document is the description of the CBL language, the description of the interfaces
and the usage of the CBL Interpreter/Debugger.
cbl-phb.fm
Latest Enhancements
Integration of the SOAP Interface
2 Latest Enhancements
cbl-phb.fm
3.1.1 program
statement
A CBL program consists of one or more statements. However, there is also the possibility that
the program is empty without any statement.
cbl-phb.fm
The CBL Language
Syntax description
3.1.2 statement
include_stmt
function_stmt
declaration_stmt
class_stmt
if_stmt
for_stmt
while_stmt
do_while_stmt
with_stmt
return_stmt
break_stmt
assign_stmt
call_stmt
syn_stmt
text_table_stmt
signature_stmt
empty_stmt
.try_catch_stmt
throw_stmt
cbl-phb.fm
include_stmt
import_stmt
function_stmt
declaration_stmt
class_stmt
if_stmt
for_stmt
while_stmt
do_while_stmt
with_stmt
return_stmt
break_stmt
assign_stmt
call_stmt
syn_stmt
enum_stmt
set_stmt
text_table_stmt
signature_stmt
try_catch_stmt
throw_stmt
empty_stmt
cbl-phb.fm
The CBL Language
Syntax description
3.1.3 assign_stmt
(assign statement)
expression expression ;
=
+=
-=
*=
/=
%=
++
--
This is the general form of an assignment. The first expression denotes a memory location, e.
g. may be the name of a variable. The second expression may be as simple as a single literal,
or as complex as required. Please see "Operator =" on page 43 for implicit type conversion.
Example:
x = 10;
str.f = x + 13;
The operator += increments the left expression by the value of the right expression.
Operator -= subtracts the value of the right expression from the left expression and stores it at
the variable defined by the left expression.
The operators *= (multiplication and assignment), /= (division and assignment) and %= (mo-
dulo operation and assignment) work equivalent.
The operator ++ increments the value of the left expression (must be a variable) by 1. The ope-
rator -- decrements the value of the left expression.
If += is used for string expressions the right string is concatenated to the left string variable.
cbl-phb.fm
Example:
i++;
z--;
string s="Hello ";
s+="world ";
k+=5;
3.1.4 call_stmt
(function call command)
expression ( ) ;
expression
Defines the syntax of a function call, where the result is ignored or the result type is defined as
void. For information about type compatibility of parameters see the description of
function_stmt.
Example:
triangle(a, b, c);
set_length(l);
3.1.5 syn_stmt
(syn statement)
quotstring
number
quotstring [ quotstring ]
Using the keyword syn you can define an alias name for an identifier, e. g. a class name.
cbl-phb.fm
The CBL Language
Syntax description
Example:
syn CForm = cblForm;
syn maxCnt = 4;
syn hello = "Hello World!";
After this declaration the identifier CForm can be used equivalent to the identifier cblForm. Due
to readability considerations of programs this statement should be used very restrictively!
The last syntax has been introduced especially for access of NLS-Texts for project H.O.T. where
the first quotstring specifies the catalogue to be opened, the quotstring in brackets is the key of
the text to be fetched from this catalogue.
Example:
syn Catalog = "messages.txt";
syn msg1 = Catalog [ "MSG1" ];
In the example msg1 is a synonym for the quotstring which has been retrieved from the cata-
logue messages.txt with key "MSG1" by the H.O.T.-OLE-Component HOT.NLS.1.
3.1.6 enum_stmt
(enum statement)
enum { identifier }
;
= number
Using the keyword enum you can define the enumeration of constants. The numeric values are
automatically incremented starting at 0. Alternatively, a specific value can also be set.
Example:
enum { mtWarning, mtError, mtInformation, mtConfirmation, mtCustom };
enum { FTProto_RmxScsi=1,
FTProto_FTP=3,
cbl-phb.fm
FTProto_FJAM=4,
FTProto_DispaList=6 };
3.1.7 set_stmt
(set statement)
set { identifier }
;
Using the keyword set you can define the enumeration of constants. The numeric values are
automatically doubled starting at 1. The first identifier is assigned the value 1, the second the
value 2, the third the value 4, the fourth the value 8, etc.
Example:
set { mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, mbIgnore,
mbAll, mbNoToAll, mbYesToAll, mbHelp };
3.1.8 text_table_stmt
(text_table statement)
text_table { quotstring }
{ quotstring : { quotstring } } ;
cbl-phb.fm
The CBL Language
Syntax description
Text tables can be used to implement language independent CBL applications (see "CBL - Na-
tional Language Support" on page 174 for further details).
3.1.9 signature_stmt
(signature statement)
signature quotstring
Signatures are used to protect cbl files against unlicensed use and modifications. Signatures
are generated by the CBL Interpreter itself and appended to a file, depending on the current
user profile.
In the first release of HiPath 4000 Expert Access this mechanism will just be used to protect
files against modification. It could be used to limit the capabilities to develop own CBL applica-
tions.
Do not modify system files secured with signatures! These files will be unusable and will
not compile.
Signatures are appended automatically to the CBL source file. There may be more than on
statements per file.
3.1.10 empty_stmt
(empty statement)
The empty_statement is provided for convenience only. It allows additional semicolons bet-
ween statements.
3.1.11 include_stmt
(include statement)
include quotstring ;
cbl-phb.fm
The include_stmt instructs the interpreter to read another source file in addition to the one that
contains the include_stmt. The name of the file must be enclosed between double quotes. You
can use both slash ("/") and backslash ("\") to separate directories. As always in quoted strings,
if you use backslash you have to double every occurrence of backslash ("\\").
Example:
include "source_b.cbl";
You can use an absolute (e.g. C:/rootdir/subdir/inc.cbl) or a relative file path (e. g. source_b.cbl,
subdir/source_c.cbl, ./subdir/source_c.cbl, ../subdir2/source_d.cbl) to specify the file. It is re-
commended to use relative file paths wherever possible. Thereby it’s easy to move a CBL ap-
plication to another directory or drive, as long as the relative position of the source files retains
intact.
If you use an relative path, the file is searched in the following order:
1. The file is first searched in the system include directory. This path is determined during in-
stallation of HiPath 4000 Expert Access and can be checked in HiPath 4000 Expert Ac-
cess-Options
2. Next the directory relative to the directory of the current source file is searched.
After determining the full path of the include file, the CBL Interpreter first checks, if this file al-
ready has been included previously. If this is the case, the second include statement is ignored
and thereby problems due to duplicate definition of classes etc. are avoided. So this feature
supports modular development of subsystems.
3.1.12 import_stmt
(import statement)
import quotstring ;
namespace quotstring
Using the import statement the complete OLE interface of an OLE automation server can be
imported. The import keyword either follows the class string under which the OLE server is
registered or the absolute file name of its type library (.tlb file).
If the passed name ends with “wsdl” the name is interpreted as URL or file name of a WSDL
description of a WebService. See section 3.3.5, “Working with the SOAP Interface”, on page
62 for details.
cbl-phb.fm
The CBL Language
Syntax description
If the passed name has the suffix “xsd” it is interpreted as file name of a XML Schema Definition
File. Please refer to section 3.3.6, “Import of XSD Files”, on page 64 for details.
If the passed name ends with “asn”, it is interpreted as file name of a ASN.1 module. If the suffix
is “zip”, the CBL intepreter unpacks this file an expects a file with suffix “lst” (with the same fi-
lename as the .zip-File) that should give the order for reading the ASN.1 modules. See section
3.3.7, “Import of ASN.1-Modules”, on page 67 for details.
By specifying the optional "namespace", the relevant prefix can be assigned to each OLE class
published by the OLE server.
The classes, functions and property attributes that were made available with the import state-
ment can be displayed in the CBL Interpreter’s data inspector. A description of meaning and
action is provided in the documentation provided with the relevant application.
The following example shows how the OLE interface can be imported and used by MS Excel:
import "Excel.Sheet" namespace Excel_
Excel_Application excel;
Excel_Workbooks workbooks;
workbooks=excel.Workbooks;
workbooks.Add();
excel.Range("A1").Formula="Hello World";
Excel_Workbook workbook=excel.ActiveWorkbook;
workbook.SaveAs("c:\\temp\\hello.xls");
workbook.Close();
3.1.13 function_stmt
(function declaration)
cbl-phb.fm
type_identifier identifier
[]
( ) block
function_parameters
3.1.14 function_parameters
(function parameters)
type_identifier identifier
[] @
,
The type-identifier specifies the type of data the function returns. It can be defined by a class
or be of the type int, string, variant or void if no value is returned. It is also allowed
to return an array. The type variant is used only in the context of OLE automation.
The second identifier is the name of the function. It is followed by a parameter list, which is a
comma separated list of variable names (identifier) and their associated types (type identifier)
that receive the values of the arguments when the function is called.
By default parameters are passed by value, i. e. the function gets a local copy of the parame-
ters. Modifications of the parameters within the function are not seen by the caller. In contrast,
the @ sign denotes a reference parameter. Reference parameters don’t receive copies of the
arguments, but use the same memory location as the arguments. Modifications of the parame-
ters within the function are therefore seen by the caller. Also, the current argument for a refe-
rence parameter must always denote a memory location, e. g. be a variable, and must not be
an arbitrary expression.
For compatibility of actual and formal parameters the same rules are valid as for assignment
(see there). Therefore it is possible to pass an int variable to a string parameter and vice versa.
This is even true for reference parameters!
The parameter list of a function is optional, but the parentheses are required. The block is the
body of the function, which consists of the code. A function’s code cannot be accessed by any
statement in any other function except through a call to that function. Unless the function uses
global variables or data, the code of its body can neither affect nor be affected by other parts
of the program.
cbl-phb.fm
The CBL Language
Syntax description
Although it is possible to define functions within functions this feature is not available
> in the interpreter.
Example:
int sqr(int x)
{
x = x * x;
return (x);
}
int a;
int b;
a = 3;
b = sqr(a);
// b is 9; a still is 3
b = sqr(4);
// b is 16
Example:
string concat(string a, string b)
{
return a + b;
}
Example:
void func_call()
{
int a;
a = 10;
z = sqr(a);
}
cbl-phb.fm
string [] list;
append(list,"aaa");
append(list,"bbb");
append(list,"ccc");
3.1.15 declaration_stmt
(Variable statement)
type_identifier
const @
identifier ;
[ =
[
expression
expression
cbl-phb.fm
The CBL Language
Syntax description
A ’@’ in front of the type-identifier can be used to define a reference variable. This is a variable
that does not contain a value itself but it "points" to another variable/object. See Section 3.3.1
on page 3-51 for further details.
To declare an array the variable name has to be followed by brackets.
There are two different methods to define arrays (with/without upper bound) as well as two dif-
ferent types to access array elements (string indexed, integer indexed). Memory allocation for
an array is always done when a new array element is accessed, not when the array is defined.
If one tries to access an element by an index and there is not yet an element, an "empty" ele-
ment is created automatically.
string list[10]; defines an array with a maximum of 10 elements. This boundary is che-
cked with every access to this array. Note, that the expression in brackets need not be an con-
stant expression! It is evaluated once, when the array declaration statement is executed. The
array may be either string indexed or integer indexed.
string list[]; without an expression in brackets defines a dynamic array of strings. Dy-
namic means, that there is practically no maximum number of elements. The array may be eit-
her string indexed or integer indexed.
The first access to an array defines the type of indexing. If the first access was done with an
integer index, this array can only be accessed with integer indices. It is allowed to have gaps
within the index values, the elements in-between are allocated automatically. Integer indices al-
ways start with 0. The following example creates two strings in the array called list.
list[3]="Gerry";
list[6]="Bernd";
The index range is from 0 to 99999.
cbl-phb.fm
If the first access to an array (e.g. string[]) was done with a string index, this array gets
string indexed. The elements of a string indexed array are automatically sorted alphabetically
due to performance reasons. Example:
string phone[];
phone["Erich"]="18492";
phone["Roland"]="34928";
phone["Alexandra"]="23049";
String indexed arrays can be accessed both with string or integer indices, however you cannot
allocate an additional array element using an integer index for an array that uses string type
indices.
Each array variable has a property count, which holds the number of array elements currently
allocated, i.e. the array elements can be accessed using indexes 0..count-1. Example:
int i;
for i=0 to phone.count-1 // will loop 3 times in the example above
{
system.ConsolePrint(phone[i]);
}
This example prints the values "23049", "18492" and "34928" in the console window (sorted
alphabetically by string index).
int i;
for i=0 to list.count-1 // will loop 7 times in the example above
{
system.ConsolePrint(list[i]);
}
This example prints the values "", "", "", "Gerry", "", "", "Bernd" in the console window.
Currently only one-dimensional arrays are supported. If you absolutely need multi-dimensional
arrays, you can embed an array into a class and build an array of this class.
The optional = expression clause is used to define an initial value for a variable or symbolic
constant. It is a shorthand notation for definition of a variable and a subsequent assignment.
The initialization of member variables is effective whenever a new object instance of the class
is created: Every new object’s data variables are initialized with the values specified in the class
declaration (see class_member below).
Note that class members of type reference cannot be initialized in the class declaration with a
value other than null.
cbl-phb.fm
The CBL Language
Syntax description
The const modifier is used to define symbolic constants, i. e. you define a variable who’s can-
not be modified later on. For const variables you must specify a initialization expression, be-
cause there is no other way to assign a value to a const variable.
Example:
int a;
...// assign some value to variable a
string chars[a]; // fixed sized array of strings
int b[];
int c[10]= {"Bernd":39153, "Erich":31562, "Roland":34752}; // fixed
// sized string indexed array of ints
int d[10]= {89, 1199, 3}; // fixed sized integer indexed array of ints
string name;
const int True=1;
const string name="Hugo";
3.1.16 class_stmt
(class statement)
extends identifier
dll_class
ole/dll_cls_member
cbl-phb.fm
A class declaration defines a new type that links code and data. Classes are created using the
keyword class. The identifier specifies the name of the class. The code and data of classes
are enclosed in braces.
A class can be derived from a base class using the keyword extends. The new class inherits
all members (attributes and methods) of the base class. If a method/attribute has the same
name as a base class member, only the member of the derived class will be accessible (over-
riding).
OLE classes are described in chapter 3.3.3, "Using the OLE interface".
DLL classes are described in chapter 3.3.4, "Using the DLL interface".
3.1.17 class_member
function_stmt
declaration_stmt
Example:
class book {
string author;
string title;
string keywords[];
int number;
}
In the case above, the class consists only of declarations. The data members of a class or ob-
ject are called attributes in CBL.
This example below is more complex. The class consists of declarations and a function. emp-
loyee is a simple class, which is used to store a name and an address. The function tax is used
to compute an employee’s wage. In this special case wage will be 3000.
class employee {
string name;
string address;
int tax(int pay)
{
return pay - 2000;
}
}
cbl-phb.fm
The CBL Language
Syntax description
...
void foo()
{ employee fred;
int wage;
fred.name = "Frederick";
fred.address = "Munich";
wage = fred.tax(5000);
...
}
In the example below, an initialization for data members is given:
class Point
{ int top = -1;
int left = -1;
}
In this example a base class "base" and a derived class "subclass" is defined. The subsequent
calls of the methods produce the following output in the console window:
cbl-phb.fm
base::g called
subclass::g called
subclass::h called
The function f() is inherited by the subclass. Please note that f always accesses the attributes
b and c of class "base".
Function g() is overridden by the derived class, so the function g() of the subclass will be exe-
cuted for objects of type subclass.
Function h() is an additional method defined by the subclass.
The member c of the base class cannot be accessed directly by a method of subclass because
it is hidden by "string c". It can be accessed using the predefined "pointer to base class" called
super.
3.1.18 ole/dll_cls_member
function_stmt
declaration_stmt
OLE/DLL-Prozedur/-Funktion:
void function_parameters
OLE-Eigenschaft:
3.1.19 ole_type
int
string
OLE classes can additionally contain "externally" implemented functions and properties. The
types for parameters, return value and properties is limited to int and string. The quotstring be-
hind the colon specifies the name of the OLE procedure, function or property as published by
the OLE server application.
cbl-phb.fm
The CBL Language
Syntax description
3.1.20 if_stmt
(if statement)
if ( expression ) block
else block
If the if-expression is true (anything other than 0), the corresponding block will be executed.
Otherwise the elseif-expressions are tested one after the other until one is found which yields
true. Then the corresponding block is executed. If none yields true, the block which is the target
of else will be executed, if it exists.
Please note that the condition expressions can be as complex as you want using the boolean
operators "and" (&&), or (¦¦) and not (!).
Example:
x = 10;
if (x < y)
{
x = y;
}
elseif (x > y)
{
y = x;
}
else
{
x = x + 1;
y = y + 1;
}
cbl-phb.fm
Example:
x = 22;
y = i;
if (x == y)
{
y = y + 1;
}
Expression must yield an integer result. Here if (x == y) means: If x is equal y the following
block (in the braces) will be executed. x = y would be an assignment, which does not return
an value and therefore would cause an runtime error.
Hint: Could/Should be detected at compile time!
Example:
if (x)
{
...
}
cbl-phb.fm
The CBL Language
Syntax description
3.1.21 for_stmt
(for statement)
for (
expression = expression
; ;
expression
) block
expression = expression
The keyword for is followed by three expressions - each of them is optional - enclosed in par-
entheses. In general the first expression is an assignment statement that is used to set the loop
control variable, but may also be e. g. a function call. The second is a relational expression that
determines when the loop exists. The third is an increment that defines how the loop control
variable changes each time the loop is repeated. These three sections are separated by semi-
colons. The for-loop continues to execute the block as long as the condition is true.
Due to performance reasons there is also a second possibility to express a for_stmt. This form
of the for_stmt consists of an assignment and a limitation. Therefore the first expression has to
be a variable, the second and third expression have to be numerical. The increment is
always 1 (see example above).
cbl-phb.fm
3.1.22 while_stmt
(while statement)
The expression enclosed by the parentheses after the keyword while must be a condition.
True is represented by any nonzero value. The block is iterated while the condition is true. When
the condition becomes false (==0), the program passes to the statement after the block.
Example:
string answer;
string text;
answer = "N";
while (answer != "Y")
{
cbl-phb.fm
The CBL Language
Syntax description
answer=question(text);
}
...
The function question(text) (which must be defined anywhere in the program code) will be
iterated as long as "Y" will be returned.
The next example has the same effect:
string answer;
while (question(answer) != "Y") { }
...
3.1.23 do_while_stmt
(do_while statement)
Unlike for and while loops, which test the loop condition at the top of the loop, the do_while_stmt
checks its condition (the expression enclosed by the parentheses) at the bottom of the loop.
That means that the block is always executed at least once. The do_while_stmt iterates until
the condition becomes false.
Example:
string answer;
string text;
answer = "Y";
do {
answer=question(text);
} while (answer != "Y")
...
Although answer is "Y" the block after do is executed. It depends on the return value of the
function question(text) if it is repeated or not, no matter which value answer has before
the do_while_stmt. (In contrast to the while_stmt.)
cbl-phb.fm
3.1.24 try_catch_stmt
(try_catch statement)
try block
Using the try_catch statement in conjunction with the throw statement you can implement ex-
ception handling as in C++ or Java.
If an exception object is "thrown" to a random call hierarchy within the try block, then it can be
"caught" via subsequent catch instructions. An exception object is caught if its type, i.e. the ex-
ception class, matches; in other words, the thrown object contains the class to be caught in its
class hierarchy (see "class_stmt" on page 25, see keyword extends).
The identifiers that follow the keyword catch specify an exception class and the name of the
exception object under the following block.
For an example of exception handling see "throw_stmt" on page 34.
3.1.25 throw_stmt
(throw statement)
throw identifier ;
cbl-phb.fm
The CBL Language
Syntax description
The base class of all exceptions is predefined in the system and is called "Exception". More-
over, an OleException exception class that is triggered as soon as a runtime error occurs in
response to OLE problems is predefined:
class Exception
{
string File;
int Line;
string Message;
}
The properties File and Line are automatically set by the CBL Interpreter on the execution
position of the throw statement. The origin of the exception can thus be determined later.
3.1.26 with_stmt
(with statement)
P30357-B9800-B10-101 EN, 2002-10-29
ComWin / CBL Programmer’s Reference, Guide 35
2002-07-29
cbl-phb.bk Page 36 Monday, March 22, 2004 10:24 AM
cbl-phb.fm
The with_stmt has to be followed by an expression enclosed by the parentheses and a block.
The expression must denote a memory location. This statement makes it easier to access data
and functions of a class.
Example:
class xyz
{
int a
int b
void m()
{...}
...
}
xyz ABC
...
with (ABC)
{
funct(a);
b = 5
m();
...
}
Without the with_stmt the code after the "..." had to be:
funct(ABC.a)
ABC.b = 5;
ABC.m()
3.1.27 return_stmt
(return statement)
return ;
expression
cbl-phb.fm
The CBL Language
Syntax description
3.1.28 break_stmt
(break statement)
break ;
Example:
for (t = 0; t < 100; t = t + 1)
{
count = 1;
for (;;)
{
count = count + 1;
if (count == 10)
{
break;
}
}
}
cbl-phb.fm
3.1.29 .try_catch_stmt
The try-catch-statement can be used to catch exception objects that have been thrown by
means of the throw statement. The first identifier specifies the exception class, the second the
exception object). If there is no exception the exception block is ignored.
Example:
try
{
g();
}
catch (Exception e)
{
comwinFrame.ConsolePrint("exception catched");
}
3.1.30 block
(block)
{ }
statement
A block consists of none, one or more statements. A block begins with an opening curly brace
and ends with a closing curly brace.
cbl-phb.fm
The CBL Language
Syntax description
3.1.31 expression
identifier
quotstring
hex or decimal number
number
expression . identifier
field access
[ ] indication
expression expression
unary minus
- expression
! ’not’
expression
( ) parenthesis
expression
( ) function call
expression
expression
cbl-phb.fm
3.1.32 binop
* multiplication
/ division
% modulus
|| logical OR
| bitwise OR
== equal
!= not equal
cbl-phb.fm
The CBL Language
Syntax description
There are some restrictions concerning the operand types allowed for the different operators:
Arithmetic, logical and bitwise operators are defined for int operands only. The plus sign is also
used for string concatenation (see table below).
The comparison operators ==, <, >, <=, >=, != are defined for the basic types int and string.
The following tables give you an overview about the possibilities of combinations with the four
operators "+", "-", "in" and "=".
(If there is a „-“ in a cell, it means that this combination is not defined.)
Operator +
+ right operand
string - string - -
concatenation (1)
class - - - -
[] - - - -
cbl-phb.fm
Operator -
- right operand
string - - - -
class - - - -
[] - - - -
Operator in
in right operand
(1) Example:
string hello;
...
if ("he" in hello)
{...}
If "he" occurs in the string hello, the expression ("he" in hello) is true and the block
{...} will be executed.
(2) Example:
cbl-phb.fm
The CBL Language
Syntax description
string hello;
string Text[];
...
if (hello in Text)
{...}
If the string in variable hello is an element of the array Text, the expression (hello in
Text) is true and the block {...} will be executed.
Operator =
= right operand
cbl-phb.fm
// expression list:
int list[] ={ 10 , 25, 30 };
cbl-phb.fm
The CBL Language
Syntax description
3.1.33 type_identifier
string
void
The type-identifier defines the type of a variable or function. You cannot define a variable of type
void. The type void is used only as return type of functions, which do not return a result and as
possible base type of references.
There is an additional predefined type variant, which is used only in the context of OLE auto-
mation.
Example:
int i;
void func();
string Text[];
string book(string title) {...}
An identifier which is defined by a class_stmt:
cbl-phb.fm
....
class myclass {
...
}
myclass data;
....
3.1.34 identifier
alpha
alpha
_
digit
The names of variables, functions, and other user-defined items are identifiers. These identi-
fiers can vary from one to several characters. The first characters must be a letter or an un-
derscore, and subsequent characters must be either letters, digits, or underscores. In an iden-
tifier, upper- and lowercase are treated as distinct. Hence, x and X would be two separate
identifiers.
All names starting with an underscore are reserved for the CBL system and should
> therefore not be used in applications.
Example:
Correct: _
test1
list_book
Incorrect: 1x
hello!you
list...book
cbl-phb.fm
The CBL Language
Syntax description
3.1.35 alpha
a....z A....Z
3.1.36 digit
0....9
3.1.37 number
digit
hex
’ any char. ’
3.1.38 hex
0 x digit
A....F
a....f
cbl-phb.fm
Example:
int a;
int b;
a = 0x3F; // 77 in decimal
b = a + 0x64; // equal to: b = a + 100
3.1.39 quotstring
„ „
any char.
Example:
"This is a ’simple’ test"
An exception is the backslash character (\). This character is used to include special codes in
a string.
The backslash codes are:
\n new line
\t horizontal tab
\r carriage return
\" double quote
\\ backslash itself
\x The following two characters are interpreted as hex digits. The corresponding
ASCII character is inserted into the string (e. g. \x0a = newline character).
If a single backslash followed by any other character occurs in a string, the backslash will be
ignored.
cbl-phb.fm
The CBL Language
Syntax description
/* */
any char.
Structured comments begin with the character pair /* and end with */. There must be no
spaces between the asterisk and the slash. The interpreter ignores any text between the be-
ginning and ending comment symbols. Comments can be anywhere in a program, as long as
they do not appear in the middle of a keyword or identifier or quoted string.
Example:
x = 10;
/* this is a comment */
x = x + /* add a number */ 5;
Comments may not be nested. That is, one comment cannot contain another comment.
Example:
/* This is /* not allowed */ and causes an error */
// \n
A single line comment begins with // and it ends at the end of the line. Whatever follows the
// is ignored by the interpreter until the end of the line is reached.
cbl-phb.fm
Example:
x = 10;
//this is a single line comment
x = x + 5; //add a number
cbl-phb.fm
The CBL Language
Advanced topics
cbl-phb.fm
cbl-phb.fm
The CBL Language
Advanced topics
class complex
{ int re;
int im;
}
"complex"
re
im
Therefore you can also initialize the members in a class declaration to define other initial values
than the default 0 values:
class point
{ int x = 1;
int y = 9;
}
"point"
x 1
y 9
cbl-phb.fm
complex
re
im
copy
complex
re
Z
im
complex
X re
im
When a structured variable is assigned to another structured variable as a whole, the value ob-
ject of the source variable is cloned and assigned to the destination variable (Btw.: This is not
the way the interpreter really works, but this description shows it from the users view):
X=Z;
complex
re
Z
im
complex
X re
im
complex
re "value objects"
im
cbl-phb.fm
The CBL Language
Advanced topics
As shown, the previous value object still exists but without any reference to it. Value objects wi-
thout any reference will be removed by a process called "Garbage Collection".
However, when an expression list is assigned to a structured variable, the assignment occurs
elementwise. Therefore, no object is cloned and the memory used by the object remains the
same!
Reference variables allow a named data element to be referred multiply. If a reference variable
is created, it first points to no value object. This value is called "null".
complex @Ref;
Ref null
The reference variable cannot be accessed until it has been assigned a variable.
The only thing you can do here, is to test if the reference variable is null:
if (Ref == null) ...
if (Ref != null) ...
When you assign a variable to a reference variable which is null, a reference to the right side
of the assignment is stored in the reference variable:
Ref=Z;
complex
re
Z
im
Ref
Ref is now a synonym for Z. If Ref is assigned a new value the value of the referred variable
changes too:
Ref=X;
Z=X; // both assignments have the same effect!
cbl-phb.fm
complex
re
Z
im
complex
re
Ref im
complex
re
X
im
Ref complex[]
[0]
a2 [1]
array=a2;
cbl-phb.fm
The CBL Language
Advanced topics
complex[]
array [0]
[1]
[2]
Ref complex[]
[0]
a2 [1]
complex[]
[0]
[1]
cbl-phb.fm
The information which is important for the logical link between OLE and CBL is printed bold.
In the current version of the interpreter only the types int and string are allowed for parameters,
return values and properties. Only Call-By-Value is supported.
The function parameters, return values and property types must be consistent between OLE
and CBL.
If you want to access 3rd party applications you must try to get the interface from the vendors
help files or documentation.
Examples: (works only for German MS Word 7.0)
ole_class MS_Word : "Word.Basic"
{
void FileNew(string type) : "DateiNeu"
void Insert(string text) : "Einfügen"
void FileSaveAs(string param) : "DateiSpeichernUnter"
void FormatTabulator(string pos) : "FormatTabulator"
}
ole_class Netscape : "Netscape.Network.1"
{
int Open(string pURL, int iMethod, string pPostData,
int lPostDataSize, string pPostHeaders) : "Open"
int GetStatus() : "GetStatus"
void Close() : "Close"
int BytesReady() : "BytesReady"
int GetContentLength() : "GetContentLength"
string GetContentType() : "GetContentType"
int Read(string pbuffer, int iAmount) : "Read"
}
cbl-phb.fm
The CBL Language
Advanced topics
{ variant value;
_OlePropertyGet(obj,name,value,i1,i2);
return value; }
void OlePropertySet(string name,variant value,variant i1, variant i2)
{ _OlePropertySet(obj,name,value,i1,i2); }
void OleProcedure(string name,variant p1, variant p2, variant p3)
{ _OleProcedure(obj,name,p1,p2,p3); }
variant OleFunction(string name,variant p1, variant p2, variant p3)
{ variant value;
_OleFunction(obj,name,value,p1,p2,p3);
return value; }
}
Variant sheet;
sheet.CreateObject("Excel.Sheet");
Variant app;
app.obj=sheet.OlePropertyGet("Anwendung",empty,empy);
int visible=app.OlePropertyGet("Sichtbar",empty,empty);
app.OlePropertySet("Sichtbar","Wahr",empty,empty);
Variant cell;
cell.obj=app.OlePropertyGet("AktiveZelle",empty,empty);
cell.OlePropertySet("Z1S1Formel", "11", empty,empty);
Variant range;
range.obj = sheet.OlePropertyGet("Bereich","A2",empty);
range.OleProcedure("Auswählen",empty,empty,empty);
cell.obj=app.OlePropertyGet("AktiveZelle",empty,empty);
cell.OlePropertySet("Z1S1Formel", "222",empty,empty);
range.obj=sheet.OlePropertyGet("Bereich","A3",empty);
range.OlePropertySet("Z1S1Formel",
"=SUMME(Z(-2)S:Z(-1)S)",empty,empty);
cbl-phb.fm
void OlePropertySet(string name,variant value,variant i1, variant i2) sets the value of pro-
perty name of OLE object obj to value. If the property is an array i1 and i2 are used as
index values to this array.
OleProcedure(string name,variant p1, variant p2, variant p3) calls the OLE procedure name.
p1, p2 and p3 are parameters for this procedure call.
variant OleFunction(string name,variant p1, variant p2, variant p3) calls the OLE function
name. p1, p2 and p3 are parameters for this procedure call. It returns the result of the function
call.
cbl-phb.fm
The CBL Language
Advanced topics
_MemBlockGetString(mb,offset,size); }
void SetString(int offset, int size, string s)
{ _MemBlockSetString(mb,offset,size,s); }
}
Meaning of the functions:
user32.MessageBeep(1000);
user32.MessageBox(0,"Hello World", "Message", 1);
cbl-phb.fm
If the server requires authentification with user and password the CBL Interpreter intrinsic func-
tion _Import can be called.:
As shown in the example above the URL can be constructed at runtime. Exceptions can be
caught using the CBL excaption handling. The second paramter of the _Import function is the
namespace.
If a WebService could be imported successfully there will be a class with the name of the Web-
Service and methods for each WebMethod. These types and objects can be visualized using
the data inspector of the CBL interpreter.
These imported objects contain predefined properties like _url, _keepconnection and
_http. They are used to control the execution of the methods of that WebService.
cbl-phb.fm
The CBL Language
Advanced topics
_url is a text string. It tells the CBL interpreter where to execut the WebMethod. Therfor the
_url must be set in advance to the execution of the first method. Setting _url is ablolutely
necessary if the WSDL was read from a file.
_keepconnection tells the CBL interpreter if the HTTP connection should be reset (0) or kept
(1) for each call of an WebMethod. Default value of _keepconnection is 1.
By means of the string array _http additional parameters can be passed to the HTTP connec-
tor component (see description of MS-SOAP-Toolkit for details).
Methods that are defined in the WebService can be called like ordinary CBL functions::
cbl-phb.fm
cbl-phb.fm
The CBL Language
Advanced topics
The elements defined in this file lead to definition of corresponding data structures in the sym-
bol table of the CBL interpreter. These types can then be inspected using the data inspector.
With the data inspector you can also navigate to the XSD file where the data structure has been
defined. This is a very helpful function when exploring complex schemas.
If a XML string is to be created - matching the XML description shown above - an object of this
data type can be instanceated like this:
CSTA::MakeCall makecall;
The properties of this object can be accessed like with any other CBL defined object:
makecall.callingDevice=”31562”;
makecall.callingDevice.typeOfNumber=
CSTA::DeviceID::typeOfNumber::dialingNumber;
makecall.calledDirectoryNumber=”39153”;
Each class that has been generated by a XSD import has the methods string ToString()
and void FromString(string s).
Using ToString() a XML string will be generated from the current objects content. Default
values will be taken into consideration when genering the XML string: only values that differ
from the default values will be visible in the string.
string s=makecall.ToString();
comwinFrame.ConsolePrint(_BeautifyXML(s));
The function _BeautifyXML can be used to “beautify” a XML string to enhance its readabilty.
The object shown above results in this XML string:
<MakeCall>
<callingDevice>31562</callingDevice>
<calledDirectoryNumber>39153</calledDirectoryNumber>
</MakeCall>
The method FromString is used for parsing a XML string in the other direcion. The object will
be filled with data provided in the XML string:
cbl-phb.fm
CSTA::MakeCall mc;
mc.FromString(s);
The the data can be accessed using ordinary CBL functionionality. By this means the CBL in-
terpreter got a validating XML parser.
cbl-phb.fm
The CBL Language
Advanced topics
cbl-phb.fm
{
int send_response=0;
if (operation_value.value==211)
{
// Received SystemStatus-Request --> Send SystemStatusRes
with (rose_res)
{
choiceId=CSTA::ROSEapdus::rors_apduCid;
rors_apdu=CSTA::RORSapdu::New();
with (rors_apdu)
{
invokeID.value=rose_apdu.roiv_apdu.invokeID.value;
cSTA::CSTA::RORSapduSeq=CSTA::RORSapduSeq::New();
with(cSTA::CSTA::RORSapduSeq)
{
operation_value.value=211;
anyDefBy=CSTA::GetAnyByInt(operation_value,2);
with(anyDefBy)
{
choiceId=CSTA::SystemStatusRes::noDataCid;
noData =AsnNull::New();
}
}
}
}
send_response=1;
}
elseif (operation_value.value==207) // SystemRegister
{
// Received SystemRegister-Request--> Send SystemRegisterResult
with (rose_res)
{
choiceId=CSTA::ROSEapdus::rors_apduCid;
rors_apdu=CSTA::RORSapdu::New();
with (rors_apdu)
{
invokeID.value=rose_apdu.roiv_apdu.invokeID.value;
cSTA::CSTA::RORSapduSeq=CSTA::RORSapduSeq::New();
with(cSTA::CSTA::RORSapduSeq)
{
operation_value.value=207;
//anyDefBy=CSTA::SystemRegisterResult::New();
anyDefBy=CSTA::GetAnyByInt(operation_value,2);
with (anyDefBy)
{
sysStatRegisterID.octetLen=3;
sysStatRegisterID.octs={ 1, 2, 3 };
}
}
}
}
send_response=1;
} // SystemRegister
if (send_response)
{
b.InitInWriteMode();
cbl-phb.fm
The CBL Language
Advanced topics
rose_res.BEncPdu(b,bytesEncoded);
b.PutByteRvs(bytesEncoded%256);
b.PutByteRvs(bytesEncoded/256);
hex=b.ToHex();
sim.SendRequest(hex,3);
os="";
rose_res.Print(os);
comwinFrame.ConsolePrint("\nSent:\n");
comwinFrame.ConsolePrintStyle(os,cpsFixed);
}
}
}
}
return;
}
os="";
b.InstallDataFromHex(hex);
acse_apdu.Init();
ok=acse_apdu.BDecPdu(b,bytesDecoded,os);
if (ok)
{
os << endl;
acse_apdu.Print(os);
comwinFrame.ConsolePrint("\nReceived:\n");
comwinFrame.ConsolePrintStyle(os,cpsFixed);
//
// Waiting for ACSE::AARQ
//
// Send ACSE::AARE
//
ACSE::ACSE_apdu resapdu;
resapdu.choiceId=ACSE::ACSE_apdu::aareCid;
resapdu.aare=ACSE::AARE_apdu::New();
with (resapdu.aare)
{
application_context_name=acse_apdu.aarq.application_context_name;
result.value=ACSE::Associate_result::accepted;
result_source_diagnostic=ACSE::Associate_source_diagnostic::New();
with (result_source_diagnostic)
{
acse_service_user=ACSE::Associate_source_diagnosticInt::New();
acse_service_user.value=ACSE::Associate_source_diagnosticInt::null1;
}
user_information=ACSE::Association_information::New();
with (user_information)
{
with(list[0])
{
direct_reference=AsnOid::New();
direct_reference=acse_apdu.aarq.user_information.list[0].direct_reference;
encoding=ACSE::EncodingCsta::New();
encoding=acse_apdu.aarq.user_information.list[0].encoding;
}
}
}
b.InitInWriteMode();
cbl-phb.fm
resapdu.BEncPdu(b,bytesEncoded);
b.PutByteRvs(bytesEncoded%256);
b.PutByteRvs(bytesEncoded/256);
hex=b.ToHex();
sim.SendRequest(hex,3);
os="";
resapdu.Print(os);
comwinFrame.ConsolePrint("\nSent:\n");
comwinFrame.ConsolePrintStyle(os,cpsFixed);
//
// Send CSTA/ROSE::SystemStatus
//
rose_apdu.Init();
with (rose_apdu)
{
choiceId=CSTA::ROSEapdus::roiv_apduCid;
roiv_apdu=CSTA::ROIVapdu::New();
with (roiv_apdu)
{
invokeID.value=0;
operation_value.value=211;
argument=CSTA::GetAnyByInt(operation_value,1);
with(argument)
{
systemStatus.value=CSTA::SystemStatus1::normal;
}
}
}
b.InitInWriteMode();
rose_apdu.BEncPdu(b,bytesEncoded);
b.PutByteRvs(bytesEncoded%256);
b.PutByteRvs(bytesEncoded/256);
hex=b.ToHex();
sim.SendRequest(hex,3);
os="";
rose_apdu.Print(os);
comwinFrame.ConsolePrint("\nSent:\n");
comwinFrame.ConsolePrintStyle(os,cpsFixed);
return;
}
}
cbl-phb.fm
CBL - Programmer’s Reference
Interface to the Interpreter
Advanced topics
> chapter 4.1, "Interface to the Interpreter"
> chapter 4.2, "General functions"
> chapter 4.3, "Interfaces to the HiPath 4000 Expert AccessFrame components"
> chapter 4.4, "Designing forms"
> chapter 4.5, "CBL - National Language Support"
Advanced topics
> chapter 4.1.1, "Command line parameters: Args"
> chapter 4.1.2, "Interpreter functions"
cbl-phb.fm
Args["par1"]="value1"
Args["par2"]="value2"
Args["par3"]="value3"
Functions starting with underscore _ should only be called directly by the user
> if absolutely necessary. They are only intended for functions defined in system in-
cludes.
cbl-phb.fm
CBL - Programmer’s Reference
Interface to the Interpreter
int _Defined (void _Defined can be used to check if a specific function named
@_this, string _symbol or a specific field is defined for an object.
_symbol)
cbl-phb.fm
int _MemBlockGetPtr The _MemBlock functions are needed for the implementation
(_memblock @m); of memory blocks for the DLL interface.
void _MemBlockSetPtr
(_memblock @m, int see "Using the DLL interface" on page 60
ptr)
void _MemBlockAlloc
(_memblock @m, int si-
ze)
void _MemBlockFree
(_memblock @m)
int _MemBlockGetInt
(_memblock @m, int
offset, int size)
void _MemBlockSetInt
(_memblock @m, int
offset, int size, int
value)
string
_MemBlockGetString
(_memblock @m, int
offset, int size)
void
_MemBlockSetString
(_memblock @m, int
offset, int size,
string s)
int _MemBlockGetSize
(_memblock @m)
cbl-phb.fm
CBL - Programmer’s Reference
Interface to the Interpreter
cbl-phb.fm
Advanced topics
> chapter 4.2.1, "cbl_sysfunc_ (ole_class)"
> chapter 4.2.2, "cbl_chain (ole_class)"
> chapter 4.2.3, "cblFile (ole_class)"
> chapter 4.2.4, "cblIniFile (ole_class)"
> chapter 4.2.5, "cblZipFile (ole_class)"
> chapter 4.2.6, "cbl_dialogs (ole_class)"
> chapter 4.2.7, "cblXmlFile (ole_class)"
cbl-phb.fm
CBL - Programmer’s Reference
General functions
// encryption / decryption
string encrypt(string s, string p="")Ö
string decrypt(string s, string p="")Ö
//
// Misc
//
string ExtractFilePath(string file)Ö
string CreateTempDir() Ö
string CreateTempFile(string dir) Ö
void DeleteTempDir(string dir)Ö
int file_compare(string file1, string file2, int size=0)Ö
string [] FindFile(string pattern)Ö
void ForceDirectories(string dir)Ö
string FindConnectProfile(string uw7ipaddr)
cbl-phb.fm
String length
int strlen(string s)
strlen() returns the number of characters of s.
Substring
string substr(string s, int start, int len)
substr() returns a string which is a part of s. It begins at the position of start and has the
length len. start is 0-based.
cbl-phb.fm
CBL - Programmer’s Reference
General functions
rtrim() returns the string s where all spaces and control characters on the right have been
removed..
cbl-phb.fm
* Any number of the preceding character; in the example all " *schon"
lines are searched that contain the word “schon” with any
number of preceeding spaces:
. Exactly one character. ".och"
[] Excatly one of the enclosed characters. "[Dd]och"
[a-z] One of the characters matching a range. "[A-X]och"
[^] none of the enclosed characters "[^ln]och"
\ Invalidates the special meaning of the succeeding charac- "x\$\>y"
ters.
\< Search pattern at the beginning of a word "\<doch"
\> Search pattern at the end of a word. "ung\>"
\(..\) Remember enclosed patern; this can be accessed later "\(aff\)ig
using \1. Up to nine patterns can be stored in this way. \1enstark"
x\{m\} m-timed occurance of character x. "s\{3\}"
x\{m,n\} At least m-, at most n-timed occurance of character x "+\{5,8\}"
int cnt=sys.match_regex(s,"and",1,found);
//-> cnt=1, found="and"
cnt=sys.match_regex(s,"s.",1,found);
//-> cnt=3, found="st"
cnt=sys.match_regex(s,"s.",2,found);
//-> cnt=3, found="si"
cnt=sys.match_regex(s,"rabbit",1,found);
//-> cnt=0, found=""
cbl-phb.fm
CBL - Programmer’s Reference
General functions
cbl-phb.fm
sort_grid sorts a string array, whose entries are intended as the contents of a multi-column
ctListbox control (see ctListbox), by a specific column defined by col. The first column has
the index 0.
_sep=","
cbl-phb.fm
CBL - Programmer’s Reference
General functions
Execution time
int clock()
The function clock() returns a time value in milliseconds (ms). The absolute value is mea-
ningless for the caller. However, it is possible to measure the time between two occurrences.
If the execution time is not available, or the value cannot be interpreted, the function will return
-1.
Emit beep
void MessageBeep(int sound=-1)
A beep or a system sound can be output with MessageBeep.
cbl-phb.fm
cbl-phb.fm
CBL - Programmer’s Reference
General functions
Error numbers
string [] parse_amo_errors(string _in)
The parse_amo_errors() function creates a 0-based array with the error numbers of the re-
sults of a HICOM command. All M-, S-, H- and F-messages are stored in the array. The string
_in is the reply, sent by HICOM, on a HICOM command.
cbl-phb.fm
cbl-phb.fm
CBL - Programmer’s Reference
General functions
CreateTempDir creates a temporary directory. The path of the directory is returned. The
directory is located beneath Window’s temporary directory, usually C:/TEMP. The name of the
temporary directory starts with "CBL".
Compare files
int file_compare(string file1, string file2, int size=0)
file_compare compares the given files, opened in binary mode. If file1 could not be ope-
ned it returns -1; if file2 could not be opened it returns -2.
size defines the minimum number of bytes to be compared. If size equals 0 (default) the files
are compared completely.
file_compare returns 0 for equal, 1 for different files.
Find files
string [] FindFile(string pattern)
FindFile returns all file names that match the specified pattern (which can be defined using
the usual wildcards * and ? allowed under Windows).
cbl-phb.fm
Parse URL
cblUrl ParseUrl(string url)
ParseUrl parses (i.e. splits) the url that is passed to it as an argument into its respective
components:
cblUrl loc=ParseUrl(
"http://hpserv99.mch4.siemens.de:8080/ComWin/
download.html?par1=value1&par2=value2");
-->
loc.proto="http"
loc.user=""
loc.pass=""
loc.host="hpserv99.mch.pn.siemens.de"
loc.port="8080"
loc.path="/ComWin"
loc.filename="download.html"
loc.params["par1"]="value1"
loc.params["par2"]="value2"
cbl-phb.fm
CBL - Programmer’s Reference
General functions
cbl-phb.fm
Removes all values in int chain s from the internal representation of the chain object. To see
the resulting chain, you have to convert the chain object back into a string (see
chain_to_string() below).
Example:
mychain.void remove_chain_from_chain("30&32&36&&38");
Opening a file
string open(string name, string mode)
The function open() opens a file. Here, name is the name of the file and mode determines
how the file will be opened. Legal mode values are:
"r" open a file for reading (this file must exist)
"w" create a text file for writing (any already existing file with this name will be overwritten)
"a" open a text file with mode append (new data will be appended to the end of the file).
cbl-phb.fm
CBL - Programmer’s Reference
General functions
If the function fails, an error message will be returned, otherwise an empty string will be retur-
ned.
Example:
cblFile f;
f.open ("sysfunc.cbl","r");
Reading a string
string readln()
string read(int size=0)
The function readln() reads a line from a file opened in read mode by open(). The retur-
ned string are the data the function reads.
The function read reads a given number (size) of characters from the file. If size equals 0
(default) the file is read until the end of file is reached.
Writing a string
int write(string txt)
The write() function write strings to a file that was previously opened (and created) for wri-
ting.
Closing a file
void close()
The close() function closes a file that was opened by the open() function.
End of a file
int eof
If the end of a file is encountered the eof property returns true (1), otherwise it returns 0.
Example:
cblFile f;
string line;
f.open("readme.txt","r");
line = f.readln();
while (!f.eof) {
//handle line read:
...
line = f.readln();
}
f.close();
cbl-phb.fm
The block after the while_stmt is executed until the end of the file is reached.
cbl-phb.fm
CBL - Programmer’s Reference
General functions
string [] directory()
void close()
}
open opens a zip file. It returns 1 if the zipfile could be opened, else it returns 0.
close closes the zip file.
directory returns the files and paths that are contained within the zip file.
unzip unpacks the files matching the given pattern into the destination_dir.
If mode equals 1 a popup window shows the current unpacking progress.
cbl-phb.fm
string Directory
string Filter
class cblXmlRecord
{
string name;
string [] params;
cblXmlRecord [] items;
string [] contents;
}
cbl-phb.fm
CBL - Programmer’s Reference
General functions
cbl-phb.fm
Advanced topics
> chapter 4.3.1, "Comedit (ole_class)"
> chapter 4.3.2, "ComwinControl (ole_class)"
> chapter 4.3.3, "(mode|=2: application handles wrong password, open returns immediately;
mode|=4: deactivate autologon.)ComwinFrame (ole_class)"
> chapter 4.3.4, "ComwinCBL (ole_class)"
> chapter 4.3.5, "ComWinFT (ole_class)"
> chapter 4.3.6, "ComWinPPP (ole_class)"
> chapter 4.4, "Designing forms"
> chapter 4.3.8, "ComWinAccessSession (ole_class)"
> chapter 4.3.9, "ComWinAccessFileman (ole_class)"
> chapter 4.3.10, "ComWinAccessDatabase (ole_class)"
> chapter 4.3.11, "ComWinAccessQuery (ole_class)"
> chapter 4.3.12, "ComWinFM (ole_class)"
ComWin ComWin
MML Editor CBL
This class encapsulates the interface from a CBL program to HiPath 4000 Expert Access-
MML_Editor. It contains functions for handling of MML command strings and parsing of AMO
output strings.
ole_class Comedit : "ComWin.MML_Command"
{
string getParam(string param, int language=0) Ö
int setParam(string param, string value, int language=0) Ö
string getParamName(int index, int language=0)Ö
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
string [] getParamNames()Ö
string getParamDesc(string param, int language=0)Ö
int getParamProps(string param)Ö
string getValue(string param, int index, int language=0)Ö
string getValueDesc(string param, int index, int language=0)Ö
string getParamValidation(string param, int language=0)Ö
int getParamIndex(string param) Ö
string command Ö
int Active Ö
int ParamCount Ö
string HicomVariant Ö
int HicomLanguage Ö
int ApplicationLanguage Ö
string HicomCommand Ö
string Noun Ö
string Verb Ö
string [] GetHicomVariants() Ö
int KeywordOriented Ö
string DestinationProcessor Ö
int Error Ö
string ErrorMsg Ö
string ErrorParam Ö
string ErrorParamIdx Ö
string ErrorValue Ö
int Check() Ö
int CheckParam(string param) Ö
int ExistsParam(string param) Ö
int ShowParamDlg(string param) Ö
string ShowCommandDlg(string command) Ö
void ShowCommand(int ConnectionId,
String ConnectionName,
String MMLCommand,
String MMLVariant,
int MMLLanguage,
String ReplyObject,
String ReplyMethod) Ö
cbl-phb.fm
// Zusätzliche Funktionen
void ShowHelp(string url)
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
Hicom Language
int HicomLanguage
The HicomLanguage specifies the current MML language of the PBX. 1 = german, 2 = eng-
lish. Please refer to the description of HicomCommand for further details.
Application language
int ApplicationLanguage
The ApplicationLanguage specifies the current MML language as used in the CBL application.
It defines the language for parsing the MML commands as stored in command. 1 = german, 2
= english. Please refer to the description of HicomCommand for further details.
Hicom command
string HicomCommand
If HicomLanguage and ApplicationLanguage differ, the attribute HicomCommand can be
used for an automated translation of the current MML command. If HicomCommand is assigned
a MML command in HicomLanguage, it is automatically translated to ApplicationLangu-
age and stored into command (and vice versa). Please note that HicomCommand always uses
HicomLanguage and command always uses ApplicationLanguage for MML parsing.
cbl-phb.fm
Destination processor
string DestinationProcessor
DestinationProcessor returns the name of the Hicom board where the AMO is designed
to be executed. The value can be "SWU", "ADP", "VM", "TD" or "SS7". Please note that the des-
tination processor can be defined at runtime, too.
Number of parameters
int ParamCount
The ParamCount property returns the number of the defined parameters of the AMO-com-
mand.The AMO-command is defined in the property command, which is described above. Pa-
ramCount is a read-only property.
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
If language equals 0 the value of the parameter is returned in the current ApplicationLan-
gauge. If language equals MML_german (1) or MML_english (2) the value is translated to
the desired language.
Description of a parameter
string getParamDesc(string param, int language=0)
The getParamDesc() function returns a short help text of the parameter param.
If language equals 0 the description of the parameter is returned in the current Applicati-
onLangauge. If language equals MML_german (1) or MML_english (2) the description is
translated to the desired language.
cbl-phb.fm
If language equals 0 the value description of the parameter is returned in the current Appli-
cationLangauge. If language equals MML_german (1) or MML_english (2) the value de-
scription is translated to the desired language.
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
Error number
int Error
If the function Check() - which is described below - detects an error, the variable Error will
be the error number.
cbl-phb.fm
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
Error Meaning
32 Invalid file position
33 Noun syntax incorrect
34 No MML command
35 PDB file not found
36 Verb not found in PDB file
37 Field not found in mask
38 End of AmoResult reached
40 Parameter not found
41 Index outside valid range
42 Parameter has no defined value list
43 Internal error during parameter check
44 Output mask not found
45 Hicom variant not found (check installation)
46 Syntactical error in GENDB format (faulty headers)
47 Value range links not permitted with 'And-And'
48 Command not terminated with semicolon
49 Link not permitted with 'And-And'
50 Parameter assigned several times
51 Combination of positions and keyword-oriented parameters not permitted
100 End of input file
500 Command buffer is empty
501 Command buffer emptied
502 Entry cannot be interpreted as MML command
503 An error occurred when sending back to HiPath 4000 Expert Access-Connect
deactivate autologon.)
With every call to a function or assignment to a property of the HiPath 4000 Expert Access-
MML-Editor interface the properties Error, ErrorParam, ErrorMsg and ErrorParamIdx
are set to the appropriate value.
Error message
string ErrorMsg
cbl-phb.fm
If the check function - which is described below - detects an error, the error message is copied
into the string ErrorMsg .
Possible error messages: see list above.
Error location
string ErrorParam
int ErrorParamIdx
string ErrorValue
The ErrorParam property holds the name of the parameter, which is causing an error, Er-
rorParamIdx it’s position (as defined in the position oriented view). ErrorValue contains the
value that caused the error, if available.
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
Transfer a command from another OLE server to HiPath 4000 Expert Access-MML-Editor
This method is designed for use by other OLE servers only, not for use within CBL applications!
void ShowCommand(int ConnectionId,
String ConnectionName,
String MMLCommand,
String MMLVariant,
int MMLLanguage,
String ReplyObject,
String ReplyMethod);
ShowCommand passes the command MMLCommand to the current HiPath 4000 Expert Access-
MML-Editor window. If there is no HiPath 4000 Expert Access-MML Editor window existing, a
new one will be opened. The HiPath 4000 Expert Access-MML-Editor window will be brought
to front. MMLVariant tells HiPath 4000 Expert Access-MML-Editor the Hicom variant, MML-
Language (1=german, 2=english) the Hicom command language of the command to be dis-
played.
If ConnectionId is (used defined) non-negative and ConnectionName not empty a menu
item "Send back to " plus ConnectionName will be available from the HiPath 4000 Expert Ac-
cess-MML-Editor menu "Command". If this menu item (or Enter or F2 or Shift+F2) is executed
HiPath 4000 Expert Access-MML-Editor will create a temporary OLE-connection to the OLE-
object named ReplyObject ( e. g. "ComWin.Control") and executes an OLE method named
ReplyMethod (e. g. "SetCmd") passing ConnectionId as first, and the current MML com-
mand as second parameter. Then the OLE-connection will be released.
cbl-phb.fm
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
The example trace.cbl gives another example where ScanMask is used to parse an AMO out-
put. In this example it was necessary to use ScanMask because the values needed by the ap-
plication were not available with REGEN commands.
Using the SkipLines(int cnt) function, a defined number (cnt) of lines can be skipped in
the AmoResult.
Using the GetNextMask(string maskname) function, the name of the mask after the mask-
name mask can be checked in the PD file.
As an alternative the function FindMask can be used to find a specific mask in AmoResult.
FindMask tries to find the desired mask specified by the parameter maskname starting from
the current position within AmoResult. All lines of AmoResult that do not match the desired
mask are skipped. In case of an error (e.g. end of AMO result reached) the error variable Er-
ror is set and the error code will be returned. If mask is found the return value is 0. The current
field values can be read by means of FieldByName.
Example:
// Tell comedit to parse AMO BCSU
comedit.command="DISPLAY-BCSU:TAB,1,1;";
// endless loop
for (;;)
{
// search next occurrence of mask ’tabvar’ in AmoResult
int result=comedit.FindMask("tabvar");
if (result==0) // if found
{
// extract a field from the mask
system.ConsolePrint("soll="+comedit.FieldByName("soll"));
}
else // some error occurred, e.g. end of amo result
{
// leave the loop
break;
}
}
cbl-phb.fm
The third alternative available is the function ParseAmoResult(). This function analyzes the
complete current AmoResult and tries to cover as many AmoResult lines as possible with
AMO masks. The result of analysis is returned as a return value in a suitable array.
As the algorithm is, understandably, not trivial and recursive, the AmoResult to be parsed
should not be too large.
The elements of the result array are defined as follows:
class amoParseMaskRecord
{
string maskname;
string skipped;
string [] fields;
}
The following example should clarify the function:
include "OpenConnDlg.cbl"
amoParseMaskRecord [] parseResult;
void PrintParseResult()
{
int i;
int f;
comwinFrame.ConsolePrint("-----------------------------------");
for i=0 to parseResult.count-1 do
{
with (parseResult[i])
{
if (skipped!="")
comwinFrame.ConsolePrintStyle("Skipped "+skipped,cpsWarning);
if (maskname!="")
{
comwinFrame.ConsolePrint("Found mask "+maskname);
for f=0 to fields.count-1 do
{
comwinFrame.ConsolePrint(" field "+fields[f].index
+" = '"+fields[f]+"'");
}
}
}
}
comwinFrame.ConsolePrint("-----------------------------------");
}
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
void main()
{
// tell comedit that we are using english AMOs within our Application
comedit.ApplicationLanguage=MML_english;
// tell comedit that we want to work with AMO VEGAS
comedit.command="DISP-VEGAS;";
// execute the AMO (HicomCommand returns the command
// in the AMO language of the Hicom
string result=comwin.Send(comedit.HicomCommand);
// give comedit the AMO output
comedit.AmoResult=result;
parseResult=comedit.ParseAmoResult();
PrintParseResult();
}
OpenConnDlg conn;
if (conn.show())
{
main();
}
cbl-phb.fm
Additional functions
The function ShowHelp causes a html file being displayed in the configured web browser (e.g.
Netscape). The file name passed to ShowHelp is relative to the Service Handbook Base Url as
defined for a specific Hicom Variant. This function can be used to display a specific file of the
Service handbook (e.g. ad1sa.htm).
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
result=comedit.CheckFileUntilError("Test.MML",
"",
comedit.FilePos, 1000, 8);
lineno=lineno+comedit.ErrorLine;
line=lineno;
if (result)
{
system.ConsolePrintStyle("Line "+line+": Error="+comedit.ErrorMsg
+"(parameter "+comedit.ErrorParam+")",cpsError);
}
else
{
system.ConsolePrint(line + " lines processed ...");
}
} while (result!=33);
The property FilePos always points to the current read position within the input file.
The property ErrorLine points to the line number of the current processed command within
the input file.
The property ErrorValue shows a parameter value which caused the error, if available.
The result value of CheckFileUntilError is the current Error number.
cbl-phb.fm
ComWin ComWin
CBL Connect
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
Comedit mml
string HicomLanguage Ö
string HicomVariant Ö
string HostName Ö
string HostDispName Ö
string HostDesc Ö
Please note that the interface to CBL applications is slightly different to applications
> that connect immediate using the OLE interface. Please see module comwin.cbl to
investigate the mapping between CBL- and OLE interface.
cbl-phb.fm
Using OpenDirekt a connection can be opened without a connection profile having first been
created in the connection directory. All connection-relevant data must be transferred as call ar-
guments.
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
cbl-phb.fm
string SubDomain,
string PdbHost)
Using this function an indirect connection can be set up to an application via a HTS server or
HiPath Manager.
Call parameter meaning:
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
A valid connection ID must be transferred as the ConnId. This is transferred as command line
argument Args["Id"] from a connection window by HiPath 4000 Expert Access-Connect
when starting up a CBL application via "Start CBL" or via "CBL Bookmark" (see "Command line
parameters: Args" on page 71).
Alternatively, the connection currently open can be checked via Connections() Ö.
If keepopen!=0 is set, the connection remains open despite the fact that Close was called.
cbl-phb.fm
Log on to a host
string Logon( int deactAFR=0,
int discoverVariant=0,
string userid="",
string password="" )
The function Logon enables you to send the logon command to the host to which you are con-
nected.
If the parameter deactAFR is non-zero, AMO AFR is regenerated, and the ACTIVATE com-
mand is stored. AFR is then deactivated.
If parameter discoverVariant is non-zero the Hicom-Variant and Hicom-Language is de-
termined and stored into the property mml.HicomVariant and mml.HicomLanguage and
into the properties HicomVariant and HicomLanguage.
if parameter userid (for "New password concept" since Hicom EV2.0 WP3) and password
is passed to Logon, HiPath 4000 Expert Access-Connect uses these parameters for the logon
instead of using the password/userid from the connection profile or prompting with a userid/
password Dialog
If the functions fails an error message will be returned:
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
cbl-phb.fm
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
The Hosts function provides a list of all connection profiles in the form
name|Description
name|Description
The Connections function supplies a list of connections currently open in the form
P30357-B9800-B10-101 EN, 2002-10-29
ComWin / CBL Programmer’s Reference, Guide 123
2002-07-29
cbl-phb.bk Page 124 Monday, March 22, 2004 10:24 AM
cbl-phb.fm
name|connectionId|inUseFlag
name|connectionId|inUseFlag
Here, name is the connection name, connectionId is a value which can be used for the At-
tach function. The inUseFlag specifies whether an application is already connected to this
connection.
Using the GetParameters function, specific information on the connection profile whose
name is specified in host is read out. The result elements have the following meaning:
index Meaning
0 Famos password (new password concept since EV2.0)
1 Reserved
2 User ID (new password concept since EV2.0)
3 Reserved
4 Password (old password concept)
5 Reserved
6 Defined connections: sum of 1=LAN/FAMOS, 2=V.24 serial, 8=Telnet
7 Default connection (1=LAN, 2=V24, 8=Telnet)
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
ComWin ComWin
CBL Frame
Please note that the interface to CBL applications is slightly different to applications
> that connect immediate using the OLE interface. Please see module comwin.cbl to
investigate the mapping between CBL- and OLE interface.
cbl-phb.fm
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
Argument Meaning
basedir Base path for help files.
project The .chm file (compiled HTML help project) or "", if .htm files are to be di-
rectly displayed.
file The name of the HTML file included in the project or to be directly display-
ed.
topic The name of an internal cross-reference destination within the HTML file
(<a name="..."></a>) or "", if the HTML file should be displayed from
the start.
window Optional; a type of window defined, where applicable, in the help project.
If Hypertext-Help-ActiveX is installed (under Win2000/XP) in the current environment, the hy-
pertext help module is called with the following URL:
file:/<basedir>/<language>/<project>::<file>#<topic>
In addition, the window type defined in the help project (where applicable) is used for branching.
<language> is the current language ID, see "CBL - National Language Support" on page 174.
cbl-phb.fm
If a project file is not specified or HyperHelp is not installed, then the following URL is transfer-
red to the current HTML standard browser:
file:/<basedir>/<language>/<file>#<topic>
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
ComWin ComWin
CBL Frame
An architectural change caused all OLE requests from a CBL Interpreter to itself to be either
implemented in Interpreter internal functions or be redirected to HiPath 4000 Expert Access-
Frame. HiPath 4000 Expert Access-CBL is just listed here because the chosen implementation
is backward-compatible. Consequently, you may find references to HiPath 4000 Expert Access-
CBL in existing applications, but they are redirected to ComwinFrame (see CBL include file
comwin.cbl).
All methods of the predefined object system are redirected to comwinFrame.
cbl-phb.fm
ComWin ComWin
CBL FT
enum { FTProto_Local=0,
FTProto_RmxScsi=1,
FTProto_FTP=3,
FTProto_FJAM=4,
FTProto_HTS=5,
FTProto_DispaList=6,
FTProto_CORBA=10,
FTProto_TFTP };
enum { RmxFileType_ByteFile=0,
RmxFileType_Fix=1,
RmxFileType_Var=2,
RmxFileType_Dir=3,
RmxFileType_ByteFileOMF=4 };
enum { FT_Success=0,
FT_UserInterrupt=1,
FT_Aborted=2,
FT_LocalFile=3,
FT_RemoteFile=4,
FT_ConversionError=5,
FT_WrongLogon=6,
FT_TransmissionError=7,
FT_NotConnected=8,
FT_Undefined=9,
FT_NotSupported=10,
FT_TransferAborted=11,
FT_HtsError=12 };
class RmxFileInfo
{
int FileSize;
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
int FileType;
int RecordLength;
string Access;
string Date;
string APS;
};
int Connected Ö
int Visible Ö
int CloseAfterAutomation Ö
int DialogMode Ö
string LocalFile Ö
string RemoteFile Ö
void ShowBrowser() Ö
int FileUnsplit(string FileName) Ö
int FileSplit(string FileName) Ö
}
cbl-phb.fm
Set up a connection
int Connect(string Host="", string par2="", string par3="",
string par4="", string par5="",
string par6r="", string par7="", int batch=0,
string par8="", string par9="", string par10="",
string par11="")
Connect sets up the initial connection to the communication partner. Depending on which
protocol is set, appropriate arguments must be provided to establish the connection.
Host specifies the name of the respective partner.
The following overview shows the meaning of the parameters for the various protocols:
FTProto_DispaList:
Connect( <Host>, <RmxUser>, <RmxPass> );
FTProto_FJAM:
Connect( <Host>, <RmxUser>, <RmxPass>,
<TsapSrcFt>, <TsapDstFt>, <FtUser>, <FtPass>,
<batch(ignored)>, <TsapSrcFamos>, <TsapDstFamos>,
<FamosPort>);
FTProto_FTP:
Connect( <Host-IP>, <FtpUser>, <FtpPass> );
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
FTProto_HTS:
Connect( <Server-IP>, <HostName>, <Token>, <Region>, <User>,
<ConnectionId>, <DatabasePass>,
<batch(ignored)>, <DSNHtsDb>, <DSNCorrDb> , <ServerName>,
<Version>);
FTProto_Corba:
Connect( <Profile(ignored)>, <Host-IP>,
<Password(ignored)>, <Token> );
The return value indicates whether the connection was set up successfully. The return value for
a successful setup is 0.
The following return values are defined:
Value Meaning
1 Aborted by user
2 Operation aborted
3 Error on reading or creating local file
4 Error on reading or creating remote file
5 SAM - ASCII text conversion error
6 Invalid logon
7 Transmission error
8 Not connected
9 Undefined error
10 Operation not supported
11 Transmission interrupted
12 Error at HTS server
Disconnect
int Disconnect()
Disconnect clears the current connection. The return values are the same as those indicated
in the table above.
cbl-phb.fm
The function GetDir returns the contents of the remote directory Dir.
Retrieve a file
int Get(string Local, string Remote,
int ConvertSAM=0, int Batch=0, int maxlen=0)
Get can be used to initiate the transfer of a remote file Remote to the local file Local from a
remote system.
ConvertSAM specifies whether the remote file is an RMX-SAM file and is to be converted to
an ASCII text file.
Batch!=0 can be used to specify whether the transfer is to occur asynchronously (i.e. in the
background) or whether the system should wait for the result of the transfer.
maxlen can be additionally used to define if the entire file (maxlen=0) is to be transferred or
if only a maximum of maxlen characters should be received.
Send a file
int Put(string Local, string Remote,ConvertSAM=0, int Batch=0)
Put can be used to transfer the local file Local to the remote file Remote on a remote host.
ConvertSAM specifies whether the remote file is an RMX-SAM file, i.e., whether the local AS-
CII text file is to be converted during the file transfer to that format.
Batch!=0 an be used to specify whether the transfer is to occur asynchronously (i.e. in the
background) or whether the system should wait for the result of the transfer.
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
cbl-phb.fm
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
cbl-phb.fm
string Open This function sets up a connection to the server process. An error
(string host, message is output in the event of a fault. The host parameter is then
string given the host name or the IP address of the server.
port="7777")
int Id In the case of successful connection setup, Id contains a server ID
which is needed for the following objects of the types ComWinAc-
cessSession, ComWinAccessFileman, ComWinAccessDatabase
and ComWinAccessQuery.
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
int Id The Id transferred here should be used for the objects ComWinAccess-
Fileman, and ComWinAccessDatabase for their property Session to
link these objects to this session.
int Server After creating the object, the Id of a ComWinAccessServer object
should be sent.
int Authentica- The CBL applications uses this function for authentication at the Com-
te(string Sessi- WinAccess server. A valid SessionToken or a string should be sent in
onToken) the form "<user>/*::*/<password>", for example, "engr/*::*/
xxx.xxx". If the SessionToken or the UserId password combination is
invalid, then a logon dialog appears (unless DialogMode=0).
The system returns 0 in the case of correct functionality, otherwise an
error code.
int In the case of successful registration, this function can be used to call
GetFamosUser- up a valid Famos user ID and the associated Famos password for the
Pass current session.
(string @ user,
string @ pass)
string Additional SessionTokens can be generated with this function, as every
CreateSessi- SessionToken is invalid when used first.
onToken()
string This function can be used to call up server- or session-related data from
GetInfo(string the server.
item) The following items are defined:
"user_supersess" = user name of the superordinate session
"user" = user name for session registration
"password" = password for session registration
"os_user" = user name on the operating system level
"featureList" = the user-assigned features
"HomeDir" = home directory of the user on the server
"ServerType" = server type ("RM" for RM, "UW" for UnixWare)
"ServerVersion" = internal server version
int Print- This function can be used to make entries in the SessionLog.
Log(...) At present, only 0 is implemented as type.
p1 should be the name of the PBX, with which the action is performed,
p2 is a short message (30 characters), p3 is a "long" message (255 cha-
racters).
cbl-phb.fm
This description is incomplete as it should only be used via HiPath 4000 Expert Access-File
Transfer in FT_CORBA mode, see "ComWinFT (ole_class)" on page 130.
ole_class ComWinAccessFileman : "ComWinDbAccess.Fileman"
{
int Server
int Session
int GetFile(string local, string remote)
}
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
int The database whose name is specified via dsn is opened with Open-
OpenDatabase Database.
(string dsn,...) The return value is 1 if the database could be opened, otherwise it is
0 or negative, if no valid session or no database processing authori-
zation is available.
void This closes the database.
CloseDatabase()
string If an error occurs, an associated error message can be queried with
GetErrorMsg() this function.
cbl-phb.fm
string This function supplies the first hit for an SQL query in CBL streaming
GetFirst() format or a blank character string if the hit list is blank. See also the
following example.
string This function supplies the next hit or a blank character string if there
GetNext() are no more hits.
string Supplies the last error message or advisory for the current SQL que-
GetErrorMsg() ry.
PC UW7
database
query
ComWinAccessServer server;
ComWinAccessSession session;
ComWinAccessDatabase database;
ComWinAccessQuery query;
server.Open("139.21.131.146");
session.Server=server.Id;
int authresult=session.Authenticate("dummy/*::*/x");
string usr=session.GetInfo("user");
string features=session.GetInfo("featureList");
database.Server=server.Id;
database.Session=session.Id;
int openresult=database.OpenDatabase("cdb","u_dbuser","as_unity");
string error;
error=database.GetErrorMsg();
query.Server=server.Id;
query.Database=database.Id;
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
class cwdbf
{
int type;
string data;
}
cwdbf [] record;
int i;
cbl-phb.fm
void Init() This method should be called up after creating the object to initialize
the object.
int Visible Controls or specifies whether the application should run in the fore-
ground (visible) or in the background.
void This function is called up to enable the CBL Interpreter to receive
WaitForMes- events from an OLE server for a specific period of time (sec).
sages(int sec) See int _WaitUntilReleaseWait (int @ _context, int _timeout)
OnDataAvailable This is not a function, but rather an event handling routine which is
called up when error messages are received.
To run a separate code for event handling, a separate class in which
the OnDataAvailable function is declared must be derived from the
ComWinFM basic class. See also the following example.
cbl-phb.fm
CBL - Programmer’s Reference
Interfaces to the HiPath 4000 Expert AccessFrame components
}
}
myFM fm;
fm.Init();
fm.WaitForMessages(60);
cbl-phb.fm
Advanced topics
> chapter 4.4.1, "Form Layout"
> chapter 4.4.2, "The form class cblForm"
> chapter 4.4.3, "Form controls"
> chapter 4.4.4, "Definition of menus"
> chapter 4.4.5, "Form examples"
> chapter 4.4.6, "Modal dialog example"
cbl-phb.fm
CBL - Programmer’s Reference
Designing forms
In defining a layout, you have to specify size (height and width), position (top, left, col, row) and
alignment of each control (including compound controls) and form.
You start with simple controls and group them into compound controls until you have defined
the complete form.
cbl-phb.fm
int enabled=1;
int visible=1;
int showModified=1;
int isMainForm=0;
string icon;
int helpContext=0;
int @breakFlag;
void @onEnter;
void @onClose;
void @onHelp;
void Show()
int ShowModal()
void Update(int relayout=0)
void UpdateControl(cblFormControl @ctrl,
int recursive=0)
int CheckComplete()
int CheckControl(cblSyFormControl @ctrl)
void ResetModified()
void ResetModifiedControl(cblSyFormControl @ctrl)
void Get()
void GetControl(cblFormControl @ctrl,
int recursive=0)
void Close()
void FocusControl(cblFormControl @ctrl)
void SetStatus(string text)
void SetWindowState(int ws)
void StoreSizePos()
void RetrieveSizePos()
}
cbl-phb.fm
CBL - Programmer’s Reference
Designing forms
cbl-phb.fm
Show() is used to display the form for the first time (or for redrawing if the lay-
out has changed). The call will be like form1.Show();
To close the window later you have to call the Close() method. This
is usually done in response to clicking an appropriate button on the
form.
ShowModal() is used to display the form as a modal dialog. The dialog window is
closed only when a button of the form is clicked, where all of the fol-
lowing conditions are met:
● button.style==0
● button.tag greater than 0
● if an onClick event handler is defined for the button and the
event handler returns an int result, this result must not be equal
0
ShowModal() returns the int result of the event handler, if it exists,
otherwise it returns the tag value of the clicked button as result value.
You never call the Close() method to close a modal dialog.
Update is used to show the values of the designated value variables to the
(int corresponding form controls. It also updates/interprets the values of
relayout=0) the options readonly, visible and enabled. If the optional para-
meter relayout is set to 1 the form is "relayouted" and repainted com-
pletely.
UpdateControl Same as Update, but updates only the one Control that is passed as
(cblFormControl argument ctrl. Example:
@ctrl, int re- form1.UpdateControl(form1.controls["edit"]);
cursive=0) If parameter recursive is true and ctrl is a compound control, then the
nested controls are updated, too.
CheckComplete() can be called to check if all form controls where the attribute re-
quired is true(1) got a value other than "". CheckComplete()
does not check controls where the visible attribute is false.
It returns1 if the check was successful.
The attribute error is set to 1 for each required control with no value.
cbl-phb.fm
CBL - Programmer’s Reference
Designing forms
CheckControl( checks the current value of the associated value variable against the
cblsyFormCont- validation specified by items. Only valid for controls of type ctAmo-
rol @ctrl) Parameter.
The return value is:
0 = no error
1 = required parameter needs a value
2 = spaces are not allowed in individual values
3 = odd number of quotes
4 = quotation mark missing
5 = illegal individual value
6 = ranges may not be concatenated with &&
7 = too few individual values
8 = too many individual value
9 = illegal character in value
ResetModified() resets the modified attribute of all controls contained in the form
and all its subforms and internally stores the current value of each
control as the new original value of the control. This original value is
used to determine, when the modified attribute has to be set/reset
by the CBL Interpreter.
ResetModified- resets just the modified attribute of the control ctrl.
Control(cblSy-
FormControl
@ctrl)
Get() reads the values of all controls into the corresponding value variables.
The values of all controls contained in a form are read, even if they
are invisible, disabled or hidden by other controls, panels etc.
GetControl Same as Get, but reads only the value of the one Control that is
(cblFormControl passed as argument ctrl. Example:
@ctrl, int re- form1.GetControl(form1.controls["edit"]);
cursive=0) If parameter recursive is true and ctrl is a compound control, then the
values of the nested controls are read, too.
Close() is used to close the (nonmodal) window.
FocusControl can be used to give the focus to a specific form control. The control
(cblFormControl must be contained in the current form.
@ctrl)
SetStatus may be used to update the status field of a form immediately.
(string text)
cbl-phb.fm
int row;
int col;
int rowspan=1;
int colspan=1;
int left;
int top;
int width;
int height;
int align=alNone;
string caption;
string hint;
int enabled=1;
cbl-phb.fm
CBL - Programmer’s Reference
Designing forms
int readonly=0;
int required=0;
int visible=1;
int outofdate=0;
int modified=0;
int error=0;
int default=0;
int translate=1;
int supportUndo=1;
int showModified=1;
string oldValue;
int align=alNone;
int style=0;
int taborder;
int tag;
int helpContext;
void @value;
void @items;
void &onEnter;
void &onExit;
void @onChange;
void @onClick;
void @onHelp;
cblForm @panels[];
CMenu popupMenu;
}
}
cbl-phb.fm
translate (true=1, false=0) activates the automatic translation for the current control. De-
fault value is true (see "CBL - National Language Support" on page 174).
visible (true=1, false=0) defines, if the control is visible at runtime. Default is true. Avai-
lable for all controls.
modified (true=1, false=0) is set immediately by the CBL system when the user modifies
the value of a control. If the user changes the value of a control back to its ori-
ginal value, the modified attribute is reset immediately.
The modified attribute is also reset by a call to the ResetModified() method
of the form. Usually you call ResetModified() after a call to form.Get(),
when you have verified that the value of each control is acceptable and proces-
sing of the data starts. The modified attribute must not be manipulated direct-
ly by the CBL application!
The visual effect is, that a change bar appears to the left of the modified con-
trol. The color of the change bar is set in the options dialog of the CBL Interpre-
ter and is yellow by default.
outofdate (true=1, false=0) defines, if the value of a control is not current. This attribute
should be set by the CBL application, if you know that the value of a control is
out of date, but you don’t want to update it automatically, e.g. to avoid unneces-
sary data transfer to and from Hicom. Default is false.
The visual effect is, that a change bar appears to the left of the outofdate
control. The color of the change bar is set in the options dialog of the CBL In-
terpreter and is brown by default.
error (true=1, false=0) defines, if the value of the control is erroneous. This attribute
is set by the CheckComplete() method of a form, if a control which has the
required attribute set, does not contain a value. The error attribute can also
be set by the CBL-application. Default is false.
The visual effect is, that a red change bar appears to the left of the erroneous
controls (only if change bars are activated).
showModi- Activates display of a change bar for this control. Default value is true. The
fied change bar is only activated if displaying change bars for the current form is ac-
tivated.
sup- (true=1, false=0) defines whether the context-sensitive menu (right mouse key)
portUndo for this control should include the menu item "Undo".
oldValue This string is used to save the previous value (value) of a control element. ol-
dValue can be set explicitly or via the functions ResetModified or
ResetModifiedControl. In the case of the latter functions, oldValue
is set to the current value. oldValue is also the value that is entered for the
control on executing the Undo function. Furthermore, as soon as value and
oldValue differ, i.e., modified is not equal to 0, the change bar is displayed .
col column number which the control is assigned to.
row row number which the control is assigned to.
cbl-phb.fm
CBL - Programmer’s Reference
Designing forms
colspan colspan and rowspan define the width and heights of the control in grid co-
rowspan lumns/rows. Default value is 1.
left offset of the left position relative to the layout cell; in pixels.
top offset of the top position, relative to the layout cell; in pixels.
width width of the control in pixels.
height height of the control in pixels.
cbl-phb.fm
align This attribute is used to specify the alignment of a control (A) within the layout
cell or (B) within the surrounding panel/form. Alignment with the surrounding
panel/form (B) is used to define the layout of the control, when the window is
resized by the user.
All controls can be assigned to an "invisible" layout cell by setting the attributes
col and row. The width of a column of this layout grid is defined by the widest
control in this column, the height of a row of the layout grid is defined by the tal-
lest control in this row.
col=0 col=1 col=2
row=0
width left
row=1
height
row=2
top
row=3
For controls with a caption the width of the control can be computed automati-
cally by the "layouter" (e.g. Label, Button, Checkbox, Radiogroup). The height
of the control can be computed by the number of entries (e.g. Radiogoup).
For controls that can contain other controls (e.g. panel) the size of this control
is defined by the sum of the sizes of the contained controls.
The position of the control within a cell can be controlled by the value of the at-
tribute align. In this case align can be a sum of values of alHLeft (adjust
left, default), alHCenter (adjust horizontally centered), alHRight (adjust
right), alVTop (adjust top, default), alVCenter (adjust vertically centered),
alVBottom (adjust vertical bottom).
Example: align:alHCenter+alVBottom.
The size of a control within a cell can be defined by align too. To use the avai-
lable horizontal space set align to alHFill, to use the available vertical
space set align to alVFill.
Example: align: alVCenter+alHFill.
The size of a control and of the cell rows and columns is computed, when
form.Show() is called and is not recomputed, when the window containing
the controls is resized by the user!
cbl-phb.fm
CBL - Programmer’s Reference
Designing forms
h1 glue
alTop alTop h1
resize alClient
alClient
alBottom h2
alBottom h2
Controls which can contain other controls are ctPanel, ctPages and ct-
Grid.
see "Alignment to resizable panels" on page 171
cbl-phb.fm
taborder defines the order in which the controls are selected if the user moves from con-
trol to control using the tab-key. taborder is optional and should start with 1. The
default tab order is defined by the order in the controls[] array which differs
if the controls array is integer or string indexed (alphabetically sorted by the in-
dexes’ values).
You may use the same value for taborder both for a control and its associated
label. This is also useful to define a keyboard shortcut for a control: When the
user enters the keyboard shortcut of the label, the associated controls gets the
focus.
tag can be used for general purposes by the user. It is only evaluated if a Button is
clicked. Then the tag value is written into the value variable of the Button (if
available). tag also defines the result value of the function ShowModal().
helpCon- If F1 is pressed or the menu item "help" is selected from the context sensitive
text menu this value is passed to the onHelp-function of the form as argument.
value is a reference to a variable holding the value for the current control. When the
form’s Get() method is called, the current values of all controls are copied from
the form into the referenced variables. To avoid multiple write access to a vari-
able, each variable must only be referenced in one value attribute within
a form. Else the multiple write accesses to the variable would cause unpredic-
table results.
However, there is one exception to this rule: The value attribute of several but-
tons should reference the same variable! After clicking one of the buttons you
can determine which one was pressed by checking which tag value is found in
the variable referenced by the value attribute.
items is a reference to a variable holding an array of items for the current control (e.
g. items of a combo box).
onChange is a reference to a function which is called if the value of the current control is
changed.
onClick is a reference to a function which is called if the current control is clicked.
onHelp is a reference to a function which is called if the menu item "Help" is selected
from the context sensitive menu (right mouse key) of a control.
onNaviga- is a reference to a function which is called if the menu item "Go to object" is se-
te lected from the context sensitive menu of a control.
panels is an array of subforms for compound controls (e. g. page control).
cbl-phb.fm
CBL - Programmer’s Reference
Designing forms
popupMenu popupMenu allows to define a context sensitive menu for this specific control.
The onClick handlers of the menu items get the reference of the current con-
trol as first parameter. Example:
void abcClicked(CFormControl @control)
{
comWinFrame.ConsolePrint("ABC clicked");
}
onEnter is a reference to a function which is called if the current control gets the focus.
onExit is a reference to a function which is called if the current control looses the focus.
Please note that the event handling routines cannot change the value of the current control.
4.4.3.1 ctLabel
4.4.3.2 ctEdit
value string @ reference to a string variable containing the value of the edit
field
onChange function @ function which is called for every change in the edit field (each
typed character!)
style 0 standard edit field
1 edit field for password input (prompt character is * )
cbl-phb.fm
4.4.3.3 ctCombo
value string @ reference to a string variable containing the value of the combo
edit field
items string [] reference to an array of strings to be displayed in the combo
@ box
onChange function @ reference to a function which is called for every change in the
edit field (each typed character!) in the combo box.
onClick function @ reference to a function which is called before the selection dia-
log is shown when the "..."-button is clicked. This function can
prepare the items array. Only available for style=1.
style 0 standard combo box (Windows style)
1 Enhanced combo box, consists of edit field and "..."-button to
start a selection dialog. The selection dialog contains a string
grid (do not confuse this with the ctGrid control!) which is filled
with the items array. A ’|’-characters in each item separates the
columns in this string grid.
If the ’Ok’-Button is pressed the value of the first column is dis-
played in the edit field after the selection dialog is closed.
2 standard combo box (same as style=0) but without the possibi-
lity to edit a value. Only selection of predefined values is pos-
sible (drop down list).
4.4.3.4 ctMemo
4.4.3.5 ctListbox
value int @ reference to an int variable containing the index of the selected
item (or -1 if none is selected)
items string [] reference to array of strings to be displayed in the listbox
@
style 0 standard listbox (Windows style)
1 Enhanced listbox. The array of items is displayed in as a table.
’|’-characters in an item separate the columns in this table.
cbl-phb.fm
CBL - Programmer’s Reference
Designing forms
caption string used to define column headers for listbox of style 1; ignored for
listbox of style 0.
’|’-characters in caption are used to separate the column hea-
ders.
4.4.3.6 ctCheckListbox
value int [] @ reference to an int array containing the values (states) of the
CheckListbox entries.The size must be the equal to the num-
bers of items
items string [] reference to array of strings to be displayed in the checklist box
@
4.4.3.7 ctRadiogroup
value int @ reference to an int variable containing the index of the selected
item (starting with 0)
items string [] reference to array of captions of the radio buttons
@
caption string caption of the radio group (displayed in the radio group frame)
cbl-phb.fm
4.4.3.8 ctCheckbox
4.4.3.9 ctButton
4.4.3.10 ctAmoParameter
The AmoParameter control allows to define a HiPath 4000 Expert Access-MML-Editor styled
control. All information about the AMO parameter is stored in the object that is passed to item.
This object can be easily retrieved from HiPath 4000 Expert Access-MML-Editor using the me-
thod getParamValidation(string param).
Example:
amoParam gerkon;
...
comedit.command="EINR-SCSU;";
gerkon=comedit.getParamValidation("GERKON");
cbl-phb.fm
CBL - Programmer’s Reference
Designing forms
4.4.3.11 ctBitmap
4.4.3.12 ctPanel
4.4.3.13 ctPages
cbl-phb.fm
panels cblForm[] array of forms which should be displayed in the different tab
sheets. The caption of the tab sheet is the caption of the "sub-
form".
4.4.3.14 ctGrid
Grid controls are the most complex controls which can be defined on the GUI of CBL applica-
tions. The following example should show the usage of a grid control.
include "form.cbl"
class cblGridItem
{
string caption;
string value;
string items[];
}
class gridItemCls
{
cblGridItem A_edit1;
cblGridItem B_combo1;
cblGridItem C_button1;
}
cbl-phb.fm
CBL - Programmer’s Reference
Designing forms
gridItemCls gridItems[];
gridItems={ { A_edit1:{value:"edit1"},
B_combo1:{value:"combo",items:{"v1","v2","v3"}},
C_button1:{caption:"b1"} },
{ A_edit1:{value:"l2"},
B_combo1:{value:"c2"},
C_button1:{caption:"b2"} },
{ A_edit1:{value:"e3"},
B_combo1:{value:"c3",items:{"a1","a2","a3"}},
C_button1:{caption:"b3"} },
{ A_edit1:{value:"e4"},
B_combo1:{value:"c4"},
C_button1:{caption:"b4"} }
};
class helloCls
{
int gridLine;
cblForm form1;
int x;
void get()
{
form1.Get();
}
void update()
cbl-phb.fm
{
form1.Update();
}
void ButtonClicked()
{
form1.Get();
string line;
line=gridLine;
gridItems[gridLine].A_edit1.value="Line "+line;
form1.Update();
}
void init()
{
form1 = { caption:"Grid Test Form",
controls:
{ "grid1":
{ type : ctGrid,
width :300, height:90,
items : gridItems,
value : gridLine,
panels: {{ controls:
{ "A_edit1": { type: ctEdit,
caption:"feld1" },
"B_combo1": { type: ctCombo,
caption:"feld2" },
"C_button1":{ type: ctButton, value:x,
caption:"action", onClick:ButtonClicked }
}
cbl-phb.fm
CBL - Programmer’s Reference
Designing forms
}}
},
"but1": { type:ctButton, row:1, caption:"Get",
onClick:get },
"but2": { type:ctButton, row:1, left:150,
caption:"Update", onClick:update }
}
};
form1.Show();
}
}
helloCls hello;
hello.init();
cbl-phb.fm
caption string is the text displayed as menu item and as hint for the speed but-
ton.
onClick function @ is the function to be called if the current menu item is clicked.
submenu cblMenu is the submenu of a menu item.
enabled 0=false, defines if the current menu item can be selected or not. Default
1=true is true.
left int defines the horizontal distance to the previous speedbutton in
pixel. Default is 0.
bitmap string defines the file path to the bitmap which is to be used for dis-
playing the speedbutton.
class cblMenu
{
cblMenuItem items[];
}
class cblMenuItem
{
string caption;
void @onClick;
CMenu submenu; // for menu only
int enabled=1;
int visible=1;
int left; // for speedbar only
string bitmap; // for speedbar only
}
cbl-phb.fm
CBL - Programmer’s Reference
Designing forms
include "form.cbl"
class myWindow
{
CForm form1;
CForm subform1;
CForm subform2;
CForm subform3;
cbl-phb.fm
cbl-phb.fm
CBL - Programmer’s Reference
Designing forms
The "tagged" expression list has been used for initialization of the controls array
> of the form. If we do so, the controls array gets string indexed. Then we can access
(and modify) each control element by it’s name, e.g. for activation of a button:
form1.controls["button1"].enabled=1;
include "form.cbl"
class myWindow
{
CForm form1;
CForm header;
CForm body;
CForm footer;
void init()
{
header={ controls: { { type:ctLabel, caption:"header area" },
{ type:ctEdit, col:1 } } };
body= { controls: { { type:ctLabel, caption:"body area" } } };
footer={ controls: { { type:ctLabel, caption:"footer" },
{ type:ctButton, col:1, caption:"Button"} } };
form1= { caption: "Form-Example 2",
controls: { "panel1":{ type: ctPanel, align:alTop, panels: { header } },
"panel2":{ type: ctPanel, align:alClient, panels: { body } },
"panel3":{ type: ctPanel, align:alBottom, panels: { footer } }
}
};
form1.Show();
}
}
myWindow window;
window.init();
cbl-phb.fm
cbl-phb.fm
CBL - Programmer’s Reference
Designing forms
cbl-phb.fm
Advanced topics
> chapter 4.5.1, "CBL-intrinsic text tables"
> chapter 4.5.2, "NLS texts from H.O.T."
cbl-phb.fm
CBL - Programmer’s Reference
CBL - National Language Support
If there is no value ("") defined as translation in the current language column, the tag value is
used instead.
The translation table can be accessed by purpose using the interpreter defined functions
"TranslateIn(string text)" and "TranslateOut(string text)".
Example: (Language=en)
TranslateOut("Anzeigen") returns "Show",
TranslateIn("Modify") returns "Ändern".
This list shows the abbreviations for the languages as supported in the current release of Hi-
Path 4000 Expert Access:
german de english en
spanish es dutch nl
french fr finnish fi
danish da portuguese pt
korean kr
cbl-phb.fm
5.1 Preface
CBL is a special language which has been created to provide more possibilities to automate
the commands or create the application rather than using only the batch command line to con-
trol the Hicom switch.
This "Step-by-Step to CBL" will be the introduction to some basic ideas in CBL programming to
get start to program CBL with the basic knowledge and to be able to understand the CBL pro-
gramming reference later on for creating the sophisticated program on demands.
cbl-phb.fm
Introduction into CBL Programming
Preface
myprogram.cbl Result
------------ ------------
------------ Interpreter ------------
------------ ------------
To start programming, we need to have an editor to write the code on. It works the same way
as programmers who write Basic can use Visual Basic editor or Java use Jbuilder editor. Re-
cently, CBL can be written on a very simple tool such as Notepad in Microsoft Windows oper-
ating system or any other kinds of editors. The CBL Interpreter and the HiPath 4000 Expert Ac-
cess-GuiBuilder also has an built-in editor.
Currently ".cbl" files are associated with notepad by HiPath 4000 Expert Access installation.
3. That's all the code you have. Next, save it by pick the name of your file as you like but do
not forget to put the extension file as ".cbl"
4. Now you have created the cbl file. To run it, first open the HiPath 4000 Expert Access CBL
Interpreter. The interpreter "HiPath 4000 Expert Access - CBL Interpreter" looks like the
picture below.
cbl-phb.fm
Current program
5. Load your cbl file into the interpreter by click Open icon (the first icon on the left) or select
open in the menu File. Then you will have the file loaded. When the file is loaded the CBL
syntax is checked.
Remark: The signature is automatically created after the file is loaded by the CBL inter-
preter. Currently it has no special function except it represents some internal checksum. In
files you create you may remove the line but CBL interpreter will try to recreate it again. For
the execution of the program it has no effect.
6. To run the program, press "Run" icon (the third button) in the menu bar. The code will be
interpreted and the result will be generated. In this case, the word "Hello world!" will be
shown in the HiPath 4000 Expert Access-Frame console window which will also be auto-
matically popped up with the result inside.
7. In case you want to edit the source code, it can be done both by press the notepad icon on
the menu bar while the code is loaded or open the code file in Notepad in the normal way.
After the code is edited, it must be saved first. Then load it in the interpreter again or if it
was saved in the same name, just reload it by pressing "Reset the program" (4th icon in
the menu bar) and run it again by pressing "Run program" button.
cbl-phb.fm
Introduction into CBL Programming
Data types, variables and operators
After grabing the way to deal with the interpreter and the editor, we will go into more details in
CBL language. Data types, program structure, and the more advance examples will be presen-
ted in the following chapters
cbl-phb.fm
Display the result of the calculation by having the lines below. For the syntax, in case of text
output, put the text in "...", and if it is a variable, put it without "...".
Like in the last example, the result will be shown in HiPath 4000 Expert Access - Frame - Con-
sole. The calculation of this program will come out with 73 Euro with all the texts as shown be-
low.
cbl-phb.fm
Introduction into CBL Programming
Data types, variables and operators
If you have some errors instead, check the spelling first. Then if you still cannot get it, may be
you forgot the " ; " at the end of the statements. Everybody will have simple errors at the begin-
ning, so you donot have to worry about it. When you have more experience, errors will become
less and you will enjoy programming.
These two lines are for string assignment. We assign the text to the variable a and b.
a = "Hello world!!";
b = "Today is Friday, Yeah!";
For the variable c, we assign it’s text to have text a, text b and more additional sentence. We
can do it by using (+) operation which will concatenate the string in the variable a, b and the
string c together. So the new text which will be assigned to c will be "Hello world!!" + " Today is
Friday, Yeah!" + "Let’s go out..."
c = a + b + "Let's go out...";
This comming last line in the program will print out the string in variable c.
cbl-phb.fm
comwinFrame.ConsolePrint(c);
For other operations of string, e.g. "in" operation can be used to check whether the specific
text is a part of another text or not. As stated in the sample code below.
string text1;
...
if ("no" in text1)
{subtask1}
...
From the program, if there is the text "no" occured inside the text in variable text1, subtask1 will
be executed. Another usecase of "in" operation will be with String still have many other useful
operations which can be found in the handbook for referencing.
cbl-phb.fm
Introduction into CBL Programming
Data types, variables and operators
As from the diagram, the locations are store in the array of station which in this case "limited
size array". There are two types of array, classified by the size. This first one is limited size array
which programmer has to specify the size in the array declaration.
string day[7];
The variable "day" is a set of strings that contains only 7 of items as decleared. But in the case
of unlimited size array, the array’s items will not be limited. With this way studentname array can
be added up unlimited as the example.
string studentname[];
The next important topic involved with array is indexing. As from the set structure of array, it has
many items in the list. Thus, when the items need to be accessed, they need the indicators to
identify themself which item are they. Each item in the list has its own identity idication which is
an index. From the first example diagram, you can see the 10 stations which are having num-
bers from 0-9 in the bracket. Index numbers always start from 0, so 10 stations have index num-
ber 0-9. In the code, if you want to change the location of station 1 from Munich to Leipzig, Sta-
tion 1 can be reached by mention Station[0].
station[0] = "Leipzig";
Type of the array just mentioned is Integer indexed array which is widely used in many langua-
ges.
In CBL, there is still one more type named string indexed array. This type, as the name, use
string to be the index instead of integer which sometimes make more sense to do this way. For
example, the case of employee’s extension numbers, we can represent those data easily by
using this way.
int[] x;
x["Erich"] = 52142;
x["Bernd"] = 56984;
x["Robert"] = 54632;
x["Emil"] = 58963;
...
So we can just use names as the indices to access each item in array. For instance, to display
the telephone extension of Erich can be done directly by using indexed name and display the
value.
comwinFrame.ConsolePrint(x["Erich"]);
The string indexed array has also the integer index set which mapped from the string indices,
ordered alphanumerical. Thus, it can also be accessed like in the normal integer index array by
mention the integer index. From in the telephone extension above, we can order the indexed
name respectively as Bernd, Emil, Erich and Robert.
cbl-phb.fm
For initializing value in array, in the integer indexed type can be initialized as follow,
string setstring[] = {"Erich","Robert","Bernd"};
int setnumber[] = {1,2,3,4};
On the other hand, the string indexed type can be initialized this way.
int extensionset[] = {"Bernd":56984,"Erich":52142,"Emil":58963}
Remark: Only items that exist in the array can be accessed, otherwise the interpreter will give
a warning message. For example, a couple lines of code below declear an array which has two
items.
int item[];
item[0] = 32;
item[1] = 16;
comwinFrame.ConsolePrint(item[2]);
Although item[2] is not yet defined the above statement will work. If an array element of an in-
teger indexed array is accessed that is not yet defined a new element with the default value (for
integer this is 0) will be created automatically.
int[] x;
x["Erich"] = 52142;
x["Bernd"] = 56984;#
comwinFrame.ConsolePrint(x[2]);
comwinFrame.ConsolePrint(x["James"]);
The access with x[2] result in an error message because of range violation (only elements 0 til
1 defined) but with x["James"] interpreter will print the result of 0, represent the default value of
item which is not exist (in case of item data type is string, it will show no character.)
cbl-phb.fm
Introduction into CBL Programming
Data types, variables and operators
5.2.1.4 Variables
After data types, we have been using variables already in many examples. Now this will be ex-
plained more in details. Start from the answer of the question "What is a variable?" It is ob-
vious that "variable" is not a new word. At least people knew it from Mathematics. Infact, con-
cept of variable in both fields are basically comparable. In the definition, a variable is a symbol
or a name that represent its data value. In programming, having variable is providing more fle-
xibility to have dynamic changing of data. A variable provide another alternative by assigned
the value in real time rather than using only fix value in the program.
The definition might look a bit complicated but a variable can be simply explained as the place
used to store the value which can be changed over time. For example, a mobile phone has
some memory to store the phone number. You can put your friend’s name and telephone num-
bers and they will be stored in the memory. Over time, a friend "John" moves to another city, so
you get his new number then you can replace the new number within the same name. The old
number which is stored in "John" changed to a new one. This is happened with computer me-
mory and variable which its value can be changed overtime. We can make use of the this fea-
ture. Without it computer programming will not be considered of a very useful innovation.
To use variables, we need to provide the name of the variable and also the data type of the va-
riable. These two are called identifier and type identifier.
Identifiers are also case sensitive e.g. the variable named a and A are treated as the different
variable.
cbl-phb.fm
5.2.1.7 Declaration
Declaration is one of programming statements. It is important to start using variables. Compiler
/ Interpreter will be informed about the variable from the declaration. It will allocate the memory
space to the variables according to their data type.
A variable can be decleared in two ways. First , it can be decleared as the constant value. This
case is useful when the program used many times a constant number. Thus, when you want to
change this constant value, it is easier to change only one time the value of the variable instead
of tracking all the codes to change line by line. Second, variable is decleared as a dynamic va-
lue variable which we have seen already.
The syntax of the first case of constant variable starts with keyword "const" then followed with
the type identifier then the identifier and assigned value, e.g.
const int montly_payment = 13;
Another case of normal variable, syntax would start with the type identifier then follows with the
identifier.
In case of array, the declaring variable’s name has to be follow by brackets. As seen in the last
topic of array, it has two different methods to difine which are limited size array (with the upper
bound) and unlimited size array (without limited bound). It has two different types of access
which are string indexed and integer indexed. Interpreter will allocation the memory space to
array only when a new array element is accessed but not when it is defined. Therefore, acces-
sing an element which is not yet created causes an empty element.
cbl-phb.fm
Introduction into CBL Programming
Data types, variables and operators
int book[];
int student[10];
string test[];
string text[3];
Scope of variables:
The next question might be "where can I put the declaration statement?".Variables can be de-
cleared in 4 different places which are :
● inside blocks (every sequence of statemens that are enclosed by curly braces { } , e. g. in-
side or outside of a function)
● in the definition of function parameters
● inside class, but outside of functions
● globally: outside of all classes and functions
Variables stated in the different places also have different functions which are local variables,
formal parameters, member variables, and global variables respectively.
Global variables and local variables have some differences. The global variable decleared out-
side the function and it can be accessed through out the entire program but the local one can
just used only inside the local scope which it has been declared to used in. For example, gMax
is a global variable and it can be used even inside the function add but the variable sum can be
used only inside function block that it was decleared in.
In HiPath 4000 Expert Access - CBL - interpreter, there is a feature called data inspector which
allowed you to trace the value of all variables including the scope information so that you can
also see the global and local variable scope. To use data inspector, click an icon on the menu
bar (the third one from the right). It will open the data inspector window(the window witht the
cbl-phb.fm
title"Current symbols"). Like in the picture below, at the break point in function add, there are
an amount of variables active at that moment. In the window, it shows values of interesting 4
variables which has underlined.
5.2.2 Operators
After got some ideas about the variables, then what can we do with them? To manipulate vari-
ables we need operators. In previous topics in this chapter, we have seen some operators for
fulfilling explanation of data types, e.g. some arithematic operators: plus (+), minus(-) which are
arithmetic operators or assignment operators but there are still more useful operators in CBL
language. Operators can be classified into many types and have different functionalities. Here
CBL operations will be explained according to type of the operations.
cbl-phb.fm
Introduction into CBL Programming
Data types, variables and operators
For example, if there is a person name "John" in the Hicom switch, read his extension number
and output it on the screen. So if computer finds "John" in the switch the condition will become
"true" and computer will proceed the task of reading and showing John’s extension number.
Otherwise, it will not do any task. That ’s why boolean operators are very useful.
In CBL, there are two boolean operators given: logical and, logical or. Besides logical operators
there are still be bitwise operators which are also using somehow the same logic to apply with
operands. From now each operation will be explained one by one.
Example:
We have 3 expressions to consider.
1. "John needs a mobile phone"
2. 2. "John has enough money"
3. 3. Will John buy a mobile phone?
So for the AND operation, if expression 1 and 2 is true that John needs a mobile phone and
also has enough money, he will buy a mobile phone. Those sentenses can be represent
using "&&" as a symbol for AND operation.
JohnWillBuy = (John has enough money)&&(John needs a mobile phone)
With AND, if any of the expression is false, it will result in false. So in these cases of :
● John has not enough money but he needs a mobile phone. He will not buy it.
● John has enough money but he does not need a mobile phone. He will not buy it.
● John has not enough money. He does not need a mobile phone. He will not buy it.
The only case that made John buy a mobile is both are true.
Thus, the logic of AND operation can be present as in table.
cbl-phb.fm
Logical OR : (||)
OR operation use the operator symbol, ||. It works in the similar way like AND operator but
the only different is the logic.
Example:
The given 3 expressions are:
1. "The bin is full."
2. "Today is Saturday."
3. Jim will throw away garbages?
The expression will be
ThrowGarbages = (The bin is full) || (Today is Saturday)
From this expression, Jim will throw away garbages in condition if the bin is full or it is Sa-
turday. For any of the true input expression will cause the true result. But the fault case will
be only if both inputs are false. The bin is not full and today is not Saturday. So Jim will not
throw away garbages.
You can also see from the logic table of OR
cbl-phb.fm
Introduction into CBL Programming
Data types, variables and operators
result = operant1&operand2;
comwinFrame.ConsolePrint(result);
The bit representation of the operand 1,2 will become like showing below and also the result.
Bitwise OR ( | )
The way of proceeding in this operation is the same as bitwise AND but just change the logic
applied with two operands. In OR operation if any of the compared bits have 1 then the result
will become 1, the only case that will cause 0 in result is when both compared bit are 0,0.
cbl-phb.fm
Bitwise XOR ( ^ )
The logic of XOR is not the same as AND, OR. It take two base two values to compare then if
they are the same, the result will be 0 but if they are different, the result will be 1. All possibilities
in XOR logic can be shown below.
As always, the interpreter will interpret integer and take it as binary to do the operation which
can be shown in the table below.
cbl-phb.fm
Introduction into CBL Programming
Data types, variables and operators
0 ^ 1 = 1
1 ^ 1 = 0
1 ^ 0 = 1
0 ^ 0 = 0
cbl-phb.fm
y = 10;
text = "hello!";
comwinFrame.ConsolePrint(x);
You can see the assignment expressions in the example, e.g. the line of x =, y = but what does
it mean? The process of assigning is very simple as it takes value of the expression on the right-
hand-side and assign it to be the value of the variable in the left-hand-side. So x will have 0 as
its value, y will have 10, text will become "hello!".
Assigning integer value at the declaration statement, we can put "=" followed by integer num-
ber. With the string, we use the same "=" but follow with the string in double quotes sign, such
as:
int a = 5;
string text = "Hello world";
There are also other operators in this assignment group which are very useful and make the
command shorter. Assume that you want the codes below:
int x;
int a;
x = x+a;
You can write the code in another way around by using the operator += like this:
x +=a;
This line means the operator takes the value on the left-hand-side and add with the value on
the right-hand-side then assign to the variable to the left-hand-side. In this case, the value of x
will be taken and add by the value of a then assign it to the variable x;
There are some more operators with the arithematic operators mixed with the assignment ope-
rators and it works in the same way as +=. They are all including +=, -=, *=, /=, %= . They will
do the same method but change only the arithmetic operators.
Those expressions are correct or not? You might think, they are all wrong. Some will say they
are all type mismatching. Although it is quite strange to have the string assign to the integer
variable and also on the other way around with integer value assign to string variable but in
cbl-phb.fm
Introduction into CBL Programming
Data types, variables and operators
CBL, it is allowed to do so. But why and how? It is just an implicit way to convert the data to be
in the type of the variable. Because of the data from Hicom switch (both numbers and text) nor-
mally comes in text form. So if you want to manipulate the data which is in text format e.g. you
have "12345" and you want to do some arithmetic operations with it. You have to change it to
interger somehow. Then it can be applied by the operators. And also on another way around to
change the integer to string to send to Hicom switch.
Example:
int aNum;
aNum = "254";
From the codes above, the string "254" is converted to be integer and then assigned to aNum.
string sTxt;
sTxt = 245;
As in the same way, the integer 245 will be converted into string "245"
But what will happen in these following cases.
int a = "test";
int b = "12 34";
int c = "58p";
In case the text assigned to an integer variable cannot be converted to number like the case
variable a, it will just assign value 0 to a. But in case of b, the text has two groups of numbers
seperated with the space. So this case it will take the first value of the text which is 12. For the
c case, the string will be converted to 58 because it cut out the character "p" behind.
Thus, besides the normal way to use assignment operators, it can also be used for type con-
version purpose. This machanism also works in another way not really at the declaration part,
eg:
string y;
int x;
x = "123";
y = 123;
Those lines can result also in the same implicit type conversion.
cbl-phb.fm
Thus, the easier way is using parenthesis to specify the order of operations yourself.
cbl-phb.fm
Introduction into CBL Programming
Statement and Expression
5.3.1 Expression
We have seen already many expressions in the last chapter. So what is exactly an expression?
An expression is as simple as it contains one or more operations which represent by operators.
The expression in the simplest way can be only the variable or number or string value such as:
MonthlyPayment
123
"Hello!"
Besides the expression with one operator, if it has more then one operator, it will be called com-
pound expression. In order to deal with the execution of many operators, it has to determine
the precedence of each operators it has, e.g :
3/5-2
6 / 3 | 5 + 2
The operators in the expression can be any of the operators mentioned in chaptor 2 , e.g. arith-
matic operators, boolean operators, bitwise operators and etc.
cbl-phb.fm
Start
go to the bank
Yes
Buy a mobile
End
cbl-phb.fm
Introduction into CBL Programming
Statement and Expression
From John’s example, saving money is a routine job which can be assigned as a function.
This saveMoney function has an input parameter which is the amount of money to save.
Then the saving amount will be added up with the old balance in the bank account then
return the new balance as an integer value.
int v;
v = 30;
x = v + v/2;
}
This example shows how to use the none-return function. This function will not return any value
but only proceed the tasks in the function. So when the function myFunction is called the x
equation will be calculated and the x value will be assigned.
5.3.2.2 If - statement
The "if - statement" is a conditional statement which allows you to write the condition and to
control the program to execute some codes due to the conditions. So if the if-expression is con-
sidered to be true (can be anything except 0) then the corresponding code block will be execut-
ed. Otherwise the block of else will be executed.
Example: If-else
x = 8;
if (x > 5)
{
x = x * 10;
}
else
{
cbl-phb.fm
x = x * 20;
}
In this example, first, x is assigned to be 8. Then it is checked in the expression (x >5) which
become true. Thus, the block next to the expression (x = x* 10) is executed. On the other hand,
in case the value of x makes the expression become false(in case x<5), the block after else (x
= x*20 ) will be executed.
If you want to make the conditions more complex, you can use the boolean operators, such as,
and (&&), or (||) , not (!) and if you have more than one condition you can use else-if expres-
sion which will be checked one after the other if the previous condition is false.
Example: if - else if
int income;
int tax;
if (income < 500)
{
tax = 0;
}
elseif ((income >= 500) && (income < 1000))
{
tax = income * 10/100;
}
elseif ((income >= 1000) && (income < 2000))
{
tax = income * 12/100;
}
else
{
tax = income * 15/100;
}
This example shows the simple process of tax calculation which the tax will be calculated from
the income level. The income will be checked whether which level it is in from the first if-expres-
sion and go to the next elseif (if the condition is false) until the program found the range that the
income is in. Then it will calculate the tax with the percentage of that income level.
cbl-phb.fm
Introduction into CBL Programming
Statement and Expression
pose of 3 expression after "for" which will define the initial value of loop control variable, a rela-
tional expression that determines when the loop exists, and the condition that defines how the
loop control variable changing in each round.
This for-loop will increase the value of saving variable in each time the loop is repeated. The
loop start with a control variable x assigned to 0 then increasing by one as from the last expres-
sion in the parenthesis. It will be repeated until the value of x cannot meet the condition x<10
in the second expression.
The initialization part can be omitted if the initialization of the variable has been executed before
the for-statement.
int x = 1;
for ( ;x<10;x++)
{
comwinFrame.ConsolePrint(x);
}
But if all of the expressions in for-loop are empty, it means the loop will run forever. The code
in the block will be executed again and again.
for ( ;; )
{
comwinFrame.ConsolePrint("I’m running forever");
}
However, there is a break-statement which can terminate the loop from inside the block:
int x;
for (;;)
{
x++;
if (x>10)
cbl-phb.fm
break;
}
The syntax in pascal style using "for... to" and it is ended with "do " and the code block in the
bracket. In this example, the loop will be repeated 100 times and show the text as the codes in
the bracket will be repeated.
This example is using the first style of while-statement. The block code will be executed only if
the condition x < 10 is true. Then the program will increase the value of saving variable and
print out the result.
cbl-phb.fm
Introduction into CBL Programming
Object and Class
This program will first run through the code block after do and then check the while expression
whether the condition is true or not. If the x <10 is true, then the code block will be repeated
otherwise the loop will be ended.
cbl-phb.fm
Adress book
Create
Functions Delete
Edit
The figure above shows the adress book as an object with the data attributes which is called
Member data (Attribute in CBL) and the functions that applied with this object, called Member
functions. Member data can be compared with the normal variables which explained before but
it is different from the normal variables in the way of accessibility. Member data cannot be ac-
cessed everywhere like the global variable but can only be accessed internally by the object.
Member functions also work in the same way as member data. It can be called only by referen-
cing to the object.
cbl-phb.fm
Introduction into CBL Programming
Object and Class
Create Create
Delete Delete
Edit Edit
Adress book object Instance of Adress book object
This record is an instance of the address book. Each instance has its own internal data stored
and it’s own accessible functions. Every instance has the same pattern. It contains the same
data members and the same functions from the template object.
5.4.3 Class
A template or the block that used to create the instances is actually called a class in program-
ming language. As mentioned from Data type chapter that besides the primitive data types, the-
re is another kind of data types. It is called complex data type which can be created on demand
by using class representation. For instance, the address book can be assigned as a complex
data type. Thus, the address book type will contain data members, e.g. record number, name,
address and etc which can be assigned with primitive types: record number can be integer; na-
me, address, city can be string. Besides the attributes, the address book type will contain also
the funcitons for manipulating instances. The functions; delete and edit; are also needed to be
inside the class.
cbl-phb.fm
{
comwinFrame.consolePrint(name
+"’s telephone number is "+telephone);
}
void delete() {/*..delete a specific record..*/}
void edit() {/*..edit the record..*/}
}
Like any other statements, class also has some syntax in CBL. The syntax looks not so new
because it consists of known statements which can be either funciton statements or decleara-
tion statements. As in the example, the syntax of the class declaration start with the word class
then the class name and the declaration of attributes and funciton members in the a curly bra-
cket.
In order to use the class, you have to make the instance out of it then use the instance. The
syntax of instantiation is as simple as declare a variable. On the other hand, you can take the
class as a data type then assign it to a variable. For instance:
void main()
{
address_book john;
john.name = "John smith";
john.telephone = "089-123456";
.
.
.
john.displayPhone();
}
This case the data members are initialized outside the class but it can be done also in the class
so that the new instance will have the default value from right after it is created.
class point
{ int x = 0;
int y = 0;
int z = 0;
}
point p1;
comwinFrame.consoldPrint(p1.x);
comwinFrame.consoldPrint(p1.y);
comwinFrame.consoldPrint(p1.z);
cbl-phb.fm
Introduction into CBL Programming
Object and Class
In this class, the class represent point in 3 dimensional coordinate system which eash point in
x,y,z axis has been initialized to 0. Thus, all points that are created from this class will have x,y,z
value of 0 as the default value.
The member function of classes is like the normal function. It can be both with the input para-
meters or not. In the last example of address book, there are only funcitons without parameters.
The syntax of member functions exactly the same as the normal function as the functions wit-
hout parameters will start with void and the name of the function then function’s statements in-
side curly bracket. Here is another example of
class person
{
string name;
int age;
string sex;
void incrementAge()
{ age++;
comwinFrame.consolePrint("Now the age is");
comwinFrame.consolePrint(age);
}
}
If we create a person from this class, this person will have the function incrementAge which can
be call without any parameters. Here is some codes of that show the way to call this function.
person john;
john.name = "John Smith";
john.age = 25;
john.incrementAge();
The same way as using the attributes of the instance, to call a function (also called method in
this context)function, we need to mention the instance first. Thus, if we declared the instance
name "john" as a person, the attributes and functions inside can be refered by using the in-
stance name and a dot then follow with the specific attribute or function. Calling functions just
have a bit different compared with the attributes that it needs to have the parenthesis after func-
tions’ name. If a the member function has parameters, it is called needed to have the name of
parameters inside as shown in the function is followed by a parenthesis. example below.
If the member function has parameters, it is needed to have the parameters inside as shown in
the example below.
class person
{
string name;
int age;
cbl-phb.fm
string sex;
int incrementAge(int y)
{ age = age + y;
return age;
}
}
Now in this example, the incrementAge function has a parameter which is the amount of year
to be incremented to the current age. The function ’s type is not void but it is assigned to the
type of return value which in this case "age" variable ’s type. So when you call this function, it
will automatically output the age variable after the process inside the function, for instance:
person john;
person jim;
int different;
john.age = 25;
jim.age = 20;
different = john.age-jim.age; // now the different will be 5.
john.age = jim.incrementAge(4);// But John& Jim is now 24.
The last expression assigns the return value of Jim’s incremented age to John’s age. So Jim’s
age will become 20+4 and then assigned to John’s age.
cbl-phb.fm
Introduction into CBL Programming
Programming with GUI-Builder
Button Memo
Start CBL
Save Check
Label box
Open Form Cursor Pages
editor Combo box
Radio group
Edit Panel
Object Gernerate
Inspector code AMO List box
Parameter Bitmap
Checklist box
Source code editor
GUI builder helps you to create your interface easily by providing menu bar to create forms, but-
tons, edit boxes. You can easily put the mouse curser on the icon to see each icon’s description.
cbl-phb.fm
cbl-phb.fm
Introduction into CBL Programming
Programming with GUI-Builder
2. Coming to the programming part, once again, the goal is to calculate the broadcasting
address and the subnet ID in every change of each field in IP or Netmask. So we need all
the input edit boxes has to provide some be put the code for each event handler for on the
onChange event of the input fields.
If you select the first IP box, there will be the Events part on the bottom of object inspector.
Double click in the onChange box, a function will be created. Then you have to put the code
inside each function.
3. For the code, 8 funcitons are more or less using the same algorithm. The only minor points
are changed. This part of the code will look like this.
void Show()
{
init();
MainForm.Show();
}
// Function editIp1OnChange()
void editIp1OnChange()
{
MainForm.Get();
editBroadcast1Value=_string( _int(editIp1Value)
| (0xff ^ _int(editNetmask1Value)) );
editSubnetId1Value =_string( _int(editIp1Value) & _int(editNetmask1Value) );
MainForm.Update();
cbl-phb.fm
// Function editIp2OnChange()
void editIp2OnChange()
{
MainForm.Get();
editBroadcast2Value=_string( _int(editIp2Value)
| (0xff ^ _int(editNetmask2Value)) );
editSubnetId2Value =_string( _int(editIp2Value) & _int(editNetmask2Value) );
MainForm.Update();
}
// Function editIp3OnChange()
void editIp3OnChange()
{
MainForm.Get();
editBroadcast3Value=_string( _int(editIp3Value)
| (0xff ^ _int(editNetmask3Value)) );
editSubnetId3Value =_string( _int(editIp3Value) & _int(editNetmask3Value) );
MainForm.Update();
}
// Function editIp4OnChange()
void editIp4OnChange()
{
MainForm.Get();
editBroadcast4Value=_string( _int(editIp4Value)
| (0xff ^ _int(editNetmask4Value)) );
editSubnetId4Value =_string( _int(editIp4Value) & _int(editNetmask4Value) );
MainForm.Update();
}
Similar to the changes of the IP address input fields the onChange event handlers for the net-
mask inpuf fields needs to be provided:
// Function editNetmask1OnChange()
void editNetmask1OnChange()
{
MainForm.Get();
editBroadcast1Value=_string( _int(editIp1Value)
| (0xff ^ _int(editNetmask1Value)) );
editSubnetId1Value =_string( _int(editIp1Value) & _int(editNetmask1Value) );
MainForm.Update();
}
cbl-phb.fm
Introduction into CBL Programming
Programming with GUI-Builder
// Function editNetmask2OnChange()
void editNetmask2OnChange()
{
MainForm.Get();
editBroadcast2Value=_string( _int(editIp2Value)
| (0xff ^ _int(editNetmask2Value)) );
editSubnetId2Value =_string( _int(editIp2Value) & _int(editNetmask2Value) );
MainForm.Update();
}
// Function editNetmask3OnChange()
void editNetmask3OnChange()
{
MainForm.Get();
editBroadcast3Value=_string( _int(editIp3Value)
| (0xff ^ _int(editNetmask3Value)) );
editSubnetId3Value =_string( _int(editIp3Value) & _int(editNetmask3Value) );
MainForm.Update();
}
// Function editNetmask4OnChange()
void editNetmask4OnChange()
{
MainForm.Get();
editBroadcast4Value=_string( _int(editIp4Value)
| (0xff ^ _int(editNetmask4Value)) );
editSubnetId4Value =_string( _int(editIp4Value) & _int(editNetmask4Value) );
MainForm.Update();
}
4. Then the program can be run by clicking the "Start CBL" button on the menu bar. It will ask
you to save the project first then it will be run.
cbl-phb.fm
include "OpenConnDlg.cbl"
if (conn.show())
{
// Now we can send the first command to Hicom.
// Therefor the function Send of the predefined object named "comwin"
// is called.
// return value of this function is the complete AMO result of the
// passed command.
cbl-phb.fm
Introduction into CBL Programming
HiPath 4000 Expert Access Interoperation
string result;
string [] cmds;
int i;
comedit.HicomCommand=cmds[i];
// From comedit we can get every value of the different parameters.
// And we can send this value e. g. into the ComWin-Connect
// protocol window.
comwin.Print(comedit.getParam("TLNNU")
+ " --> "
+ comedit.getParam("LAGE")
+ "\n" );
cbl-phb.fm
} // for
result=comwin.Send("REGEN-SBCSU;");
cmds=sys.prepare_regen_results(result);
for i=0 to cmds.count-1 do
{
comedit.HicomCommand=cmds[i];
comwin.Print(comedit.getParam("TLNNU")
+ " --> "
+ comedit.getParam("LAGE")
+ "\n" );
}
}
oi_SIX.fm
oi_SIX.fm
oi_SIX.fm
oi_SIX.fm
oi_SIX.fm
M Operator + 41
MacroRunning (ComWin-Connect) 114 operator ++ 13
mainmenu (cblForm) 149 operator += 13
match_regex (sys) 76 Operator = 43
memo control 160 operator -= 13
menu 168 Operator in 42
Message (ComWin-Connect) 114 Operators 188
MessageBeep (sys) 77 operators *= 13
MessageDialog (cbl_dialogs) 94 OR 190, 191
Modal dialog example 173 outofdate (cblFormControl) 154
modified (cblFormControl) 154
P
N panel 163
namespace 19 panels (cblFormControl) 158
namespace (keyword) 50 param_intervals (sys) 77
National Language Support 174 param_ivals (sys) 77
NewLine (ComWin-Connect) 114 ParamCount (Comedit) 97
NLS 174 parse_amo_errors (sys) 77
Noun (Comedit) 97 parse_amo_result (sys) 77
null (keyword) 50 ParseAmoResult (Comedit) 98
ParseUrl (sys) 78
O Password (ComWin-PPP) 136
Object and Class 203 PhoneNumber (ComWin-PPP) 136
oldValue (cblFormControl) 154 popupMenu (cblFormControl) 159
ole_class (keyword) 50 PPP-Manager 136
onChange (cblFormControl) 158 precedence 196
onClick (cblFormControl) 158 prepare_regen_results (sys) 77
onClose (cblForm) 149 Print (ComWin-Connect) 114
OnDataAvailable (ComWin-FM) 144 PrintLog (ComWinAccessSession) 138
onEnter (cblForm) 149 Profile (ComWin-PPP) 136
onHelp (cblForm) 149 program 10
onHelp (cblFormControl) 158 Put (ComWin-FT) 131
onNavigate (cblFormControl) 158
open (cblFile) 90 R
Open (cblIniFile) 92 radio buttons 161
open (cblXmlFile) 95 radio group 161
open (cblZipFile) 93 RasConnError (ComWin-PPP) 136
Open (ComWinAccessServer) 138 RasConnState (ComWin-PPP) 136
Open (ComWin-Connect) 114 RasStatusString (ComWin-PPP) 136
OpenDatabase (ComWinAccessDatabase) read (cblFile) 90
140 read (cblXmlFile) 95
OpenDialog (cbl_dialogs) 93 ReadInteger (cblIniFile) 92
OpenDirect (ComWin-Connect) 114 readln (cblFile) 90
Operator - 42 readonly (cblFormControl) 153
ReadString (cblIniFile) 92
P30357-B9800-B10-101 EN, 2002-10-29
ComWin 300 / CBL Programmer’s Reference, Guide Index-5
2002-07-29
cbl-phb.bk Page 6 Monday, March 22, 2004 10:24 AM
oi_SIX.fm
oi_SIX.fm
T W
taborder (cblFormControl) 158 Wait (interpreter functions) 72
tag (cblFormControl) 158 WaitForMessages (ComWin-FM) 144
text tables 174 while - statement 202
text_table (keyword) 51 while (keyword) 51
text_table statement 16 while statement 32
TextHeight (interpreter functions) 72 width (cblFormControl) 155
TextWidth (interpreter functions) 72 WindowState (ComWin-Connect) 114
this (keyword) 51 with (keyword) 51
throw (keyword) 51 with statement 35
throw statement 34 write (cblFile) 90
to (keyword) 51 write (cblXmlFile) 95
tolower (sys) 76 WriteInteger (cblIniFile) 92
top (cblFormControl) 155 WriteString (cblIniFile) 92
toupper (sys) 76
TracePrint (interpreter functions) 73 X
translate (cblFormControl) 154 XOR 191
TranslateIn (interpreter functions) 72 XSD 64
TranslateOut (interpreter functions) 72
trim (sys) 76
try (keyword) 51
try_catch statement 34
type (cblFormControl) 153
type identifier 185
type-identifier 45
U
unzip (cblZipFile) 93
Update (cblForm) 150
UpdateControl (cblForm) 150
User (ComWin-PPP) 136
V
value (cblFormControl) 158
Variables 185
variant (keyword) 51
Verb (Comedit) 97
virtual (keyword) 51
visible (cblForm) 149
visible (cblFormControl) 154
Visible (ComWin-FM) 144
Visible (ComWin-FT) 131
Visible(ComWin-PPP) 136
void (keyword) 51
oi_SIX.fm