You are on page 1of 31

Technical Quiz

1. Explain the difference between DOW and DOU
Ans: In Case of Dow the condition is checked first and then the loop is
executed, in case of Dou the loop is executed at atleast once and then
the condition is checked . There is a possibility that the loop is not
executed even once but in case of Dou the loop is definetly executed at
least once.
2. What is a librar list and h!w can it be chan"ed#
Ans: Library list is a list of libraries that is iven to each !ob when
it is started , we can chane the library list usin so"e CL co""ands
#DTLI$L , C%&LI$L , C%&C'(LI$,C%&)*)LI$L,C%&')(LI$L.
$. What is Q%&% librar and what is it used f!r #
Ans: +)*) is the syste" library that contains so"e of the syste" defined
ob!ects and will also contain Authori,ation list .
'. (n a displa file) what d! displa attributes *() +*)+, and -(
Ans: (I - (everse I"ae
.( - .rotected
.C - .osition Cursor
%I - %ih Intensity
/. what is the difference between ,-A(0 and %TE11#
Ans: )etll sets the pointer to the lower li"it of the key field
specified in factor / and does not read the record.
Chain - 0ill )et the pointer on the specified key field in factor / and
reads the record
2. What is QTE3+ and h!w is it created#
Ans : +T#1. is a syste"s library specified in the user part of the
library list that will contain user data and is created auto"atically
the "o"ent an interactive !ob starts
4. -!w .an files can !u declare in a ,1 pr!"ra.#
Ans: 2ne
5. What d! !u use t! 3O03%6 c!..and in ,1 pr!"ra.s f!r #
Ans: T2 trap run ti"e error "essaes in a CL prora"
7. What are data 8ueues#
Ans: Data +ueues are ob!ects that are used for prora" to prora"
19.What are DD3 files#
Ans: Data Distributed 1anae"ent files
11.(f an *+6 pr!"ra. fre8uentl reads the sa.e s.all set !f rec!rds fr!.
a file) h!w can the efficienc !f the pr!"ra. be!:ed#
Ans: *ou can load the records into a run ti"e array and then process the
run ti"e array fro" within the prora"
12. what is the difference between *ET*0 with 1* indicat!r set !n and
*ET*0 with 1* set !ff#
Ans: (eturn will !ust return the control to the callin prora". 0ithout
closin or initiali,in the local variables or will not clear the
"e"ory. 0here as L( will close all file and initiali,e all local
variables and clear the "e"ory used by that prora"
)ettin on L( 3Last (ecord4 will close files and free resources occupy
by the prora". Initiali,ation will occur on the next call to the
prora". 5ot settin on L( 3in 2.1 prora"s4 will keep the prora" in
"e"ory, keeps file open and pointers set, retains variable values, and
prevents the 6I57)( fro" bein executed the next ti"e the prora" is
called, as well as I57 specified in your D8specs. As a rule, I never
seton L( when a prora" will be called "ultiple ti"es. This rule "ost
definitely applied to a trier prora" that could be called hundreds or
possibly thousands of ti"es.
/9. -!w w!uld !u debu" a ;!b in batch#
Ans: )ervice :ob
/;. -!w w!uld !u a ;!b t! batch fr!. an *+6 pr!"ra.#
Ans: +C1D#<C
1/. What are the <+%%* and <(0=%* subr!utines#
Ans: 6.))( is a prora" status subroutine that is executed
auto"atically if there an error in the prora" or a file and if for
this file specification there a 6.))( defined in the file
specification 6I57)( is an initiali,e subroutine that is executed
auto"atically whenever this prora" is called .
/=. What is the difference between ,1EA* and *E%ET#
Ans: Clear will clear the variables and (eset will reset the
variables to the initial value.
/>.-!w and when is c! c!ntr!l used#
Ans: Co""it"ent control is used to co""it the chanes "ade to the
records of a file fro" the last rollback or co""it. ?or co""it"ent
control !our"allin is "andatory and the file in the prora" should
be opened under co""it"ent control
/>. A pr!"ra. writes t! a data 8ueue. (f !u wish t! see the c!ntent !f
the data 8ueue) what c!..and w!uld !u use# Ans: +(C@DTA+
15. What is a shared OD+ and h!w and when w!uld !u use it#
Ans: ?or a file if you want to share the open data path in different
prora"s within a !ob then you will override the database file in a
shared "ode that is )%A(#36*#)4.
17.What A+(s ha:e !u used# Ans: +C1D#<C,+(C@DTA+,+)5DDTA+.
29.What is (1E and h!w d!es it differ fr!. O+3#
Ans: IL# - Interated Lanuae #nv. 8 In 2.1 the bindin is done at the
run ti"e. In IL# the bindin is done at co"pilation ti"e.
22.(n an (1E en:ir!n.ent) what is the difference between *,1*%, and
Ans: If a user8na"ed activation roup is left in the !ob, you can delete
it by usin the (eclai" Activation &roup 3(CLACT&(.4 co""and. This
co""and allows you to delete na"ed activation roups after your
application has returned. 2nly activation roups that are not in use can
be deleted with this co""and. While The (CL()C co""and "ay be used
to close the files based on a particular call8level nu"ber passed to
that co""and.
2$.(n (1E) what is the .axi.u. nu.ber !f arra ele.ents in an arra#
Ans : AAAA
2'.What is the >uilt (n ?uncti!n @EQUA1 used f!r#
Ans: 0ith a )#TLL state"ent if you ive an indicator under eBual
colu"n then that indicator is set on if an eBual "atch is found in
the file , instead of usin an indicator in (.& I@ after setll we can
check for an eBual "atch usin C#Bual $I?
2/.Which (1E !perati!n c!de is the e8ui:alent !f the 3OAE !perati!n
c!de# Ans: #val
22.What is the difference between subr!utine and pr!cedure#
Ans: .rocedures can be called across different "odules but a
subroutine can only be called within a "odule or prora"
24.What is special ab!ut %T*,3T,T1 and OA*D>? in an (1E en:ir!n.ent#
Ans: )T(C1TCTL and 2@(D$? can be specified for all the prora"s
within an activation roup
25.Which character is used t! define an indicat!r tpe :ariable#
Ans : D5E
27.Which tpe !f pr!"ra. is b!und b reference#
Ans: )ervice .rora"s
$9.I a" havin an assin"ent in which it is asked to display specific
pae of subfile. e.. I a" currently on /Fth pae of subfile, now if I
wants to display Gnd pae directly..... %ow should I doA
(iht now I have taken a InputH2utput field in control record for"at, to
specify the pae to be displayd. %ow should I use this value to display
specific pae on L2AD ALL subfile.Is )?L(CD5$( or )?LC)(((5 usuful in
this caseA 2r any other, it is urent. If possible try to
elaborate your concept with an exa"ple...
Ans :If your )?L.A& I /F, Gnd pae should start on //th record. 1ove
this nu"ber to )?L(CD5$( and #<?1T aain.
$1.h!w d! !u access all .e.bers in pf# : 0(J1$(.D1
$2. -!w d! use the new ?ile >uiltBin ?uncti!ns#
Ans : 2)H;FF @ersion ;, (elease G (.& I@ supports the eli"ination of the
(esultin Indicators. In their place, several new built8in functions
have been introduced. 1ost of these new built8in function provide
infor"ation about the result of ?ile operations si"ilar to the (esult
indicators. $ut instead of codin (esultin indicator 9, for exa"ple, to
check for the end8of8file condition, you si"ply check the value of the
C#2? built8in function.
The built8in functions that replace the (esultin Indicators include:
C?2'5D, C#2?, C#+'AL. In addition, there are C2.#5, C)TAT'), and C#((2(.
1ysteriously "issin is CL2CJ to check for a record lock condition.
@?OU0D : returns an 625 or 62?? condition if the previous ?ile
operation returns a record8found condition. This is particularly useful
on the C%AI5 operation. (eali,e, however, that when C%AI5 sets on
(esultin indicator /, a not8found condition is sinaled. 0hereas,
without codin (esultin Indicator /, the C?2'5D built8in function
returns the found condition.
@EO? : can be used to check for end8of file, beinnin of file,
or subfile full conditions. A (#AD and (#AD# return C#2?I625 if the end
of file is reached. (#AD. and (#AD.# return C#2?I625 if the beinnin of
file is reached. The W*(TE operation returns C#2?I625 if the 0(IT#
operation to a subfile detail record returned a subfile8full condition.
@EQUA1 : is used by the )#TLL operation to indicate that it
detected a record in the file with a key eBual to that of the value
specified in ?actor /. )ince )#TLL does not read the record, does not
lock the record, and does not copy the data into the input buffer, )#TLL
is "uch faster and less of an i"pact on the perfor"ance of the
application than other operations, such as C%AI5. 'se C%AI5 when you
need to retrieve the record, use )#TLL and C#+'AL when you need to only
check for the existence of a record.
@O+E0 : is used to check to see if a file has already been
opened. The built8in function returns 625 if the file is opened,
otherwise it returns 62??.
$$. What is the new E !perati!n extender used f!r#
Ans :The new 3#4 operation extender is used to cause the C#((2( and
C)TAT') built8in functions to be initiali,ed after an operation is
perfor"ed. That is, these built8in functions and the # operation
extender are used in place of (esultin Indicator G on all operation
codes that currently support (esultin Indicator G as an error
?or exa"ple, to check to see if a record is locked, you would code the
C Cust52 ,hain3#4 Cust1ast
C if C#((2( I 625
C )elect
C 0hen C)TAT') I /GG/
C exsr 'pdate5o(ead
C 0hen C)TAT') I /G/L
C exsr (ecdLocked
C end)L
C #L)#
C if C?2'5D3 Cust1ast 4
C exsr whatever...
C endif
C endif
The concept is to first check C#((2( for a enerali,ed error condition,
and then check C)TAT') for the specific error. 5ote that no resultin
indicators are used in the previous exa"ple. The nor"al not-found
condition is checked usin the C?2'5D built8in function rather than
testin (esultin Indicator /.
$'. What "!!d are the @T*(3) @T*(31 and @T*(3* builtBin functi!ns#
Ans : The use of the T(I1 functions is very li"ited, in that they
support only the use of character variables and data structures. 5u"eric
fields, and ,ero8fill values are not supported. They do, however,
provide so"e useful function for strin handlin. ?or exa"ple, in (.&
I@, one line of code is all thatMs needed to left8ad!ust a value within
a field. ?or exa"ple:
, Ex?.t ,ust3aint
, E:al ,ust0a.eC@Tri.1D,ust0a.eE
Typically, the CT(I1 function is the only one of the three that et
used. The other two, however, do have their place.
CT(I1 re"oves trailin and leadin blanks fro" a field, and returns the
re"ainin value, in place, within the expression. The returned value is
treated si"ilar to a constant value with leadin or trailin blanks.
CT(I1L re"oves leadin blanks 3tri"8left4 fro" a field, and returns the
value in place, within the expression.
CT(I1( re"oves trailin blanks 3tri"8riht4 fro" a field, and returns
the value in place, within the expression.
The table below illustrates the "echanics of the T(I1 functions.
2riinal @alue (eturned @alue
CT(I13co"pna"e4 M The I$1 Corp. M MThe I$1 Corp.M
CT(I1L3co"pna"e4 M The I$1 Corp. M MThe I$1 Corp. M
CT(I1(3co"pna"e4 M The I$1 Corp. M M The I$1 Corp.M
It would be wonderful if the T(I1x functions also supported a second
para"eter that indicated the character to be tri""ed. It could default
to blanks, but would accept any value. The internal 1I instruction T(I1L
actually does this already, but T(I1L and T(I1( do not directly "ap to
this 1I instruction. In addition, it would be even nicer if the second
para"eter supported "ultiple characters. That is you would be able to
specify CT(I1(3Co"p5a"e : M .M4 and it would strip off blanks and
periods fro" the end of the C21.5A1# field. 88 Drea"er...
9N.0hy doesnMt the CC%A( built8in function work with nu"eric valuesA
Ans :The CC%A( built8in function was introduced. %owever, the function,
as desined, only converted DAT# values to character values. This proved
to be too restrictive a use for this function. In 2)H;FF @;(; I$1 will
added function to CC%A( allowin it to convert all for"s of non8
character data to character. In that release CC%A( works with nu"eric
D A"ount >+ G In,3/G9.;N4
C #val text I MThe a"ount is: M K
CChar3 a"ount 4
The T#<T field would contain the followin after the #@AL operation is
MThe a"ount is: /G9.;NM
'nlike C#DITC, the CC%A( built8in function tri"s off leadin blanks.
%owever, C#DITC provides "uch "ore editin power than CC%A(. 'se CC%A(
for basic nu"ber to character conversion.
9=. 0hatMs the difference between C%AI5 and )#TLLA Is there a
perfor"ance advantaeA
Ans :
$4. -!w .an can we !pen file in pr!"ra.# h!w .an rec!rds can be
str!ed when E specif <n!.ax#
Ans : I hope you pass this Bui,:
/4 2@(D$? ?IL#3<<<<4 T2?IL#3<<<<<4 1$(36ALL4
G4 'se ')(2.5 and you can open and close it as often as you want
94 0ith the 6no"ax option, you can store 6no"ax records.
$5. %ow "any )ubfile are availableA what are difference between the"
Ans : %ubfile:
• you have to write a prora" and create a display file to enerate
• There are basically T02 types of subfiles:
1E Expandin" 2E %in"le +a"e.
#xpandin is further divided into T02 types:
• /./4 Load All
• /.G4 .ae by .ae.
/4 Expandin": 0hen )?L)I7 O )?L.A&, it is called as expandin subfile.
i.e. )ubfile si,e increases auto"atically as we add records. e..
)?L)I7IGF and if you add /FF records, syste" extends subfile si,e for
all /FF records.
1.1E 1!ad All: In this type of subfile difference between )L?)I7 and
)?L.A& is lare. ?or exa"ple )?L)I7I/FFF and )?L.A&I/F. In this type,
prora" adds as "any records as possible in the subfile 3ideally all
records. $ut re"e"ber the "axi"u" si,e of a subfile is only PPPP4.
Therefore this subfile is usually used for s"all nu"ber of records.
Advantae: 5aviation throuh the subfile is fast. Disadvantae: Ti"e
reBuired to load the subfile is lare.
1.2E +a"e b pa"e: In this type of subfile we enerally keep difference
between )?L)I7 and )?L.A& is /. ?or exa"ple )?L)I7I// and )?L.A&I/F. 30e
can keep )?L)I7 lare but it should not be #+'AL to )?L.A&4 That "eans
prora" loads / pae of records initially. And then as we press .ae
Down key, it loads next pae of records and so on 30ithout deletin
previously loaded records4. Therefore in this type of subfile we have to
write code for .ae Down key to load / pae of records. Aain subfile
si,e restriction is there and therefore we use this subfile also for
s"all nu"ber of records. Advantae: 5aviation throuh the subfile is
slow. Disadvantae: Ti"e reBuired to load the subfile is less.
2E%in"le +a"e: In this type of subfile, )?L)I7 I )?L.A&. That is subfile
is non8expandin. In this type, every ti"e we press .ae Down or .ae 'p
prora" clears subfile and load next or previous pae of records.
Therefore we have to write code for both .ae Down and .ae 'p keys. As
at any "o"ent this subfile contains only records eBual to )?L.A& and
therefore this subfile can be used for lare nu"ber of records.
%ubfile 1inFs :
$7. what is the difference in s!urce file and s!urce .e.berr#
Ans : A )ource .hysical ?ile contains the source for the various ob!ects
created. This file has a specific structure.A .hysical ?ile contains
data, and the record for"at can be different for different physical
)ource file is an ob!ect over A)H;FF but source "e"ber is !ust a source
code of (.&,D).?,.(T?... and )ource file used for containin sources
"e"ber3s4 ?or #xa"ple ,)ource file na"e :+(.&)(C is used for containin
source "e"ber 3source code4 of (.&
'9. -!w d! debu" a re.!te Di.e. GbatchGE ;!b fr!. an interacti:e ;!b#
Ans :The ability to debu another !ob has been a lon standin
reBuire"ent for A)H;FF, now i)eries prora""ers. It isnMt as difficult
as it "ay see". 0hether you need to debu a batch !ob, another
interactive !ob, or an %TT. server !ob 3browserHC&I prora"4, the
followin steps can et you started.
%tartin" Debu" f!r a *e.!te H!b
/. Deter"ine the !ob na"e of nu"ber for the !ob you need to debu.
• 'se 0(JACT:2$ and note the :ob na"e, nu"ber and user profile
• If debuin a C&I prora", look in the !oblo of the !ob
for C.? "essae %T.GFF/.
G. (un the )tart )ervice :ob 3)T()(@:2$4 co""and specifyin the !ob
to be debued
• e.., )T()(@:2$ :2$3F/G9;NHusridH!obna"e4
9. (un )tart Debu 3)T(D$&4 on the prora" to be debued
• e.., )T(D$& .&13libna"Hp"na"e4 '.D.(2D36*#) Q 6524
;. At this point the prora" in the re"ote !ob is under debu control
fro" your !ob
• *ou can now set break points 3if youMre debuin an (.& I@
prora", the source will have already been displayed4.
• .ress ?/G fro" within the debuer to return to C1D entry
after settin your break points.
N. #voke the prora" in the re"ote !ob. If you youMre doin a web
browser session, hit the )'$1IT button.
=. *ou interactive !ob will RbreakR at the debu break points and you
can debu application nor"ally.
Endin" Debu" f!r a *e.!te H!b
#ndin the debu session should be done in the followin seBuence.
/. ?ro" your debuin session, run the #nd Debu 3#5DD$&4 co""and
G. Then run the 3#nd )ervice :ob4 #5D)(@:2$ co""and
*our session is no loner controllin the re"ote !ob. The re"ote !ob
continues nor"ally.
%pecial ,!nsiderati!ns when Debu""in" a Web >r!wserI,6( +r!"ra.
To debu a C&I prora" that is evoked fro" a 0eb $rowser session runnin
fro" the standard I$1 %TT. 0eb )erver, you need to do the followin in
addition to the above.
>ef!re %tartin" Debu" f!r a Web >r!wserI,6( %essi!nI+r!"ra.
• #nd the %TT. )erver usin the followin CL co""and:
• #5DTC.)@( 6%TT.
• 0A(5I5&SSS 88 *ou 1')T include 6%TT. as the para"eter for
#5DTC.)@( otherwise all TC.HI. server !obs 3includin
telnet, ftp, s"tp, etc.4 will be ended. And this is a bad
thin. I$1 sucks for "akin 6ALL the default for #5DTC.)@(.
• (estart the %TT. )erver usin the followin CL co""and:
• )T(TC.)@( 6%TT. %TT.)@(3D#?A'LT M8"inat / 8"axat /M4
• This restarts the %TT. server with once instance of each !ob
type 3one for C&I, one for :ava, etc.4
• 'sin 0(JACT:2$ in the +%TT.)@( subsyste" location the !obs
• The !ob whose !oblo contains the C.? "essae %T.GFF/ is the one
to be debued.
After ?inishin the Debu )ession
• #nd the %TT. server usin the followin CL co""and:
• #5DTC.)@( 6%TT.
• (estart the %TT. server usin the followin CL co""and, unless
your shop has another process for startin the %TT. server:
• )T(TC.)@( 6%TT.
*our syste" should be back to nor"al.
'1. .ls so"ebody tell "e how to find that weather there is data in .? in
CL without definin file in CLA Also how to 1aintain access path without
usin the opnBryf or Loical file or e"bedded sBl
Ans : 0ithout definin... file in CL, (unBry H D).?D co""and... can be
executed in CL p" or D)..?1 to check... whether data is present in .?
or not. *ou can use (T@1$(D in CL and find the nu"ber of records in the
file "e"ber
'2. 0hile Loadin )'$?IL# IM" ettin session and device error, what is
the reson and solutionA
Ans : If you are ettin "essae... in !ob lo as : Incorrect relative
record nu"ber or field selection error. Then "ay be chances... are there
that you "ust not have declared... the keyword
M)fileM i.e %fileDsubfile rcdf.t na.e : **0E while declarin... your
display file in ?8specs. If so then one can et... session or device
'$.Is there any function in (.&L# that takes a strin as para"eter and
returns its lenth
Ans :
/. The lenth of a fieldMs content is CL#53CT(I1(3?I#LD44
G. Lenth of field 8 CLen3?ield4 and Lenth of contents of strin 8
''. In "y pro!ect i enerated a report 3Invoice .rintin4. the )heet is
.re8printed. i a" takin the printout in dot .rinter. when i feed the
paper into the printer it allins at the top . when printin starts it
leaves two lines and starts printin i had iven the )JI.$3/4 in this
record for"at. any one know how to "ake the printer to print at the
Ans : the proble" could be connected to the type of printer 3"odel,
type, etc4. 1any printers have a feed function that "ove ahead the paper
to "ake easier to keep the fold. An other proble" can be the ?(25T1&5
para"eter in the .rinter file. $ut itMs strane that you have do this
without know it :84 *ou can do a test: prepare an other prtinter file
with a line of characters on the first line, and not use the skip or
spaceb state"ents. In this way the print starts on the first line
avalaible. If the printer "ove for two lines the proble" is the printer,
if not the proble" is the prtf
'/.Is there any way to rena"e only one field in a file in (.& without
usin any prefix A
Ans :
I(#C2(DT5A1# I ?I#LD (5A1#T?LD DonMt look at the positions, arenMt
Anothe way:
D "yds # D) #xt5a"e3"y?ile4
D 1y5a"e # #xt?ld3?ile?ield5a"e4
D D)
D ?ile?ield5a"e
D 1y5a"e Like3?ile?ield5a"e4 2verlay3?ile?ield5a"e4
'2. I need so"e info. about settin up A);FF. 0hat hardware I will
need A 0here can I et info. A
Ans : I$1 has several books that you can download.
)tart hereU
'4. I want to type in a letter in word processor and attach data fro"
A)H;FF at the end of this letter and send to "y users. Is there a way to
open a word docu"ent in (.& or CL .I can tranfer this docu"ent back to
A)H;FF usin ftp, but openin it is a bi proble" for "e.
Ans : 0hat about the co""and )T(.CC1D A 0ith this co""and you can open a
0ord docu"ent.
'5. #xecute CL ans (.& prora"s fro" a excell "acro Is this possibleA
Ans : you can use a @$A "acro usin an AD2D$ connection for this issue.
The followin "acro holds an 2'T+.
?or exa"ple:
.rivate )ub %old$uttonTClick34
Di" xy As 2b!ect )et xy I Create2b!ect3RAD2D$.ConnectionR4
xy..rovider I RI$1DA;FFR
xy..roperties3Rdata sourceR4 I RyourI)#(I#)syste"na"eR
xy.2pen xy.#xecute RVVhldoutB outB3Bprint4WWR, , adC"dText If 5ot xy Is
5othin Then xy.Close )et xy I 5othin 1s$ox 3R2'T+ +.(I5T set to
#nd )ub
*etrie:e Database %!urce
The (etrieve Database )ource 3(T@D$)(C4 co""and retrieves the
infor"ation fro" an existin physical or loical file and writes to a
DD) "e"ber.
The typical co""and is *TAD>%*, ?IL#31*LI$H1*?IL#4 T2)(C31*LI$H+DD))(C4
This will extract the infor"ation fro" the na"ed file and creates a new
"e"ber 3or updates an existin "e"ber4 into the specified source file.
Co""ents oriinally entered in the source "e"ber will be lost. The field
reference 3and reference file4 is not be retrieved by this tool. 1ulti8
for"at files are retrieved as Rclosed asR possible but not a uarantee
that all infor"ation are retrieved. The tool does not support ?ield
(easons to use this tool
?iles were created usin )eBuel and no source "e"ber existed.
*ou lost your DD) source.
3e.ber Tpe %!urce ?ile
C(T(T@D$ CL. +CL)(C
(T@D$)(C C1D +C1D)(C
(T@D$/ CLL# +CLL#)(C
(T@D$G (.&L# +(.&L#)(C
Copy the individual "e"ber to the desinated source file in your
library. Take note that (.&L#)(C has a lenth of //G and the rest
of the source uses the default PG lenth.
Create the C(T(T@D$ prora":
C(TCL.&1 .&132b!libHC(T(T@D$4 )(C?IL#3)rclibH+CL)(C4
Add the 2b!lib in your library list.
Call the C(T(T@D$ prora" to create the utility.
CALL C(T(T@D$ .A(13M2b!libM M)rclibM4
H6 .rora""ers &roup X 1anae"ent (esource Copyriht /PPL 6H H6 6H
H6 3 o o 4 6H
6H H6 6H
H6)yste" na"e . . . : Technical )upport 6H
H6 Co""and na"e . . . : (T@D$)(C 6H
H6 Text . . . . . . . : (etrieve Database )ource 6H
H6 6H
H6 Author . . . . . . : Alex 5ubla 6H
H6 Description. . . . : (etrieves the source for an existin 6H
H6 file into a source "e"ber. 6H H6
H6 Co""and para"eters: 6H
H6 6H
H6 ALL20336ALL4 6H
H6 6H
H6 C..: (T@D$/ 6H
6H H6888888888888888888888888888888888888888888888888888888888888888888
c"d 3M(etrieve Database )ourceM4
H6 88888888888888888888888888888888888888888888 6H
H6 ?ile 6H
H6 88888888888888888888888888888888888888888888 6H
par" file Bfile K "in3/4 K pro"pt3M?ileM4 Bfile: K Bual 6na"e /F K
expr36yes4 Bual 6na"e /F K dft36libl4 K spcval36libl 6curlib4 K
expr36yes4 K pro"pt3MLibraryM4
H6 88888888888888888888888888888888888888888888 6H
H6 To source file 6H
H6 88888888888888888888888888888888888888888888 6H
par" tosrc Bsrcfile K "in3/4 K pro"pt3MTo source fileM4 Bsrcfile: K Bual
6na"e /F K expr36yes4 Bual 6na"e /F K dft36libl4 K spcval36libl 6curlib4
K expr36yes4 K pro"pt3MLibraryM4
H6 88888888888888888888888888888888888888888888 6H
H6 To "e"ber 6H
H6 88888888888888888888888888888888888888888888 6H
par" to"br 6na"e /F K dft36file4 K spcval36file4 K expr36yes4 K
pro"pt3MTo "e"berM4
H6 88888888888888888888888888888888888888888888 6H
H6 (eplace "e"ber if it exist. 6H
H6 88888888888888888888888888888888888888888888 6H
par" "bropt 6char L K rstd36yes4 K dft36replace4 K values36replace 6add4
K choice3M6(#.LAC#, 6ADDM4 K pro"pt3M(eplace or add recordsM4 T
6H H6 .rora""ers &roup X 1anae"ent (esource Copyriht /PPL 6H H6 6H
3 o o 4
6H H6888888888888888888888888o2288883T4888822o8888888888888888888888888
6H H6 6H H6 )yste" na"e . . . : .rora""er Tool 6H
H6 .rora" na"e . . . : C(T(T@D$ 6H
H6 Text . . . . . . . : Create (T@D$)(C 6H
H6 Author . . . . . . : Alexander 5ubla 6H
H6 Description. . . . : .rora" to create (T@D$)(C utility 6H
H6 6H
H6 1ove the followin "e"ber to the X)rclib 6H
H6 /. (T@D$)(C +C1D)(C 6H
H6 G. (T@D$/ +CLL#)(C 6H
H6 9. (T@D$G +(.&L#)(C 6H
H6 1odification Lo: 6H
H6 6H
H6 Date Task .rora""erHDescription 6H
H6 FNH9FHP> Alex 5ubla 6H
H6 Created 6H
3X2b!lib H6 2b!ect library 6H K X)rclib 4
H6 )ource library 6H
H6 declaration 6H
dcl X2b!lib 6char /F dcl X)rclib 6char /F crtcl"od
"odule3X2b!libH(T@D$/4 K srcfile3X)rclibH+CLL#)(C4 crtrp"od
"odule3X2b!libH(T@D$G4 K srcfile3X)rclibH+(.&L#)(C4 crtp"
p"3X2b!libH(T@D$/4 K
"odule3X2b!libH(T@D$/ X2b!libH(T@D$G4 crtc"d c"d3X2b!libH(T@D$)(C4 K
srcfile3X)rclibH+C1D)(C4 K p"3(T@D$/4
D!cu.ent Title
(.& )ubfile That Loads )ubfile 2ne .ae at a Ti"e
D!cu.ent Descripti!n
The followin exa"ple is an (.& prora" that loads the subfile one pae
at a ti"e. As the user presses the .ae Down key, it loads additional
paes into the subfile.
Displa ?ile:
A .(I5T
A C?F93F94
A %#L.
A6 %#AD#( (#C2(D T2 $# AT T2. 2? DI).LA*
A ( %#AD#(
A 2@#(LA*
A G 9M%#AD#(M
A G >FDAT# #DT0(D3M H H M4
A 9 >FTI1# #DT0(D3M : : M4
A6 )'$?IL# (#C2(D
A ( )?
A )?L
A 7I. N 2 L /G
A C')T GF 2 L GL
A 5A1# GF 2 L N9
A6 )'$?IL# C25T(2L (#C2(D
A ( )CTL )?LCTL3)?4
A 2@#(LA*
A )?L)I73FL4
A )?L.A&3F>4
A (2LL'.3PF4
A 9/ )?LD).
A 9G )?LD).CTL
A 99 )?L#5D
A 9; )?LCL(
A 9N )?LI57
A 0D.2) ;) F% )?L(CD5$(
A ; /GM)'$?IL# C25T(2LM
A = /GM7I.M
A > /GM88888M
A = GLMC')T21#(M
A > GLM88888888888888888888M
A = N9M5A1#M
A > N9M88888888888888888888M
A6 0(IT# I? )'$?IL# I) #1.T*
A ( #1.T*
A 2@#(LA*
A L /GMT%# )'$?IL# I) #1.T*M
A6 ?22T#( (#C2(D T2 $# 0(ITT#5 AT T%# $2TT21 2? T%# DI).LA*
A ( ?22T#(
A 2@#(LA*
A G9 9M?22T#(M
Database ?ile %!urce:
( ?1T/
7I. NA
5A1# GFA
*+6 %!urce:
?T#)T.? I? # DI)J
?25#.&)?LC? # 02(J)T5
? ((5 J)?IL# )?
C 78ADDF ((5 ;F
6 CL#A( )?L
C 12@#AMFFF/M 6I5,9/
C 12@#AMF/FFM 6I5,9/
6 L2AD ?I()T .A&# 2? DATA I5T2 )'$?IL#.
C #<)( L2AD
6 C%#CJ T2 )## I? )'$?IL# %A) A5* (#C2(D).
6 I? T%#(# A(# (#C2(D) T%#5 )#T 25 T%# )?LD). I5DICAT2(.
6 I? T%#(# A(# 52T A5* (#C2(D I5 T%# )'$?IL# T%#5 0(IT#
6 T%# #1.T* (#C2(D ?2(1AT.
C ((5 I?&T F
C )#T25 9/
C #L)#
C 0(IT##1.T*
C #5D
6 0(IT# #@#(*T%I5& T2 T%# DI).LA*.
C 6I5F9 D20#+MFM
C 0(IT#%#AD#(
C 0(IT#?22T#(
6 .2)ITI25 T%# )'$?IL# T2 T%# .A&# T%AT C25TAI5) (#LATI@#
6 (#C2(D 5'1$#( /.
C #<?1T)CTL
C 6I5PF I?#+ M/M
C 6I5F9 A5D#+MFM
C 6I5LF I?#+ MFM
C #<)( L2AD
C6 #L)#
C6 I))'# A5 #((2( T%AT *2' A(# AL(#AD*
C6 AT T%# $2TT21 2? T%# )'$?IL#. ')# T%#
C6 1#))A&# )'$?IL# #<A1.L#, )?L1)&, 2(
C6 )?L1)&ID.
C #5DI?
C #5DI?
C #5DD2
C 12@# M/M 6I5L(
6 L2AD )'$?IL#
6 T%I) .(2&(A1 L2AD) T%# )'$?IL# 25# .A&# AT A TI1#.
C L2AD $#&)(
C (#AD ?1T/ LF
C 6I5LF D20#+MFM
C C2'5T A5DL#=
C ADD / ((5
C ADD / C2'5T
C 0(IT#)?
C C2'5T I?L# =
C (#AD ?1T/ LF
C #5D
C #5DD2
C 78ADD((5 0D.2)
C 6I5LF I?#+ M/M
C )#T25 99
C #5D
C #5D)(
Tips J ?acts
'$. I would like to know difference between
/4 6Loval and 6)tart
G4 6%ival and 6#nd
Ans :L2@AL and 6%I@AL are not specifically created for J#*H(#C2(D
processin. 6)TA(T and 6#5D are are key8specific. 6)TA(T always takes
you to the first record in the key seBuence, and 6#5D takes to to the
last 3or after the last one dependin on the loic4. This works even
when the key fields are in D#)C#5DI5& or A)C#5DI5& seBuence, which is at
best confusin with 6%I@ALH6L2@AL.
$ob is correct. ?or exa"ple 6%I@AL )#TLL ?IL#5A1# "iht 52T
position you at the end of the file, for exa"ple, when there are
dupicate keys. %owever, 6#5D is always at the end of the file.
6L2@AL can also have Buirks, especially with descendin keys, whereas
always is a beinnin of file. I "ost cases, therefore, it prob doesnMt
"atter which you use. $ut on so"e cases, it does.
;;. 0hen to use L( X when not to useA Diff. L( X (eturnA
*eturn : will !ust return the control to the callin prora". 0ithout
closin or initiali,in the local variables or will not clear the
"e"ory. 0here as
1* : will close all file and initiali,e all local variables and clear
the "e"ory used by that prora". )ettin on L( 3Last (ecord4 will close
files and free resources occupy by the prora".Initiali,ation will occur
on the next call to the prora".
5ot settin on L( 3in 2.1 prora"s4 will keep the prora" in "e"ory,
keeps file open and pointers set, retains variable values, and prevents
the 6I57)( fro" bein executed the next ti"e the prora" is called, as
well as I57 specified in your D8specs. As a rule, I never seton L( when
a prora" will be called "ultiple ti"es. This rule "ost definitely
applied to a trier prora" that could be called hundreds or possibly
thousands of ti"es.
;N. %ow do I convert character to nu"eric
Ans : In 2)H;FF @ersion N, (elease G (.& I@ was enhanced such that the
CD#C and CI5T built8in functions now support a character value on their
first para"eter. )i"ply specify the character field or literal value as
the first para"eter for CD#C, then indicate the lenth and deci"al
positions and the built8in function converts the character field to
nu"eric. The CI5T function works si"ilar, except no lenth attributes
are reBuired since it only works with whole nu"bers.
D s,0eb?@al ) >A In,3M/G9.;NM4
C #val A"tDue I CD#C3s,0eb@al : N:G4
Que : What are the ad:anta"es !f O+0Q*&?
Ans : a. Dyna"ically select records fro" files
b. Dyna"ically access files in a specified key path
c. Dyna"ically !oin files
Que :I would like to have the output report fro" +uery na"ed so"ethin
other than +.+'.(?IL. Can this be acco"plished anywhere within BueryA 2r
does it have to be set up in the CL that wayA
Ans : the +ueryH;FF output report na"e depends on 6prtf +.+'.(?IL. *ou
can si"lpy chane output report 3spool file4 na"e by CL co""and: OA*+*T?
?(1EDQ+QU+*?(1E %+1?0A3ED!urKnewKna.eE Co""and 2@(.(T? takes effect
only for your !ob and you have to type this co""and before you run your
Que : I have never used 2.5+(*? before, but I need to "aintain a prora"
that uses this, so I hope you, experts, can help "e out with this. The
ob!ective is to !oin files %I.? and 5#.? with a for"at like +0FF/? so
that the records can be accessed by the prora" via 5##A5 field. The
seBuence of co""ands run by the (.& prora" by callin +C1D#<C oes like
2.#5 +0FF/? 2.5+(*? ?IL# 33%I.?4 35#.?44 ?2(1AT 3+0FF/?4 J#*?LD 5##A54
:?LD 33GH5#A$ /H%IA$4 3GH5#A5 /H%IA54 3GH5#A) /H%IA)44 )#+25L*36524
:D?T@AL36*#)4 C211IT36524 2.5D$? ?IL#3+0FF/?4 2.TI2536I5.4 C211IT36524H
!ust to test, I inserted here:
C.*?(1+(*? ?(212.5ID3%I.?4 T2?IL#3+T#1.H+0FF/?4 1$(2.T36ADD4 Y...and it
did produce the records... 2@(D$? ?IL#3+0FF/?4 T2?IL#3%I.?4 )%A(#36*#)4
2@()C2.#36:2$4 H I a" expectin the prora" will now use the &0FF/? access
path... and should be able to et the records, but it canMt find any...
Z5##A5 )#TLL +0FF/? (#AD +0FF/? 0hat should have been the correct way to
refer to the opened Buery fileA .lease helpS Thanks in advance,
Ans : I assu"e that the file na"e in your ?8spec is +0FF/?. The only
thin that I do different is I do the 2@(D$? prior to the 2.5+(*? and I
do not do 2.5D$?
2. I concur with Tfisher. 2@(D$? to )%A(# first, then 2.5+(*?. 2.5D$?
is not needed since 2.5+(*? is an 2.5D$? with a subset of the data 3or
!oin or 0hatever4, so the file is open already, you do not need to open
it aain.
$. Thanks for your replies. I tried re"ovin the 2.5D$? and puttin the
2@(D$? before 2.5+(*?. )till there are no records on the (#AD.0hat sould
have one wronA
'.0hat is the na"e of the file in your (.& prora"Ms ?8specA
*ou should be followin this seBuence
2@(D$? ...
2.5+(*? ...
CALL (.& ...
CL2? ...
DLT2@( ...
If you are also doin a C.*?(1+(*? 3or any other read of the file4
before the (.& call, you will also need to do a .2)D$?36)TA(T4.
$ecause of the shared data path, the read does not restart at record /
unless you position it there.
/. %ow to !oin files usin 2.5+(*? co""andA
2.5+(*? ?IL#3?IL#A ?IL#$4 ?2(1AT3:2I5?1T4 K
:?LD33C1.* C1.*4 3C')TZ C')TZ44
In your exa"ple :2I5?1T is a existin fileA
:2I5?1T is !ust so"ethin that I "ade up for this exa"ple, it is a
for"at that would not exist in either of the two files I a" !oinin.
0hen you !oin files you "ust ive a for"at na"e in the ?2(1AT para"eter.
The for"at na"e "ay be any of the files bein !oined, but "ost people
use a du""y for"at na"e that will be used to pass to the hih8level
lanuae prora". I have even seen people create DD) for the !oined
for"at. #ither way, the for"at "ust be whatever your hih8level
lanuae prora" is expectin.
Also donMt foret the override prior to the 2.5+(*? co""and:
2@(D$? ?IL#3:2I5?1T4 T2?IL#3?IL#A4 )%A(#36*#)4
Thank you once aainS $ut I could not use du""y na"e for record for"at
as it ave "e error Mfile not found in 6LI$LM. I donMt know the reason,
because I had overridden the file with followin co""and:
2@(D$? ?IL#3:2I5?1T4 T2?IL#3A$.?FFF/4 )%A(#36*#)4
88888Then I created a file A$.?FFF= and wrote followin CL prora":
1251)& 1)&ID3C.?FFFF4
#<#C3&2T2 C1DL$L3#5D44
2@(D$? ?IL#3A$.?FFF=4 T2?IL#3A$.?FFF/4 K
2@()C2.#36:2$4 )%A(#36*#)4 2.5+(*? ?IL#33'A:I$A@HA$.?FFF/4
3'A:I$A@HA$.?FFFG44 K
?2(1AT3A$.?FFF=4 :?LD33/H#1#152 K GH)A#15244 1A.?LD33.?#152 M/H#1#152M4
K 3.?#151 M/H#1#151M4 3.?D#)& MGH)AD#)&M4 K
3.?)A(* MGH)A)L(*M44 CALL .&13'A:I$A@HA$(.FF/F4 CL2? 2.5ID3A$.?FFF/4
DLT2@( ?IL#3A$.?FFF=4 L@L36:2$4
#5D.&1 88888888888888888888888888888888888888888888888888888888888888888
A$(.FF/F (.& Code:
?6 ?A$.?FFF=I?
? 99 DI)J
#6 IX?IL# D) 99
I / 9F[?LD/
I ; G9 [?LDG
I G; GL [?LD9
I GP 99F[?LD;
C 12@# MFM 6I5PF
C 6I5PF D20#+MFM
C (#AD A$.?FFF= [?IL# PF
C 6I5PF I?#+ M/M
C L#A@# C #5DI?
C [?LD/ D).L*
C [?LDG D).L*
C [?LD9 D).L*
C [?LD; D).L*
C #5DD2
C 12@# M/M 6I5L(
'2. Can so"e one help "e on how to et syste" data X ti"e in free for"
(.&A If so"e one can help "e in ettin the free for" (.& "anual that
would be reat. Thanks
Ans : 1. ItMs done in the D specs now:
D Date s d in,36sys4 datf"t36usa4
D Ti"e s t in,36sys4 ti"f"t36usa4
2. *ou can et the "anual here:
:uan Carlos.
$. There is no R(.& ?reeR "anual, the docu"entation for the (.& co"piler
directive and free for" syntax is included in the (.& IL# "anual. &o to
the web site that :uan Carlos "entions. )yste" date, ti"e, and ti"esta"p
can be coded like this: )ysDate I CDateU )ysTi"e I CTi"eU )ysTi"e)t"p I
'. Is it possible to check a date retrieved fro" the a reade operation
with the syste" date and iterate the the sa"e process aain to check the
date as the key i a" passin "ay have "any records for it
/. Hfree

read fileU HH &et next record
dow not Ceof3file4U HH Jeep loopin while we have
HH a record
if CerrorU
dsply MThe read failedMU
if CdateIyourTdateU HH your date is your date field
doTso"ethinU HH 0hat you want to do
read fileU
'4. 0ill u pls tell "e the diff. in the si"ple Buery X Buery "anaer
Ans :0hatMs the difference between +ueryH;FF and +1 +uery. +1 +uery is
based on )+L. *ou can write an )+L state"ent that enerates the data for
the output. #ffectively you can replace 2.5+(*? with +1 +uery X )+L
offer a "ore readible solution
'5. I want to write records in a local textfile.
Ans : 'se followin code
?ile definition \C2D#]
?Datei/ '? A ? //> DI)J 'sr2pn #xt?ile3?ile4
? (ecno3cur4 6
D ?ile ) /GL In,3MC:Hte"pHT#)T.DATM4
D ?ileLen ) = F
D Cur ) = F
I Datei/ 5 ) F/
I / = 2Tknr
I > 9= 2Tna"/
I 9> == 2Tstr
I => >/ 2Tpl,
I >G P= 2Tort
I P> /FL2Tkto At the #nd i have the output
2Datei/ #Add 5eu 2
2Tknr = 2 2Tna"/ 9F 2
2Tstr 9F 2 2Tpl, N 2
2Tort GN 2 2Tkto /G
in the Jlick procedure of the button have the followin code c open
C eval 2Tknr I ;>/G
C eval 2Tna"/IM%ans Test"aieGrM
C eval 2Tstr I MTestwe ==M
C eval 2Tpl, I /////
C eval 2Tort I MTesthausenGM
C #xcept 5eu when i check the output file, i see an e"pty file. There is
no text in the file, but the blanks are there. That "eans : The record
was written but there is no content. .lease help "e S reets !oi
An) : I think the output def shouold look like this: whith the sa"e
endpositions as in the input state"ents
2Datei/ #Add 5eu 2
2Tknr = 2
2Tna"/ 9= 2
2Tstr == 2
2Tpl, >/ 2
2Tort P= 2
2Tkto /FL
2Tkto is blank in your output, so the first /G bytes are blank, in your
file should be the rest of
2Tna"/ 3eGr4 vo" %ans Test"eier
'7. I a" havin an assin"ent in which it is asked to display specific
pae of subfile. e.. I a" currently on /Fth pae of subfile, now if I
wants to display Gnd pae directly..... %ow should I doA
(iht now I have taken a inputHoutput field in control record for"at, to
specify the pae to be displayed. %ow should I use this value to display
specific pae on L2AD ALL subfile.
Is )?L(CD5$( or )?LC)(((5 useful in this caseA 2r any other keyword.
.lease, it is urent. If possible try to elaborate your concept with an
Ans: (f your )?L.A& I /F, Gnd pae should start on //th record. 1ove
this nu"ber to )?L(CD5$( and #<?1T aain.
/9. how do you access all "e"bers in pfA : 0(J1$(.D1
Ans : /4 2@(D$? ?IL#3<<<<4 T2?IL#3<<<<<4 1$(36ALL4
/1. %ow "any ti"es can we open file in prora"A
Ans :'se ')(2.5 and you can open and close it as often as you want
/2. how "any records can be stroed when e specify 6no"axA
Ans :0ith the 6no"ax option, you can store 6no"ax records 3IMll bet you
always wondered what they "ent by no"ax4.
/$. .ls so"ebody tell "e how to find that weather there is data in .? in
CL without definin file in CLA Also how to 1aintain access path without
usin the opnBryf or Loical file or e"bedded sBl
Ans : 0ithout definin... file in CL, (unBry H D).?D co""and... can be
executed in CL p" or D)..?1 to check... whether data is present in .?
or not. *ou can use (T@1$(D in CL and find the nu"ber of records in the
file "e"ber
/'. (n h!w .an cate"!ries f!r br!Fe the sste. securities.
I4&eneral )yste" @alues
II4 2thers )yste" values related to security.
III4 )yste" values that control password
I@4 syste" values that control audit "ap
//. -!w t! retrie:es the s!urce !f a ,1 pr!"ra..
Ans. (T@CL)(C
/2. -!w d! ( declare an arra with a dna.ic nu.ber !f ele.ents#
Ans . In (.& I@, the new 3@9 (>4 ALL2C, (#ALL2C and D#ALL2C operation
codes can be used to allocate "e"ory. This "eans that at run ti"e, you
can o out to the syste" and ask it to assin storae to the prora"
that was not allocated to the prora" when it was evoked.
These operation codes can be used to allocate "e"ory up to /=1$. The
allocation can be assined to a pointer variable. In (.& I@, pointers
have the data8type of asterisk 364. All that is needed is to allocate
"e"ory to a pointer that is used with the $A)#D keyword of the desired
dyna"ic array. The exa"ple that follows illustrates this techniBue:
D Dn!Arr % 4+ 9 Di.D19999E basedD pDn!ArrE
D n%ize % 19i 9
, E:al n%ize C @sizeDDin!ArrE < 2'
, All!c n%ize pDn!Arr
<< We n!w ha:e en!u"h st!ra"e all!cated f!r 2' ele.ents.
, E:al n%ize C @sizeDDin!ArrE < 49
, *eAll!c n%ize pDn!Arr
<< We ha:e chan"ed the all!cati!n t! en!u"h st!ra"e f!r 49
,< ... c!de t! use the arra "!es here...
, Deall!cD0E pDn!Arr
<< We ha:e ;ust returned the st!ra"e t! the sste..
To increase or decrease the nu"ber of ele"ents in the dyna"ic array, use
the (#ALL2C operation code. )i"ply chane the nu"ber of bytes that need
to be allocated, and call (#ALL2C with the new si,e in ?actor G and the
oriinal pointer variable in the (esult field. (#ALL2C allocates new
storae of the si,e specified, and copies the oriinal data to that new
location. Then it frees 3RdeallocatesR4 the oriinal storae.
I1.2(TA5T: Always re"e"ber to D#ALL2C anythin you ALL2C. That is always
free up "e"ory that you have allocated otherwise "e"ory leaks will be
If you are not on @9 (>, you can still use dyna"ic "e"ory by callin one
of the syste" A.Is or linkin into the +CGL# bindin directory and
callin the C runti"e 1ALL2C and D#ALL2C functions.
-!w d! ( d! c!ncatenati!n in *+6 (A) liFe ( d! in ,1#
In the initial release of (.& I@, the plus sin can be used to do si"ple
concatenation. 0hen the expression of any of the enhanced operation
codes includes strin expressions, then the plus sin is considered a
concatenation operator. In later release of (.& I@, the built8in
function C#DITC can be used to allow nu"eric fields to participate in
si"ple concatenation.
The exa"ple below illustrates the basic concatenation 3line ;4 and the
enhance"ent introduced in 2)H;FF @9 (>.
9991 ?,U%T3A%T (? E M DisF
9992 << *+6 (A !n O%I'99 A$ *1 and later...
999$ , ,ust0! ,hain ,ust3ast
999' , E:al 3s" C ,ust0a.e L N is N L ,3K%tatus

999/ << *+6 (A !n O%I'99 A$ *2 and A$ *4 and later...
9992 , E:al 3s" C N,ust!.er: N L
@Edit,D,ust0!:N=NE L
9994 , N is N L ,3K%tatus
In addition, the traditional (.& I@ CAT operation code can be used for
/4. Are there an useful , *unti.e A+(s that ( can call fr!. *+6 (A#
There are several C runti"e A.Is available to the (.& I@ developer. In
2)H;FF version 9, release / the scope of these A.Is is li"ited.
The CALL$ operation code can be used to directly call the C runti"e
A.Is, provided they donMt reBuire Rpass by valueR para"eters.
In @9 (G and later, para"eters can be passed by reference or by value.
In addition, .rototypes are supporte for callin procedures written in
(.& I@ or other lanuaes.
The current list of C8related runti"e functions is lare. To support
these functions in your (.& I@ prora"s you need to co"pile the prora"
so that it runs in a nor"al activation roup, and binds to the C runti"e
library. A bindin director is conveniently provided for !ust this
purpose. ?or exa"ple:
,*T>0D*+6 p".D.+".E D?TA,T6*+D<0OE >0DD(*DQ,21EE
$y specifyin D?TACT&(.36524 and $5DDI(3+CGL#4, you open up your (.& I@
prora" to the world of C runti"e functions. These functions include
hih8level "ath and ti"e for"attin routines. )ee the (.& Developer
5etwork 5ews articles on interated these functions in (.& I@ for "ore
Another cool thin about +CGL# is that the IL# CH;FF runti"e includes
the full set of open A)H;FF 1I instructions. That is the A)H;FF asse"bly
lanuae can be called directly fro" (.& I@ by prototypin their CH;FF
functions. ?or exa"ple, to call the Convert Characters to %exadeci"al
)y"bols 1I instruction, you would call the Mc:thcM C runti"e function.
?or exa"ple:
The followin (.& I@ code should co"pile on any version of 2)H;FF that
includes (.& I@.
D sz,harAal % 29A (nzDNA>,DE?6NE
D sz-exAal D%
D sz-ex1 1(MEDsz,harAalE
D sz-ex2 1(MEDsz,harAalE
D n,har1en % 7> 9
<< if !u want t! a:!id c!n:ertin" trailin" blanFs) use this st.t.
, N N ,hecF* sz,harAal n,har1en
<< !r if !u want t! c!n:ert trailin" blanFs) use this st.t.
, E:al n,har1en C @sizeDsz,harAalE < 2
<< This c!n:erts N12$N t! N?1?2?$N
, ,A11> Nc:thcN
, +ar. sz-exAal
, +ar. sz,harAal
, +ar. n,har1en
<< This c!n:erts N?1?2?$N t! N12$N
, ,A11> Nc:tchN
, +ar. sz,harAal
, +ar. sz-exAal
, +ar. n,har1en
:ust a few thins to re"e"ber when usin the C runti"e A.Is.
• The na"es are case8sensitive. That is McvthcM "ust be specified in
lower case or it will not be found.
• These functions are located in the 2)H;FF C8runti"e library and
"ust be bound usin the +CGL# bindin directory.
• .ara"eters that reBuire pass8by8value restrict the A.I to bein
called with newer releases of (.& I@, via procedure prototypes.
• C functions that have return values cannot be called by (.& I@
under 2)H;FF version 9, release /.
• 'ntil you "ove to @9 (G or, even better, @9 (>, the nu"ber of
interfaces that can be accessed by (.& I@ is li"ited. In fact, the
%exToChar, CharTo%ex functions are about all that are useful.
• 'nder later releases of (.& I@, procedure prototypes allow access
to all of the C runti"e functions. This includes those nice little
date and ti"e for"attin functions, such as ascti"e
/5. ,an !u clear up the c!nfusi!n in the different releases !f *+6 (A
and O%I'99 and (1E#
Ans . (.& I@ is the next eneration of the (.& lanuae. (.& III is the
oriinal version of A)H;FF (.&H;FF. The na"e RA)H;FF (.&H;FFR is that
iven to the I$1 co"piler packae for distribution on the A)H;FF. This
co"piler packae co"piles various versions of (.&, includin (.&II and
at least two releases of (.&III.
As of 2)H;FF @ersion 9 release /, I$1 chaned the na"e of this co"piler
packae to RA)H;FF IL# (.&H;FFR. The reason for this na"e chane was to
identify that fact that the co"pile now includes a version of (.& that
tarets the Interated Lanuae #nviron"ent 3IL#4, that is (.& I@.
IL# was first shipped in 2)H;FF @ersion G, (elease 9. %owever, only the
C lanuae co"piler produced code that tareted this environ"ent. ?irst,
a word about IL#.
IL# is the new, RnativeR runti"e environ"ent for .rora"s, on the
A)H;FF. 'nder 2)H;FF @ersion G (elease 9, I$1 introduced a new prora"
"odel. This basically "eans that new features and interfaces beca"e
available. %owever, I$1 did not !ust port so"e runti"e environ"ent to
the 2)H;FF operatin syste", it actually re8wrote code, and wrote new
code that, essentially, chaned the way 2)H;FF works. This new code
provides support for a "ixed set of hih8level lanuaes.
.reviously, (.& and CL had their own little runti"e environ"ent, C2$2L
had itMs own, C had itMs own, and so on. 'nder IL#, all prora""in
lanuaes run in IL#. The sa"e Renviron"entR is used for C2$2L, C, (.&
and CL.
%owever, to take advantae of IL#, new co"pilers needed to be created.
As for (.&, rather than convert the existin (.&II and (.&III co"pilers,
I$1, who was desinin a new version of (.& anyway, decided to taret
IL# with the new co"piler. This would si"ultaneously provide a new
version of (.& and an IL# tareted co"piler. Are (.p!rtant
A ood friend of "ine once said, Rna"es are i"portantR in the
prora""in world. If a field is called R(hinocerosR, does it represent
its use or purposeA 2kay, so perhaps in traditional (.& RIuanaR is a
better choice for this exa"ple. 3)horter na"e.4
Durin the develop"ent of (.& I@, two distinct issues arose. ?irst, the
internal na"e for (.& I@, was RIL# (.&R. This was not a code na"e, but
rather the na"e I$1 used to refer to the new co"piler. After all, it was
taretin IL#, why not refer to it as RIL# (.&RA )econd, the re8
architecture of (.& ca"e into Buestion.
'nfortunately, the internal na"e RIL# (.&R bean to be leaked out to the
public. )everal "aa,ine writers and I$1ers not involved in the
develop"ent of (.& I@ continued to use the ter" RIL# (.&R when referrin
to (.& I@. I suppose these people still refer to the A)H;FF as
SilverLake or perhaps even Olympic.
Then when I$1 announced the co"piler packae or product na"e as RA)H;FF
IL# (.&H;FFR it only added to the confusion. I$1 dropped the ball when
pro"otin the (.& I@ na"e. They are, after all, set up to "arket their
products with their product na"es. The na"e of one prora""in lanuae
included in a product that contains nearly seven full co"pilers isnMt
hih priority.
(.& I@ is the version of (.& that tarets IL#. 2)H;FF @9(/ co"patible
(.& I@ can also taret what is now called Rthe oriinal prora" "odelR
or si"ply 2.1. 2.1 is !ust a na"e that has been iven to the oriinal
runti"e environ"ent of (.& and CL under 2)H;FF. This is the environ"ent
in which (.&III and CL run. 'nder IL#, however, the oriinal native
environ"ent is e"ulated, that is, IL# isnMt an environ"ent at all, it is
native 2)H;FF, whereas, 2.1 is now an environ"ent under IL#. )o"e very
clever prora""in and desin went into this, donMt you thinkA 5ot very
"any other operatin syste"s, if any, provide this kind of continuity.
/7. *+6 (A BB *elease what#
Ans . (.& I@ was first shipped with 2)H;FF @ersion 9, (elease /. This is
now referred to as (.& I@ release /. $ut donMt worry about re"e"berin
releases of (.& I@.
'nder 2)H;FF @ersion 9, (elease =, I$1 enhanced (.& with procedures,
"any "ore built8in functions, and several new data types. This is
referred to as (.& I@ release G.
Then, 2)H;FF @ersion 9, (elease G was announced. It brouht the oriinal
release of (.& I@ 3on the CI)C boxes4 up to the sa"e level as (.& I@
under @9(=. Are you confused yetA 1e tooS
'nder 2)H;FF @ersion 9, (elease >, I$1 added a couple of enhance"ents,
"ost notably they increased the lenth of a field na"e to a nu"ber so
lare not even "aa,ine authors that donMt write real8world code could
co"plain about it any"ore. They also added one or two new data types,
roundin out (.& I@ so that it supports all A)H;FF data types, except
variable lenth fields. This version of (.& I@ is known as (.& I@
(elease 9.
The followin table identifies the current releases of (.& I@. 5ote that
(.& I@ releases do not necessarily coincide with releases of the
operatin syste".
(.& I@ 2)H;FF CI)C or (I)C
/ @9 (/ CI)C
G @9 (= (I)C
G @9 (G CI)C
9 @9 (> (I)C
; @; (G (I)C
; @9 (N 3speculation4
)ee note /
N @; (9 (I)C
N @; (; 3?ebruary /PPP4 (I)C
= @; (N 3)u""er GFFF4 (I)C
0OTE 1: It is speculated that I$1 "ay ship a final Rclean upR release of
2)H;FF for CI)C that would included a lare level of co"patibility with
2)H;FF @; (N.
The release levels of (.& I@ are only i"portant if you want to keep
track of that kind of thin. 2ne disappointin issue is that unless you
stay on the "ost current release of 2)H;FF, you donMt et all the cool
new features in (.& I@. #ven if you stay current, you canMt taret prior
releases if you use any of the new features. In fact, even if you use a
new feature that doesnMt depend on an operatin syste" enhance"ent, it
canMt be used for back releases. This is because of the way the T&T(L)
3taret release4 feature has been i"ple"ented. $asically, if youMre on
@; (G and you do a T&T(L)3@9(G1F4 the co"piler calls the actual co"piler
for @9 (G. It doesnMt have a built8in syntax checker that says RThis
feature reBuires an 2)H;FF uprade so donMt allow it, or this one is
okay so accept it.R It iscallin the sa"e RbinaryR co"piler code that is
on any old @9 (G syste".
0hich "eans, for exa"ple, that if you want to take advantae of the new
co"piler directives, but you often have to taret a prior release, you
canMt use those directives. ?or exa"ple, HI? D#?I5#D does nothin for
the executable code thatMs enerated, but is not supported when
T&T(L)3@9(G1F4 is specified. U3 $u""erS
)o now we know about (.& I@ release levels and how the ter" RIL# (.&R
ot into our vocabulary. )o letMs clear up another ter", the na"e of the
(.& lanuae. The bi one is the ter" R(.&H;FFR. There is not
prora""in lanuae called R(.&H;FFR. The lanuae "ost often called
R(.&H;FFR is (.&III. %owever, back in the )yste"H9L days, the )yste"H9L
(.& lanuae was called (.&III. 0hen the A)H;FF was announced,
prora""ers wanted to ive the"selves an advantae on their r^su"^. )o
they bean callin A)H;FF (.&III, R(.&H;FFR. Then to "ake "atter worse,
when (.& I@ was announced, prora""ers thouht that the nu"ber RI@R in
R(.& I@R was less than the R;FFR in R(.&H;FFR. )o they decided to call
(.& I@, RIL# (.&R. 0ell letMs set the record straiht. The table below
lists the (.& lanuae na"es, their incorrect na"e, and the proper na"e.
,!..!nl used
Wr!n" 0a.e
?! 0a.e +r!per Dc!rrectE
(.&H9= )yste"H9=8co"patible (.&II (.&II
(.&H9L )yste"H9L8co"patible
(.&H;FF (.&III (.&III
IL# (.& (.& I@ (.& I@
=F. %ow does the C25)T keyword work with .rocedure para"etersA
Ans . If you are certain that the called procedure will 52T "odify a
para"eter, the C25)T keyword can provide several benefits.
/. It auto"atically converts a field of a si"ilar data type, to the
lenth and type reBuired by the para"eter.
0hat this "eans, is say a para"eter is a /N position pack field,
with N deci"als. 5or"ally, youMd have to specify a .dk3/N,N4 field
for the para"eter. %owever, if the para"eter is read8only, you can
specify C25)T on the .rototype and .rocedure Interface for the
para"eter. 0hen you do this, the co"piler auto"atically converts
the value 3say itMs a literal of G>4 to the si,e and type reBuired
by the para"eter. This works really cool with DAT# fields. A date
for any for"at can be passed as a para"eter value when that
para"eter value is C25)T.
G. .erfor"ance is i"proved because the co"piler can enerate "ore
opti"i,ed code for the C25)T para"eter.
C25)T can be used on calls to procedures or prora"s. 0e use it all the
ti"e when callin +C1D#<C fro" within (.& I@. All three para"eters of
the +C1D#<C prora" are C25)T values. The exa"ple code below can be used
as the .(2T2T*.# to call +C1D#<C fro" within (.& I@. To call it usin
this prototype, specify so"ethin like: ,A11+ runDNaddlible .1ibN 1'E
in your calculation specs.
D *un +* Ext+".3M+C1D#<CM4
D c"dstr 9FFFA ,!nst Opti!ns36@ar)i,e4
D c"dlen /N+ N ,!nst
D c"dDbcs 9A ,!nst Opti!ns3652.A))4
5ote: if youMre usin Code)tudio or I$1Ms CodeH;FF as your (.& I@ editor
under 0indows, you could si"ply hihliht the above source code within
your Internet $rowser, and copy it to the 0indows clipboard. Then
activate Code)tudio 3or CodeH;FF4 and use the .aste function to insert
the code directly into the editor. .retty cool, huhA _O
WhatNs new in O%I'99 Aersi!n / *+6 (A#
)o "uch is new in (.& I@ with 2)H;FF @ersion N, that I wrote an article
about it. (ead "y article about the enhance"ents to (.& I@ in 2)H;FF
@ersion N.
There are a few sinificant enhance"ents in (.& I@ in 2)H;FF @ersion ;,
(elease ;.
• The CC%A( built8in function has be fixed. It now functions
like it was supposed to in the first place. *ou can wrap a
nu"eric value in CC%A( and a nicely edited character for" of
the nu"ber is returned. The edited for" includes the
deci"al, tri""ed off leadin blanks, and a neative sin.
• The ?2( loop provides a free8for"at version of the D2
operation code. 0ith the ?2( operation, you can bein a loop
operation and continue iteratin throuh the loop until a
variable eBuals a li"it value. The syntax for the ?2(
operation is enhanced with the T2, $* and D205T2 keywords.
The T2 operation indicators the upper li"it for the loopin,
while the $* keyword identifies the incre"ent value for the
loop counter. Alternatively, you can specify the D205T2
keyword to loop backwards fro" a lare value to a s"all
• The 2.#52.T keyword is added to the %eader specification.
This keyword can be used alon with its one and only
para"eter 6I572?L to cause overflow indicators to be set off
when their correspondin printer file is closed and then re8
opened durin the prora". )o use 2.#52.T36I572?L4 when
• In subroutines, the L#A@#)( operation can now be used to
exit a subroutine i""ediately. #ffectively this is a
Rlorified otoR operation that branches to the #5D)(
state"ent of a subroutine.
21. -!w d! ( handle the err!r and 1* indicat!r !n a ,A11) when usin"
Ans . The short answer is, you canMt. The lon answer is, it depends on
the 2)H;FF release level.
In releases prior to 2)H;FF @; (G, there is no way to detect the L(
situation. #rrors are trapped either by specifyin the .))( subroutine,
or usin an IL# errorHevent handlin A.I. In @;(G and later, its a
little easier. (.& I@ supports the C#((2( built8in function. This built8
in allows you to test the result of the CALL. operation. 'nfortunately,
we have to use a silly R#R operation extender. Apparently it is easier
to code CALL.3#4 and then check the status of C#((2( for a 625 or 62??
condition than it is to not use 3#4 and still check C#((2(. C#((2( is
only set when the # operation extender is used. U3
As for checkin if the called prora" set on L( before returnin, the
use of CALL. does not provide this capability.
22. -!w d! ( enable a Gw!rFstati!n ti.eB!utG feature in *+6#
Ans . There are five thins reBuired to provide a ti"e8out option on any
interactive workstation file. This capability allows an (.& prora" to
receive control before an end8user presses a ?unction key or #nter. )o"e
of the uses for this kind of function include:
• .rovidin a "arBuee for a schedule via a subfile
• 'pdate the ti"e displayed on the workstation at reular
• (efresh the infor"ation, such as a news display,
As "entioned, there are five thins reBuired to achieve workstation
ti"e8out. Those five thins are:
/. Add the (0A(TE keyword to the 0orkstation display file DD).
This is a file8level keyword.
G. 'se the WA(T*,D para"eter of C(TD).? to set the desired
ti"e8out period.
9. Add the 3AODEAD<?(1EE keyword to the ?ile specification for
the 0orkstation device file.
;. 0rite the desired display file for"ats to the display usin
the nor"al "ethods.
N. 'se the *EAD operation code to read Displa ?ile na"e, not
the (ecord for"at na"e.
*ou "ust avoid usin #<?1T to the display file as this operation code does
not support workstation ti"e8out.
? 1arBuee C? # 02(J)T5 1A<D#@ 36?IL#4
? )?IL#3detail:rrn4
C 0rite %eader
C 0rite ?ooter
C Do /G rrn
C 0rite Detail
C enddo
C 0rite )?LCTL?1T
C (ead 1arBuee
2$. What >indin" Direct!r D! ( need t! bind t! when usin" ,6( *+6 (A#
The +TC. library contains the service prora" na"ed +T1%C&I which
includes access to all the necessary ob!ects to accessin any +t"h6 A.I.
)o set the $5D)(@.&1 para"eter to +T1%C&I in +TC..
If @;(G or earlier use +T1%C&I service prora":
OO $5D)(@.&1 3+TC.H+T1%C&I4
If later than @;(G use:
FFFF.FG < Test pr!"ra. f!r s!urce hi"hli"htin"
/.F ?+(.&L#)(C '? ? //G DI)J #<T?IL#3M+&.LH+(.&L#)(CM4
G.F FFF/.F/ ? #<T1$(3MT#)TM4
;.F FFF9.FF D 5or"al C C25)T3<MGFM4
N.F FFF;.FF D (everse C C25)T3<MG/M4
=.F FFFN.FF D %ihliht C C25)T3<MGGM4
>.F FFF=.FF D (everse%i C C25)T3<MG9M4
L.F FFF>.FF D 'nderline C C25)T3<MG;M4
/F.F FFFP.FF I+(.&L#)(C 5) F/
//.F FF/F.FF I / //G (ecord
/G.F FF//.FF I /L /L LineType
/9.F FF/G.FF I /P /P )tar
/;.F FF/9.FF
/N.F FF/;.FF Hfree
/=.F FF/N.FF
/>.F FF/=.FF dou C#2?3+(.&L#)(C4U
/L.F FF/>.FF read +(.&L#)(CU
/P.F FF/L.FF if C#2?3+(.&L#)(C4U
GF.F FF/P.FF leaveU
G/.F FFGF.FF endifU
GG.F FFG/.FF if )tar I M6M and LineType I 6$LA5JU
G9.F FFGG.FF LineType I %ihlihtU
G;.F FFG9.FF except 'pdU
GN.F FFG;.FF endifU
G=.F FFGN.FF enddoU
GL.F FFG>.FF 6I5L( I 625U
GP.F FFGL.FF returnU
9/.F FF9F.FF Hend8free
9G.F FF9/.FF
99.F FF9G.FF 2+(.&L#)(C # 'pd
FF99.FF 2 LineType /L
Dhir!! >hai :
/. 1AJI5& T%# T(A5)ITI25 T2 ?(##8?2(1
?ree8for" (.& is a controversial topic. IMve received a nu"ber of
1essaes fro" readers who feel stronly that I should provide "y code
)a"ples in free8for" (.& 88 but IMve also received "essaes fro"
.eople who donMt like it.
$efore startin to include free8for" code in the newsletter, I thouht
it would be a ood idea to introduce so"e of the aspects of free8for"
(.& to the readers. 'nfortunately, I donMt have nearly enouh space to
cover everythin, so I will show so"e sa"ples to et you started.
%20 T2 C2D# ?(##8?2(1 )TAT#1#5T)
?ree8for" code only replaces the calculation specifications 3Rc8
specsR4 of your prora". The %,?,D,I,2, and . specs are still coded in
the sa"e way that they would be if you were writin traditional fixed8
for" code.
Instead of codin a for" type in position = of every record, free8for"
code is identified as a block. *ou code the RHfreeR co"piler directive
in position > of the record to start the block, and you code the
RHend8freeR co"piler directive when you want the block to end. All
free8for" state"ents are typed in colu"ns L8LF of the record.
#very free8for" state"ent ends with a se"i8colon. If no se"i8colon
appears at the end of a line of code, the co"piler will assu"e that
the state"ent is not finished and will interpret the next line as part
of the sa"e state"ent.
The followin is a very si"ple (.& prora" that uses free8for":
D "s s NFA
D wait s /A
eval "s I M%ello 0orldMU
dsply "s M M waitU
eval 6inlr I 6onU
:ust to "ake it absolutely clear 88 the se"i8colon ends every
state"ent. It does not "atter where one physical line beins and
another ends. ?or exa"ple, the followin state"ent is uly, but
perfectly valid:
In free8for", the op8code is always specified first in each state"ent,
followed by the factor/, factorG, and result fields. If a particular
op8code does use the factor/, factorG, or result field, it is si"ply
The followin is a traditional C8spec for the chain op8code:
C ((5 chain 1y?ile
This is the free8for" eBuivalent:
chain ((5 1yfileU
T%# #@AL A5D CALL. 2.8C2D#) A(# ).#CIAL
*ou do not have to specify an op8code when codin an #@AL or CALL.
operation. The followin lines of code are eBuivalent:
eval "s I M%ello 0orldMU
"s I M%ello 0orldMU
1A5* 2.8C2D#) %A@# $##5 (#12@#D
2ne of the "ost controversial aspects of free8for" (.& is that "any of
the op8codes that you have in traditional fixed8for" (.& have been
re"oved. ?or the "ost part, they were re"oved because of the
expressions that you have available in the #@AL state"ent.
The R0ebsphere Develop"ent )tudio IL# (.& (eferenceR "anual in the
Infor"ation Center will tell you if an op8code is supported in free8
for", and if not, it will suest an alternative. ?or exa"ple, if you
look up the TI1# op8code in the "anual, youMll see that it says:
R?ree8?or" )yntax: 3not allowed 88 use the CDAT#, CTI1#, or CTI1#)TA1.
built8in function4R
)A1.L# ?(##8?2(1 (#.LAC#1#5T)
In "ost cases where fixed8for" op8codes were re"oved fro" free8for"
(.&, an expression or built8in8function 3$I?4 can be used instead.
1ost of the thins that IM" oin to explain here arenMt only
available in free8for" and on the traditional C8specs usin the #@AL
)ince (.& I@ was introduced in @9(/, it has been possible to do "ath
operations usin expressions in the #@AL op8code. These sa"e
expressions work nicely in free8for".
%ere are so"e typical "ath operations:
C A )'$ $ T2TALG
C A 1'LT $ T2TAL9
C < DI@ * 7
And this is how youMd code the" as expressions:
Total/ I A K $U
TotalG I A 8 $U
Total9 I A 6 $U
7 I < H *U
)tartin in @N(G, there are new operators in #@AL state"ents that can
be used when perfor"in a "ath operation that affects itself.
C ADD / C2'5T/
C )'$ / C2'5TG
C 1'LT G C2'5T9
They can be coded with the special operators as follows:
C2'5T/ KI /U
C2'5TG 8I /U
C2'5T9 6I GU
.rior to @N(G, you could acco"plish the sa"e thin by doin the
C2'5T/ I C2'5T/ K /U
C2'5TG I C2'5TG 8 /U
C2'5T9 I C2'5T9 6 GU
ItMs often useful to be able to et the re"ainder of a division
operation. ?or exa"ple, if you want to know the re"ainder of < divided
by *, youMd traditionally code the followin:
C < DI@ * '5')#D
C 1@( (
0ith the C(#134 $I?, you no loner need to do division first 88 and
you no loner need to define a variable that you donMt need elsewhere.
*ou can si"ply code this:
( I C(#13< : *4U
The 78ADD and 78)'$ op8codes were used in the old days to assin a
nu"eric value to a variable.
c ,8add /N A
c ,8sub PP $
In free8for" (.&, you could do the sa"e thin with an expression:
$ I F 8 PPU
Thouh, it see"s to "e that it "akes "ore sense to !ust do a si"ple
$ I 8PPU
Date operations are now also done with expressions even thouh dates
are relatively new to the lanuae.
c 2riDate adddur >:6DA*) 1yDate
c 2riDate subdur /:6125T%) *ourDate
c extrct 1yDate:6* *ear
In an expression, you need to tell it that youMre addin a nu"ber of
days or subtractin a nu"ber of "onths by wrappin the nu"ber in the
CDA*) or C125T%) $I?s:
1yDate I 2riDate K Cdays3>4U
*ourDate I 2riDate 8 C"onths3/4U
*ear I Csubdt31yDate: 6*4U
There are also $I?s called C*#A(), C%2'(), C1I5'T#), C)#C25D), and
C1)#C25D) that can be used in the sa"e "anner.
*ou can use special operators, KI and 8I with date operations as well.
?or exa"ple, to replace the followin:
c adddur >:6DA*) 1yDate
c subdur /:6125T%) *ourDate
*ou can code this:
1yDate KI Cdays3>4U
*ourDate 8I C"onths3/4U
?or "any of the op8codes, there are $I?s that directly replace the".
The followin op8codes can be directly replaced with $I?s: ALL2C,
C%#CJ, C%#CJ(, L22J'., (#ALL2C, )CA5, )%TD5, )+(T, )'$)T, <LAT#, and
2ne nice feature of a $I? is that you can use it anywhere you can use
an expression, includin on I?, 0%#5, D20, or D2' state"ents.
?or exa"ple, a loop that was once coded like this:
C )%TD5
c dow 6I5PP I 62??
... The code here is run until the operator shuts the prora"
... down with #5D:2$, #5D)$), .0(D05)*)
C )%TD5
c enddo
Can now be coded like this:
dow not Cshtdn34U
... The code here is run until the operator shuts the prora"
... down with #5D:2$, #5D)$), .0(D05)*)
2r perhaps a better exa"ple is usin the <?22T operation for validity
checkin. ItMs handy to be able to use it directly in an I? state"ent.
Consider the followin exa"ple:
c xfoot 1yArray Total
c if Total I F
c eval #rr1s I M*ou have to put at M K
c Mleast one value in the MK
c MarraySM
c exsr %andle#rror
c endif
I think itMs easier to read when itMs coded like this:
if Cxfoot3"yArray4 I FU
#rr1s I M*ou have to put at least one value into M K
Mthe arrayMU
exsr %andle#rrorU
The CALL, CALL$, .LI)T, and .A(1 op8codes are replaced with
prototypes. #xplainin all the uses of prototypes is beyond the scope
of this article, but I will include one Buick code sa"ple.
%ere is the traditional syntax:
C CALL M*2'(.&1M
C .A(1 2rder5o N
The followin illustrates how you do the sa"e thin in free8for"at
code with a prototype. 5ote that M*2'(.&1M does not have to be written
in free8for"at, or even in (.& I@, for this code to work.
D *our." .( #xt."3M*2'(.&1M4
D 2rder5o NA
The JLI)T and J?LD op8codes are one, replaced by two features, the
ability to use a data structure for your keylists, and the ability to
list "ultiple keys on the file operation itself.
IMve never liked keylists because I donMt like havin to re"e"ber
thins. 0hen IM" GFF lines of code into the prora" and I see that the
prora" is usin J#*F/ to chain to a file, I donMt want to have to
search the prora" for J#*F/ to find out which fields are bein used.
?or the sa"e reason, I also donMt use data structures as keys, and I
donMt see any advantae to the".
1y preference is to include the keys on the file operation itself, as
illustrated in this sa"ple code that adds up each invoice for a dayMs
DailyTotal I FU
setll 31yDate4 I5@%#AD#(U
reade 31yDate4 I5@%#AD#(U
dow not C#2?3I5@%#AD#(4U
InvTotal I FU
setll 3InvDate: Inv5o4 I5@D#TAIL)U
reade 3InvDate: Inv5o4 I5@D#TAIL)U
dow not C#2?3I5@D#TAIL)4U
InvTotal KI .rice 6 +tyU
reade 3InvDate: Inv5o4 I5@D#TAIL)U
InvTotal 8I DiscountsU
InvTotal KI TaxesU
DailyTotal KI InvTotalU
reade 31yDate4 I5@%#AD#(U
C21$I5I5& ?I<#D8?2(1 A5D ?(##8?2(1 I5 25# .(2&(A1
ItMs fine to "ix the two codin styles in the sa"e prora", but it can
"ake the code hard to read if you keep switchin back and forth
between the two different styles.
1y suestion is that you do not "ix fixed8for" and free8for" (.& in
the sa"e routine. 1ake each procedure, subprocedure, or subroutine
either all free8for", or all fixed8for".
0ell8written free8for" code is easier to read than fixed8for" because
it can be indented 88 but poorly written free8for" is "ore difficult
to read than fixed for". *our shop should develop standards for how
you want the code to be for"atted.
)o"ethin thatMs i"portant to re"e"ber is that the lessons youMve
learned over the years are still i"portant. )pacin before and after
an I? roup will still "ake it easier to read in free8for". Jeepin
the nu"ber of state"ents between an I? and #5DI? to a "ini"u" will
still help.
Indentin is an additional tool that helps to i"prove readability.
Three or four spaces are all you need to indent. If you indent too
"uch, youMll run into proble"s with the code not fittin nicely on the
screen. If you indent too little, itMll be difficult to see where the
nestin levels are.
The code sa"ple above that shows totallin up invoices for a dayMs
worth of business is a ood exa"ple of how I like to indent "y code.