• Aucun résultat trouvé

SETON IS ETOF

E. xniNf INWS [

I

'll

I

fsrr_

C,ficl::l1:.Ion» I

I I

i ! iE~:I!T R:TN~ : i I , :..i:::! I , ;, I s-.. Calc. lotio I I

i ~~ , 1 ~~.clflc~U~n$ I

i

2:r

I ' i I : I

1':1:1 ~LIA'BiL i i F,LDA: :1512

, I g.;' IRLI.AaL I F\..oB

..

: : ~~ I I I I I

i

*

I

i 1 '~ I I I

:

&

I I !

i I ! 5'~!AlBL ; ! IFLw I

-t

-I I r ~L'A6L I : INMRI I

i I I I;p.I :4P:. , INLl' 1 ;

I

: i lRiL;AB!L. : 1 IN25: i :

"1

: I R!LAS lN4;8

I

! ! I ; ,

*NOT£: F"iele! Length o.lICl Oecimal P .... ikions o~ F'ie~d.s need be dcHned in RLABL lines on\~ I~

no~ dcHncd elscwl..re in RoPG.

I J'''' ~.~I .. '~ I

25 , . . " .

30 32

OperatiOl'l ,. 3~perand 45 50 5

RTNl.. START dJ

EX'TRN FLOA

i I

I I I

E.xTRN FLDJ""

E. XTRN INMR

I E XTRNI II NLl1 I i

E.XTRNr IN25

E.xniNf

INWS [

i ii i

1\ S~. "CCI,UC' c.. o~ ope a.Hons

~ IT i

--BCR 15 .il ~4--

K

E.xit ) DC Y (FlDA) ----.,....

!

DC Y(F IL-DJ"}

DC Y ( I NMR) I

DC

rt{

I NL 1) !

DC

Y{l

N25)

Oc Iv (I NI+S)

I

Figure 45. Coding Skelete~E fer SamFlE External Subreutine Application,

General Introduction

Model 20 RPG provides the ability te sEarch through a core-stored table--known aE an argument tatle--ror table data--knc~n a~

the table arqument--that bears a predeter-mined relatienship (high, low, or equal) to ether de~ignatEd RPG data (a literal, er tbe ccntentE of a field)--knewn as the search argument. Executio~ cf this leck-up operation may be conditicnEd by indicaters assigned tc Centrcl level (ccl~. 7-8) and/

or Indicators (cels. 9-17). The statu~ of cne or twe Resulting Indicatcr~ reflects the type cf match attainEd (bigh, lew, equal, or nene). These Resulting Indica-tors may be assigned te ccndition the execution of calculation and/or cutput spec if ic at ie ns.

If deEired, subsequent calculatien and/

er ovtFut ~pecifications can call fort} the argument-table data that Eatisfied the designated relaticnshiF, and/or an asse-ciatEd data entry frem anether table--termEd a fUnction table. ~he table argu-ment and functicn data Each rerrain avail-able until the same tavail-ables are again u~ed

in a leok-up operation, and an appropriate argument match is attainEd; if tbe FrEde-termined Eearch relaticnshiF iE not

~atis-fied, t~e fermer data still remains avail-able to the program, unlESS an external subroutine instruction has placed other data into the same lccation.

Tables can be in ascending, descending, or randcm sequence; tut unseguenced tables can only be scanned for an "equal" match.

Any number cf tables may be used in one Froqram, within the limits of available core storage space. Arqument and function tables need not be in the same sequence, nor nEed they have the same data format

(alphameric or numeric). Any table in core storage can be employed as an argument table or aE a function table, and this assignment need not be uniferm for dif-ferent look-uF instructions in the program.

The table name, sequence (ascending, descending, or rand em) , tarle-inFut arrange-ment (arguarrange-ment and functien alternating or seFarate), and number of entries in a table, as well as the format of the entries themselves (alphameric or numeric, location of decimal Foint, size of field), are

definEd in the File Extensicn

Specifications--described in the next chapter.

TatlEs in core sterage cannOT re uFcated or changed in any way by the ~odEl 20 card RPG program.

Calculaticn SpEcificaticrs (OFticr.al) 149

B2i~: It is po~siblE, by HEans ef an ExtErnal sutroutinE (SEE EXIT, ateVE), to update tatlEs durinq eXEcution ef an EFG pregram ana, optionally, te punch them out in cenvE~iEnt format at cbjEct-prograrr eXEcutier time.

HoweVEr, a tarlE cannet bE Expanded by additienal entries at objEct-program execu-tion timE--unless its size specificaticn was deliterately inflated and the tablE-input deck was paddFd with rlank cards (see Nu l!!.Q'§!:--21 __ rL~.tl.§_1.!!":t~i.§ s .E'§.I_I~.tl.§, in El,l.§

K~!.§~§ifn_~E.§~ifi~~!i~nsl·

Tatles are loaded with the EPG source program at program-generaticn ti~e, and are printEd cut at qeneratien time exactly as EnterEd. If the CbjEct prcgram is punched out, the tatles form an integral part ef the punched object deck, in ~X~-card fer-mat, so ttat they arE releaded with thE ebjEct deck each time it is loadEd tc per-ferm the particular job.

IOKUP ('Tarle leek-Up)

~his operatien code, entered in cols. 28-32, causes a tatlE search te te perferned.

It is used in cenjunctien with Resulting

Indieator~ assigned in cels. 54-59 and with desiqnaticn ef a search facter (:::earcr argument), the name ef a table te te scanned (argument tatle) and, optienally, the name cf a tarlE (called a functien tatlE) trat is tc previdE a functicn asso-ciated with thE argument.

ThE pertinEnt as:::ociat~d~En~ri~:::, in the sa mEcaTeuIatrcn~

s-Feci

f lca"tien ili1"e ~ are:

1. Contrel Level (ccl:::. 7-8)--eptienal.

2.

3.

a. If tlank, the leek-up is performed at detail tine, :::UtjEct to Indica-tors (cols. 9- 17) •

t. If I-indicater (IO, l1-I9, IR) is entErEd, the leok-up i::: perfcrmed at total time, previded the parti-cular I-indicator is then cn, and sutject to Indicaters (cel:::. 9-17).

Indi ca tors (cols. 9-17) --optional.

Cn or off status of indicaters may be desiqnated to conditien Executicn cf the lcck-up operation.

Facter 1 (cels. 18-27) arquITent--reguired.

SEarch

EntEr the sEarcr. argument, lEft-alignEo (i.e., begirnina in cel. 18).

rhis ITay bE eithEr:

4.

5.

a. An alphameric er numeric literal, or

b. A field name dEfined in the input specifications or elsewhere in the calculation specifications, or c. The name of a table. A table entry

selected in a previous lOKUP opera-tion may thus become a search argument.

Factor 2 (cols. 33-38) table--reguired.

argumEnt Enter (left-alianed) the name of the tarle to be searched fer data that bears a predetermined rElationship (see Resulting Indicators, item 8, below) to the search argument.

All tatle namES begin with the let-ters TAB, followed by one, two, or three alphabetic and/or numeric

characters--see File Extension spEcifi-catien:::, telow.

]2!.§: Data in the arqument table must have the same total field length and format (alphameric or numeric) as the search argument; but the decimal-point lecation (for numeric fields) need not be identical. No decimal alignment is performed by thE progra~ in a ICfUP eperation.

Result Field (cols. 43-48) tatle--eptional

function Enter (left-aligned) the name of the tatle from which an asseciated function is to te retrieved (after an appropri-ate tatle araument--Factor 2--has been lecated to satisfy the search argument --Facter 1).

B2te: The manner in which the program determines the function-table entry that corresponos to an argument-table entry is descritEd below (Ferformanc.§

~'!!Q_B~'§.!!!!~2f_E_1E.Q!~_122~=!!E_Opera=

!:!:21!, part 2).

The Result Field i::: left blank if a corresponding function from another table is not needed. It may enly be desired to ascertain whether a table arqument of the apprerriate relation-ship to the search arqument is present --as indicated ty the status of one or two Resultinq Indicators (see item 8, below); or, it may ce oesired to Use only the tatle argument that satiSfied a criterion of Riah er low, and there-fore is net identical to the search argument.

15C SystEm/3SC ~odel 20 CPS ReFcrt Frccram Generater

6. Fi~la length (cols. 49-51) and Decimal Fositions (cel. 52)--eFticral; may always bE left blank. ThesE fiElds must tE left blank if no functien tatle

(Fesult Field) is speeifiea.

If a function table is speci~iea (in ecls. 43-48), Fiela lergth and DEc5mal positions (if numeric) may be definea here. ~his is, however, superfluous, since all tables must in any case bE defined in the File Extension SpEcifi-caticns. ~f the REsult Fiela is redE-finEd here, tte Field-length and Decirral-Positicns entries must acccrd with those in the File Extensicn Specifications.

7. Falf-Adjust (cel. 53): leaVE blank 8. Resulting Indicators (ccls. 54-59)--at

least cne entry requirEd (tut never more than twc--see belcw).

'Ih::: argument table (Factcr 2) is

searched fcr an entry that tears tc the sEarch argumE'nt (Factor 1) the rela-tionsrip designated by the assignmEnt cf erE or two Fesulting Inaieatcrs.

]~te: Tatles are stered in the crder in wrich the table data is lcaded--no check is maae to assurE that trE table sequence aaheres tc any se~uencE

(ascenaing or descending) that may be specified in the File Extensicn Speci-ficaticns. The search always ccmmences with the table entry loaded first, and progresses entry-by-entry until thE designated search condition is satis-fied cr the SEarch is terminated.

Thus, if an estensibly sequential table is out of order, inaFprcpriate table oata may be selectea and inccrrEct Resultirg-Indicator setting may be ca used (see samples, below).

£§~g11in~_lBQi5~!2±E assignmEnts in a ro¥up operation have the effEcts iterrized below:

A Resulting Indicator assigned to Egual (cols. 58-59) instructs thE prcgram to lc-cate an argument-table (Factor 2) entry equal to thE search argument (Factor 1).

The indicator turns on if such an Entry is fcund; otherwise, i t turns off.

No.i.~: 'IhE status of a REsulting Indicator

assi~nEd tc Equal cf a ~CKUP oFEraticr is not affected by a Blarik-After instruction in tre o~tput-fcrmat specificaticns, ncr is i t set on at the bEgir.ninq cf prcqram

execution.

An indicator assignea tc row (cols. 56-57) instructs the proqrarr tc lccatE that argument-table entry that is nEarest to, tut lower in sequenCE than, the search

argument. ~he indicatcr turns cn if such an entry is fcuna; otherwise, i t turns off.

An inaicatcr assignEa tc HiGh (cols. 54-55) instructs the program to locatE that argument-table entry that is nearEst to, but highEr in sEguEnce thar., tre search argumEnt.

At least one Resulting Inaicatcr must be assigned. If an indicator is assigned to Equal ana to Hiqh, or to Equal and to lOW, the program searches for an arqument-table entry that satisfies either ene of the two designated conditions, with Equal qiven precedence. The indicator for the conai-tion that was satisfied turns on; tre other indicator turns eff--unless the same indi-cator is assigned tc both conditions, in which case i t will be on. If neithEr con-dition is satisfied, the indicators turn off.

When several successivE identical entries exist in the arqument tablE, the first one encouaterEd that meets the appro-priate search criteria is selected: for an Equal ccndition, this is the first equal value; for a Eiqh or lew condition, i t is the hiqh or lew entry physically closest to equal, providEd the table is in proper order. 'Ihe significance of this (i.e., why i t mattErs which of seVEral equal entries is treated as the "hit") becomes apparent when function tables are discussea (below).

If the argument table is not specified to tE in ascending or deSCEnding sequence, a search can only be made for an Igual con-aition. (If an indicator is assianEd to High or lOW, but sequence is not desiqnated for the argument tacle in tre file exten-sien specifications, a warninq messagE is printea at program-generaticn time.)

No!~: The colUmn headings of High ana low for Resulting Inaicators must be considered reversed for the LOKUP operation--for IOYUP

High stipulates:

Low stipulatES:

Factor 2

>

factor 1 Pactor 2

<

factor 1 The expanded explanatiens below cover further particulars--includinq the contin-gency of an argument tarle, defined as beinq in sequence, beinq out of order:

1. If nc SEquence is aesiqr.ated in the file extension specifications (col. 45 or 57)--reqardless of whether the tablE is actually in sequence: A (any)

Resultinq Indicator must be assiqned to Equal (cols. 58-59).

]2!~: If no sEguence is srecified in the file extension specifications, a Fesulting Indicator assignEd to Piah (ccls. 54-55) er LCfJ (ccls. 56-57) will

Calculatien Specificaticns (Optional) 151

te ignerEd--i.e., retains it~ fcrmEr setting--if an indicatcr is also assigned to Equal; if ncne is assigned to Equal, the inoicatcr assignEd tc High or to Low is treated as thcuqt assignEd to Equal. If no Resultinq Indicator is assigned te Egual, tut diffErEnt indicators arE assignEd te beth High and low, the indicator

assigned to High is trEated as assignEd to Egual; the ot~er cnE is ignerEd. (A warning messagE is printEd during Fre-gram gEnEration.)

ThE program searchEs through the argumEnt tablE (Facter 2) until it

Eit~Er finds the first data that matctEs the search argumEnt (Factor 1) Exactly, or the entire table has tEEn

scannEd--w~ichEvEr eccurs first.

If a match is found, the Resultina Indicater assiqned te Equal turns cn;

if ne match is found, it turns off.

ExamFle: Search argument (Factor 1) 5.

Argument table (Factor 2)

=

1, 3, ~, 5, 8, 9.

The first (underlined) 5 is selected, and the Result-ing Indicatcr assigned te Equal turns on.

2. If Ascending argument-tatle sequEnce is designated in the file extensien SFEci-fications: The table is assumed tc be leadEd in ascending sequence.

.A (au¥).. ... R.e..s.ultinq. __ .lndicatcJ:.._lD.us.t t.E assigned to at lEast cne of thE threE fiElas (cols.· 54-55, 5E-57, 58-59); but tte same or different indicators may also te Effectively as~igned tc t~c

fields: High and Equal, or low and Equal. The indicator for the condition that is satisfied turn~ en; thE indica-tor assigned to a seccnd ccnditien turns off, unless it is the same indicator.

If indicators are assigned to Figh and Equal, or to Lew ar.d Egual, Equal takes Freceoence if thE Equal ccndition can bE satisfiEd (and FrevidEd tl<E table is in profEr sEquEnCE).

a. If a Resulting Indicatcr is assignEd only te Equal (col~. 58-59): Th e loek-u F epEration is identical to that describEd under 1, above. Nothinq is gained by dEsignating a se~uEncE in thE filE Extension ~pecifications.

ExamflE--wtich illustratE~ tlE

~~arch =er Egual throuqh tre entirp

tatle, eVEn thouah the table is out of erder:

S~arch arqum~nt

=

5.

Arqument tatle

=

1, 2, 9, 1C, 4, 5, 6.

5 is selEct~d.

b. If a Resultinq Indicator is assigned only to ~iah (cols. 54-55): ThE first araument-tablE entry encountered which is hiaher in sequence than t~E search arau-ment is selecteo ( i . e., bEcomes the data accEssed whEnEver, thereafter, the table namp is used as a fielo namE, before another

Lcrup

opera-tien on the same table).

Examples:

(i) Searc~ arqument (~actor 1)

=

5.

Arqument tatlE (Factor 2)

=

1, 3, (5),8, S, •••

S is selEcted as satisfyina thE search conoitier~, reqard-less of whether the entry 5 is present in the table.

The Fesultinq Indicator assiqned to Hiqh turr.s or..

(ii) Search arqument

=

5.

Argument table 1, 1, 2, 3, 3, 4, 5, 5, 5.

No tablE entry satisfies the

sEarc~ condition.

The Resultinq Indicator

assiqned to Piqh turns off.

But note:

(iii) Search arqument 5.

Argument table

=

1, .§, 8, E, 5, 6, ••• (tatle cut of

sequence)

The first (underlined) 8 is selEcted, althouqh 6 is nearer to 5 in value and position; tut the first 8 is the first value grEatEr than 5 that is Encountered.

The Resultina !ndicator assiqned to P.iqh turns on.

c. If a Resultinq Indicator is

assigneo only to lew (cols. 56-57):

The argument-table entry that is nEarest to, tut lCWEr in sEguEncE than, the search arqument is selected--provided the table is in pro fer SEqUEnCE.

]~!~: Te qeneralize fer any sequence in which the table miqht actually be (whEn ascendinq

seguEncE is SFEcifieo): The last arqument-tatle entry is selpcted which prEceaes the first entry t~at

152 System/36C ~oapl 20 CFS PEFcrt Frcgram GEn~rater

is EithEr equal te, or highEr than trE sEarch argumEnt.

Examples:

(i) SEarch argumEnt

=

~.

Argument tablE

=

1, 3, (5), 8, 9 •••

3 is selected as satisfyinc the sEarch conditicn, rEgarcless of ~hether the entry ~ is present in the tablE.

~hE Resulting Indicater assigned te Le~ turns on.

Eut note:

(ii) SearCD argumEnt = 5.

Argument taclE

=

1,

2,1,

10, 3, 4, 5, 6 (tacle Ott of sequence) .

~"hE sEcond (underlined) 2 is sElEctEd, alt~ough 4 is closer to ~ in valUE and position. The secend 2 is tr.e entry trat immEdiatEly prEcedes thE

first-encountErEd Entry (1C) that is Egual te or r.ighEr tran

t~E sEarcr ar<;ument (5).

The Resulting Indicator assiqnEd te Io~ turns en.

d. If Resultir.a Indicators are assiqnEd bot} to Hiqh ane Ie~

(irrEspective ef ~hether an indica-tor is alse assiqnEd te Equal):

Tre indicator assignEd te Io~ is ignered, and retains its fermEr status. (ThE EffEct of thE incica-ter assigned to Biqh is ExplainEd abovE and below.)

E. If Resulting Indicater~ arE

assignEd to High (cels. =4-~5) and Equal (cels. 58-59): The first arqument-table ertry enceuntErEd which is Either equal te, er higher in sequEncE than, tre sEarch argu-mEnt is SElectEd.

Examples:

(i) SEarch argumEnt (numEric)

=

+5.

Araument table

=

1, 3, ~, 5, 7, 9.

'IhE first (urdErliIJed) 5 encounterEd is selEctEd as satisfyinq the sEarch ccndi-tions: an Entry is always tested first for Equal, if an indicator is assignEd to Equal.

~he Resultinq Indicator

assigned to Equal turns on;

the indicatcr assigned to High turns cff, if it is a different indicater. ~f the

samE indicatcr is assiqned to coth conditiens, i t turns on if either condition is satisfiEd; it tUrns off only if nEither an Equal nor a High condition was

satisfiEd.

(ii) Searcr. arqument (numEric) = 5.

Arqument tablE

=

-8, -5, -4, 0, +1, 3, +7, 9.

+7 is selected, being the first-encountered value algebraically equal to or higher than 5~

The Resultina Indicator assigned to Hiqh turns on;

the indicator assigned to Equal tUrns off, unless it is the same indicator.

(iii) Search arqument = 5.

Argument table

=

1, 1, 2, 3, 3, 4, 4.

No table entry satisfiEd the search conditions.

The Pesulting Indicators assiqned to Hiqh and to :Egual turn eff.

f. If REsulting Indicators arE assignEd te To"W (cols. 56-57) and Equal (cols. 58-59): The first argument-table entry that satisfies either condition--as explainEd in

(a) and (c) above--is selected.

HOWEver, each table entry is tEsted first to SEe "Whether it is equal to thE search arqument: if hiqher, the proqram thEn selects the last precedinq le~er entry.

ExamplEs:

~) SEarch argument (alphamEric)

=

N.

Araument tablE

=

A, +5, E, J, -5, ~, P, S, 5.

-5 (=N) is selEctEd (i.e., first equal Encountered):

an entry is always testEd first for Equal, if an indi-cator is assigned to Equal.

The Fesultinq Indicator assiqned to Equal turns on;

the indicatcr assiqned to Low turns off~ unless it is the same indicator.

(ii) Search arqumEnt (alphamEric) N.

Ar1ument tablE = A, +5, E, ~,

J,- P, S, 5.

The- secend (underlined) J is selected: P is hiqher than

N (in the EretIe sequEncE);

the program therEfore selects the last precedina Calculatien Specifications (OFtional) 153

3.

lower entry.

~hE Resulting 1ndicator

a~SiqnEd te Lew turn~ en;

the indicater a~signEd to

~gual turns cff, D~lEs~ it

i~ the saWE indicater.

Put note:

(iii) SEarch arqumEnt (alr:harr.eric)

=

N.

A:qument table

=

A, E, F, E, N, S (table cut cf sEquEncE).

E i~ selected: when P (hiqher than search arqument) is rEachEd, ttE rrearam selects the last r:rEcEdinq lewer entry, althcugh an Exact match (N) exists in thE table.

The Re~ultinq Indicator

a~siqned to lew turn~ on;

the indicater assigned to Egual turn~ off, unless it is the same indicater.

If [Escending argument-table sequEnce is dEsiqnated in the file extension specificaticns: The table is assumed te b~ loaded in descending sequencE.

The effEct of LCKUF oreraticns is identical a~ for ascEnding tables (SEe 2, atove). The enly differEnces eccur

~hen sUFFosedly sequential tables arE cut ef order.

."

u . ~f Pesultina Indicatcrs are

assiqned tc low (cels. 5E-57) ana - :fqual (ccIs~--58':':-:9).

(i) Search arqument (Factor 1)

Arqument tatlE (Facter 2) 8, 6,

2,

5, ~, 1.

'Ihe first (undErlinEo) 5 enceunterEd is ~electEd.

5.

a ~

,

ThE Resulting Indicater

assi9nEd te Egual turns on;

the indicatcr assignEd to lew turns off, unless i t is the samE indicater.

(ii) Search argument = 5.

Argument table

=

9, E, E, E,

1,

3, 1, O.

The first (u~dErlined) 3 EnccuntErEd is SElECtEd.

The Resulting Indicator assigned te Lcw turns en;

the indicater assignEd to Equal turns cff, unlESS i t

i~ the samE indicator.

(iii) Searct argument

=

5.

T\r9ument tatlE

=

9, 9, 8, 7, 7, f.

No tablE Entry satisfies ~Earch conditions.

'I~e Pesultinq Indicators

a~sianed tc low and to Fcual turn off.

Eut note:

(i v) Search arqument

=

5.

Arqument tablE = 9, 1, U, 5, 4, 3 (tatle out of sEgUE'nce).

is SElEcted, althouqh thEre is an Equal value in thE tablE: 1 is the first value enceuntered that is lower than 5, ana it is encoun-tEred bEfore 5.

The Resultina Indicator assigned tc low turns en;

the indicator assianed to Equal turns eff, unless it is the same indicator.

b. If Besultinq Indicators arE

assignEd to Hiqh (cels. 54-55) and Equal (cols. 58-5S):

(i) Search arqumEnt

= s.

Arqument tablE

=

Z, V, T, R, E.

T is selEcted.

The Fesultinq Indicator assiqned tc Hiqh turns cn;

the indicator assiqned to Equal turns off, unl~s~ it is thE ~arrE indicater.

Fut note:

(ii) Search argument

= s .

Argument tablE

=

Z, W, P, T, S, f(---{tai:te-C1rt ·-o.j;:---s~~re€l. -W is selEcted, althouch ttere

is an entry S in t~e table:

W is the nearest e~try ~re­

ceding an entry lOWEr in seqUEnce than the egual value (S), and tre lower valUE (P) is encountEred beforE thE equal value (S).

ceding an entry lOWEr in seqUEnce than the egual value (S), and tre lower valUE (P) is encountEred beforE thE equal value (S).

Documents relatifs