11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

DOMainSET x=1,y=2,z=3WRITE !,"In Main ",x,y,zDO Sub1(x,y,z)WRITE !,"Back in Main ",x,y,zQUITSub1(a,b,c)WRITE !,"In Sub1 ",a,b,cQUITThe list of parameters passed by the DO command is known as the actual parameter list.The list of parameter variables defined as part of the label of the coded routine is known asthe formal parameter list. When DO calls the routine, the parameters in the actual parameterlist are mapped, by position, to the corresponding variables in the formal parameter list. Inthe above example, the value of the first actual parameter (x) is placed in the first variable(a) of the subroutine's formal parameter list; the value of the second actual parameter (y) isplaced in the second variable (b); and so on. The subroutine can then access the passed valuesby using the appropriate variables in its formal parameter list.If there are more variables in the formal parameter list than there are parameters in the actualparameter list, the extra variables are left undefined. In the following example, the formalparameter c is left undefined:MainSET x=1,y=2,z=3WRITE !,"In Main ",x,y,zDO Sub1(x,y)WRITE !,"Back in Main ",x,y,zQUITSub1(a,b,c)WRITE !,"In Sub1 ",a,b,cQUITYou can specify a default value for a formal parameter, to be used when no actual parametervalue is specified.You can leave any variable undefined by omitting the corresponding parameter from the DOcommand's actual parameter list. However, you must include a comma as a place holder foreach omitted actual parameter. In the following example, the formal parameter b is leftundefined:MainSET x=1,y=2,z=3WRITE !,"In Main ",x,y,zDO Sub1(x,,z)WRITE !,"Back in Main ",x,y,zQUITSub1(a,b,c)WRITE !,"In Sub1 ",a,b,cQUIT<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!