Utilisez ACCEPT dans des fichiers programmes pour inviter l'utilisateur à effectuer une
saisie clavier de type Caractère. L'utilisateur termine la saisie des données en
appuyant sur Entrée. Si l'utilisateur appuie sur Entrée sans taper de caractères,
ACCEPT affecte une chaîne vide (" ") à <variable>.
Puisque ACCEPT affecte automatiquement le type Caractère aux saisies clavier,
l'utilisateur ne doit pas entourer la saisie entre guillemets ou crochets. Si
l'utilisateur entoure la saisie avec des délimiteurs, tels que des guillemets, les
délimiteurs sont stockés dans la chaîne.
Si SET ESCAPE est à ON, l'appui sur Echap en réponse à une commande ACCEPT termine un
programme.
Les autres commandes qui permettent aux programmes de lire des données à partir du
clavier sont INPUT et WAIT.
function accept |
|
parameter cPrompt |
|
local f, cResult |
|
f = new acceptForm() |
f.mdi = false // ensure not MDI |
f.init(cPrompt) |
|
cResult = f.readModal() |
|
return cResult |
|
** END HEADER -- do not remove this line |
// |
// Generated on 07/21/2010 |
// |
parameter bModal |
local f |
f = new acceptForm() |
if (bModal) |
f.mdi = false // ensure not MDI |
f.readModal() |
else |
f.open() |
endif |
|
class acceptForm of FORM |
with (this) |
metric = 0 // Chars |
height = 3.8182 |
left = 40.1429 |
top = 10.2727 |
width = 73.0 |
text = "" |
topMost = true |
autoCenter = true |
mdi = false |
sizeable = false |
sysMenu = false |
maximize = false |
minimize = false |
endwith |
|
this.TEXT1 = new TEXT(this) |
with (this.TEXT1) |
height = 2.0 |
left = 1.2857 |
top = 0.7273 |
width = 57.7143 |
text = "Text1" |
endwith |
|
this.ENTRYFIELD1 = new ENTRYFIELD(this) |
with (this.ENTRYFIELD1) |
height = 1.0 |
left = 60.7143 |
top = 0.6818 |
width = 11.0 |
value = "" |
maxLength = 255 |
endwith |
|
this.PUSHBUTTON1 = new PUSHBUTTON(this) |
with (this.PUSHBUTTON1) |
onClick = class::PUSHBUTTON1_ONCLICK |
height = 1.0909 |
left = 31.1429 |
top = 2.3636 |
width = 11.4286 |
text = "Ok" |
default = true |
endwith |
|
|
function init( cstr ) |
local textwidth, nWrapTrue, nWrapFalse, nLines |
|
|
cstr = left(cstr,255) |
// Get width of cstr - récupère la dimension de cStr |
textwidth = form.TEXT1.getTextExtent(cstr) |
if len(cstr) < 55 |
// nothing, default parameters are OK - rien a faire en
particulier |
else // calcul approximatif du nombre de lignes
nécessaires |
form.text1.wrap = false |
nWrapFalse = form.TEXT1.getTextExtent(cstr) |
|
form.text1.wrap = true |
nWrapTrue = form.TEXT1.getTextExtent(cstr) |
|
nLines = ceiling((nWrapFalse / nWrapTrue) + .1) |
if nlines > 2 |
nLines = (nLines - 2) *.8 |
form.height = form.height + nLines |
form.pushbutton1.top = form.pushbutton1.top + nLines |
form.text1.height = form.text1.height + nLines |
endif |
|
endif |
// Set TEXT1 to display cstr - initialise Text1 pour
afficher cStr |
form.TEXT1.text = cstr |
|
// Set width of TEXT1 to match cstr - réglage largeur pour
textt1 |
form.TEXT1.width = textwidth |
|
// Set position of ENTRYFIELD1 to be near right end of TEXT1 |
form.ENTRYFIELD1.left = form.TEXT1.left + form.TEXT1.width + 3 |
|
// Adjust form width - largeur duformulaier |
form.width = form.TEXT1.width + form.ENTRYFIELD1.width + 6 |
|
// center pushbutton - centrer OK |
form.PUSHBUTTON1.left = form.width/2 - (form.pushbutton1.width/2) |
|
return |
|
|
function PUSHBUTTON1_onClick |
form.close(form.entryfield1.value) // renvoie la valeur saisie
par l'utilisateur |
return |
|
endclass |
|
retour
Sources :
Aide Visual dbase V5.7
From: "Marty Kay"
Newsgroups: dbase.binaries
Sent: Wednesday, July 21, 2010 7:08 PM
Subject: Form to replace ACCEPT command when upgrading old dBASE code
Si vous voyez des erreurs, n'hésitez pas à le signaler.
Dernière modification : mercredi 02 novembre 2011
© M.A.