Download P 4 - a2
Transcript
• ‘cGetPicture’ is the picture to use: same as the ‘@...GET’ command.
?/??
• ‘cColorString’ is the color string to use: same as the ‘@...GET’
command.
|?
• ‘bPreValid’ is a code block containing the condition that must
be valid before the cursor can reach this get field. It is equivalent to the ‘WHEN’ condition used with the ‘@...GET’ command,
but it must be converted into a code block. For example, if the
condition is ‘A > B’, the code block is ‘{|| A > B}’
• ‘bPostValid’ is a code block containing the condition that must
be valid before the cursor can leave this get field. It is equivalent to the ‘VALID’ condition used with the ‘@...GET’ command,
but it must be converted into a code block. For example, if the
condition is ‘A > B’, the code block is ‘{|| A > B}’
If there is a get function like the above one, screen I/O may be performed like the following example:
|function do_some_editing()
|
|
// define a variable to use as a get objects array
|
// and initialise it to the empty array
|
local aoGet := {}
|
...
|
|
...
|
// add a new get object to the get objects array
|
get(;
|
aoGet,;
|
10, 10,;
|
{ |x| iif( pcount() > 0, myVariable := x, myVariable },;
|
"@s30@",;
|
"gb+/b, n/w,
n, n, w/n",;
|
{ || .T. },;
|
{ || .T. };
|
)
|
|
...
|
// read the get objects array
|
readmodal( aoGet )
|
|
// clear the get objects array
|
aoGet := {}
|
|
...
|
return ...
If the function ‘GET()’ is not liked, the above I/O may be done as it
follows:
|function do_some_editing()
|
|
// define a variable to use as a get object
|
local aoGet
|
|
// define a variable to use as a get objects array
|
// and initialise it to the empty array
|
local aoGet := {}
|
...
|
|
...
|
// add a new get object to the get objects array
|
|
oGet :=;
|
GETENV(;
|
10, 10,;
|
{ |x| iif( pcount() > 0, myVariable := x, myVariable },;
|
NIL,;
|
"@s30@",;
|
"gb+/b, n/w,
n, n, w/n",;
|
)
|
AADD( aoGet, oGet )
|
|
...
|
// read the get objects array
|
readmodal( aoGet )
|
|
// clear the get objects array
|
aoGet := {}
|
|
...
|
return ...
«
|
[
]|
exp_list
|
|qout([exp_list])
|
|
|??
[exp_list]|
|
|qqout([exp_list])
|
@...BOX
«
|
|@ nTop, nLeft, nBottom, nRight BOX cnBoxString
[cnBoxString], [cColorString
]|)
@...GET
«
|
|@ nTop, nLeft GET Var
[
][
PICTURE cGetPicture
←֓
֒→ WHEN lPreExpression
[
] [VALID
1262
]
COLOR cColorString
]|
lPostExpression
|
|setpos(nTop, nLeft)
|
|
|aadd( GetList, _GET_( Var, "Var", cGetPicture,
[
]
{|| lPostExpression} ,←֓
֒→ {|| lPreExpression} ):display() ) atail(GetList):colorDisp(cColorStri
[
]
|
This is the command substitution made automatically, but it
shouldn’t be used to make clean programs. The step 4 (u0.1) suggests to create a get function.
@...SAY
«
|
|@ nTop, nLeft SAY exp
[COLOR
]|
cColorString
|
|devpos(nTop, nLeft)
|
|
|devout(exp
[,
]
cColorString )
|
|
|@ nTop, nLeft SAY exp PICTURE cSayPicture
[COLOR
]|
cColorString
|
|devpos(nTop, nLeft)
|
|
|devoutpic(exp, cSayPicture,
[cColorString]|)
@...TO
«
Step 5: trying to stop using commands
To stop using commands, it is important to understand how commands are or may be translated into functions. Sometimes Clipper
uses some undocumented functions: these are functions that start
with a underline.
]|
cColorString
|
|dispbox(nTop, nLeft, nBottom, nRight,
|
|@ nTop, nLeft TO nBottom, nRight DOUBLE
«
[COLOR
[COLOR
]|
cColorString
|
|dispbox(nTop, nLeft, nBottom, nRight, 2
[,cColorString])|
|
|@ nTop, nLeft TO nBottom, nRight
[COLOR
1263
]|
cColorString