ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

Forum AtoutFox : Re: Récupération paramètres d'un form   

Sujet

rss Flux RSS des derniers messages

Vous devez vous identifier pour pouvoir poser une question ou répondre.

jeu. 03 mai 2012, 18h44

FoxInCloud (Th. Nivelet)
France France

atoutfox.public.association

Re: Récupération paramètres d'un form

Merci Gregory, excellente suggestion

Le jeu. 03 mai 2012, 17h25 Gregory a écrit :
>
> FUNCTION cLitteral N && Littéral VFP de type numérique
> LPARAMETERS ;
> tuData,; && Nombre à convertir en littéral
> lcVarType
>
> LOCAL lcPoint, llPoint
>
> lcPoint = Set('POINT') && for 'YN'
> llPoint = NOT m.lcPoint == '.'
> IF m.llPoint
> SET POINT TO '.'
> ENDIF
> tuData = Iif(m.lcVarType = 'Y', '$' + Alltrim(Str(m.tuData, 200, 6)),
> Transform(m.tuData))
> IF m.llPoint
> SET POINT TO m.lcPoint
> ENDIF
>
> RETURN m.tuData
>
>
> Au lieu de jouer avec lcPoint, llPoint
>
> tuData = strtran(Iif(m.lcVarType = 'Y', '$' + Alltrim(Str(m.tuData, 200, 6)), Transform(m.tuData)), set('point'), '. ')
>
>
>
>
> Gregory
>
> "Thierry N" wrote in message news:jnu58e$26dt$1@news.niouzes.net...
>
> Correctifs...
* cParams = m.cParams + '+m.t' + padl(m.i, 2, '0')

cParams = m.cParams + '+Transform(m.t' + padl(m.i, 2, '0') + ')'
&& l'idéal serait d'utiliser une fonction qui fabrique un Litteral
&& ci-joint un exemple
cParams = m.cParams + '+cLitteral(m.t' + padl(m.i, 2, '0') + ')'
* thisForm.mesParametres = &cParams

thisForm.mesParametres = Evaluate(m.cParams)
* ===================================================================

FUNCTION cLitteral && Littéral VFP
LPARAMETERS ;
tuData, ; && Valeur à convertir en littéral (type supportés : tous
soit CDGLNOQTUXY)
tlRTrim,;  && [.F.] si type C, ôter les espaces à droite
tnTronc,; && [aucun] si type C, nombre de caractères de troncature
tlXML && [.F.] Encoder pour support XML
#IF .F. && Vartype VFP9
C && Character, Memo, Varchar, Varchar (Binary)
D && Date
G && General
L && Logical
N && Numeric, Float, Double, or Integer
O && Object
Q && Blob, Varbinary
T && DateTime
U && Unknown or variable does not exist
X && Null
Y && Currency
#ENDIF
LOCAL lcVarType
lcVarType = Vartype(m.tuData)
RETURN ICase(;
Type('tuData', 1) == 'A',;
cListOfArray(@m.tuData,,-1,.T.,.T.,.T.,.T.),;
m.lcVarType == 'C',;
cLitteral C(m.tuData, m.tlRTrim, m.tnTronc, m.tlXML),;
m.lcVarType == 'L',;
Iif(m.tuData, '.T.', '.F.'),;
m.lcVarType $ 'DT',;
cLitteralDTStrict(m.tuData),;
m.lcVarType $ 'YN',;
cLitteral N(m.tuData, m.lcVarType),;
m.lcVarType == 'X',;
'.NULL.',;
m.lcVarType == 'O',;
cLitteral O(m.tuData),;
m.lcVarType == 'G',;
'General',;
m.lcVarType == 'Q',;
'Blob, Varbinary',;
'Unknown type';
)
* -----------------------------------------------------------------

FUNCTION cLitteral C && Littéral VFP de type caractère
LPARAMETERS ;
tcData, ; && Valeur à convertir en littéral (type supportés : tous
soit CDGLNOQTUXY)
tlRTrim,;  && [.F.] si type C, ôter les espaces à droite
tnTronc,; && [aucun] si type C, nombre de caractères de troncature
tlXML && [.F.] Encoder pour support XML
LOCAL lnData
lnData = Lenc(m.tcData)
tcData = Iif(Vartype(m.tlRTrim) == 'L' AND m.tlRTrim, Trim(m.tcData),
m.tcData)
tcData = Iif(Vartype(m.tlXML) == 'L' AND m.tlXML,
cEscaped XML(m.tcData), m.tcData)
IF Vartype(m.tnTronc) == 'N'
tnTronc = Iif(Between(m.tnTronc, 1, 255), Int(m.tnTronc), 255) &&
Maximum length of a string litteral : 255)
tcData = Iif(m.lnData > m.tnTronc, cTronc(m.tcData, m.tnTronc), m.tcData)
RETURN cLitteral C (m.tcData)
ELSE
IF m.lnData <= 255
RETURN cLitteral C (m.tcData)
ELSE
LOCAL lcData, lcResult
lcResult = Space(0)
lcData = m.tcData
DO WHILE m.lnData > 0
lcResult = m.lcResult + '+' + cLitteral C (Substr(m.lcData, 1, 255))
lcData = Substr(m.lcData, 256)
lnData = m.lnData - 255
ENDDO
RETURN Substr(m.lcResult, 2)
ENDIF
ENDIF
* -----------------------------------------------------------------

FUNCTION cLitteral C (tcData)
RETURN ICase(;
NOT ["] $ m.tcData,;
["] + m.tcData + ["],; && Le plus généralement accepté
NOT ['] $ m.tcData,;
['] + m.tcData + ['],;
NOT ('[' $ m.tcData OR ']' $ m.tcData),;
'[' + m.tcData + ']',;
Space(0);
)
* -----------------------------------------------------------------

FUNCTION cLitteral N && Littéral VFP de type numérique
LPARAMETERS ;
tuData,; && Nombre à convertir en littéral
lcVarType
LOCAL lcPoint, llPoint
lcPoint = Set('POINT') && for 'YN'
llPoint = NOT m.lcPoint == '.'
IF m.llPoint
SET POINT TO '.'
ENDIF
tuData = Iif(m.lcVarType = 'Y', '$' + Alltrim(Str(m.tuData, 200, 6)),
Transform(m.tuData))
IF m.llPoint
SET POINT TO m.lcPoint
ENDIF
RETURN m.tuData
* -----------------------------------------------------------------

FUNCTION cLitteral O && Littéral VFP de type objet
LPARAMETERS tuData && Objet à convertir en littéral
LOCAL lcResult
DO CASE
CASE Type('m.tuData.name') == 'C'
lcResult = m.tuData.name
LOCAL loObject
loObject = tuData
DO WHILE Type('m.loObject.parent') = 'O' ;
AND PemStatus(m.loObject.parent, 'name', 5)
loObject = m.loObject.parent
lcResult = m.loObject.name + '.' + m.lcResult
ENDDO
lcResult = "address: " + m.lcResult
CASE Type('m.tuData.class') == 'C'
lcResult = "class: " + m.tuData.class
OTHERWISE
lcResult = "unknown name and class"
ENDCASE
RETURN "Object of " + m.lcResult

>
>
>
>
> Le 03/05/12 16:19, Cédric a écrit :
> > Bonjour,
> >
> > en effet, autant les noms des params sur le form sont disparates, autant
> > on peut les mettre de manière unique dans la classe de base, pas pensé !
> >
> > On va essayer dans ce sens
> >
> > Merci bcp =)
> >
> > Cédric
> >
> >
> >
> > Le 03/05/2012 15:25, Thierry N a écrit :
> >> Dans la classe de base:
> >>
PROCEDURE INIT
LPARAMETER t01, t02, t03, t04, etc.
IF pCount() > 0
cParams = ''
FOR i = 1 TO pCount()
cParams = m.cParams + '+m.t' + padl(m.i, 2, '0')
ENDFOR
cParams = substr(m.cParams, 2) && ôte le '+' initial
thisForm.mesParametres = &cParams
ENDIF

> >>
> >> Dans la sous-classe :
PROCEDURE INIT
LPARAMETER toto, titi, tutu
DoDefault(m.toto, m.titi, m.tutu)

> >>
> >> Le 03/05/12 14:42, Cédric a écrit :
> >>> Bonjour,
> >>>
> >>> Nous cherchons à récupérer de manière générique les paramètres passés à
> >>> un formulaire, pour stocker cette chaine de paramètres qque part
> >>> (propriété du form ou autre). On considère que tout formulaire est basé
> >>> sur une même classe de base et chaque formulaire peut avoir de 0 à x
> >>> paramètres reçus, avec des noms divers et variés...
> >>>
> >>> Si on avait eu un truc du genre ThisForm.MesParametres = PARAM(1) +
> >>> PARAM(2) + ... (selon PCOUNT), cela nous aurait bien plus mais on n'a
> >>> pas trouvé, on sèche...
> >>>
> >>> Si qqun a une idée !
> >>>
> >>> Merci
> >>>
> >>> Cédric
> >
>


Permalink : http://www.atoutfox.org/nntp.asp?ID=0000008897
20 286 messages dans le forum • Liste complète des messages

www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2026.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3