copier une variable ??

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
graph100
Messages : 1318
Inscription : sam. 21/mai/2005 17:50

copier une variable ??

Message par graph100 »

alors voila :

Code : Tout sélectionner

structure size
  a.l
  b.l
  c.s
endstructure

mavariable1.size
mavariable2.size
mavariable3.size

variable.size

for a=1 to 3
  if a = 1
    variable = mavariable1
  endif
  if a = 2
    variable = mavariable2
  endif
  if a = 3
    variable = mavariable3
  endif
next
ca ne fonctionne pas
comment fais on pour copier une variable avec une structure dans une autre variable ?
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

Guimauve
Messages : 1015
Inscription : mer. 11/févr./2004 0:32
Localisation : Québec, Canada

Message par Guimauve »

On peut faire comme suit :

Code : Tout sélectionner

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Déclaration de la Structure >>>>>

Structure MySize
   
   a.l
   b.l
   c.s
   
EndStructure

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les Macros d'accès direct >>>>>

Macro MySizea(ObjetA)
   
   ObjetA\a
   
EndMacro

Macro MySizeb(ObjetA)
   
   ObjetA\b
   
EndMacro

Macro MySizec(ObjetA)
   
   ObjetA\c
   
EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Le Mutateur Update simple >>>>>

Macro UpdateMySize(ObjetA, P_a, P_b, P_c)
   
   MySizea(ObjetA) = P_a
   MySizeb(ObjetA) = P_b
   MySizec(ObjetA) = P_c
   
EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'Opérateur Copy >>>>>

Macro CopyMySize(ObjetR, ObjetA)
   
	MySizea(ObjetR) = MySizea(ObjetA)
	MySizeb(ObjetR) = MySizeb(ObjetA)
	MySizec(ObjetR) = MySizec(ObjetA)
   
EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'Opérateur Déboggue >>>>>

Macro DeboggueMySize(ObjetA)

	Debug MySizea(ObjetA)
	Debug MySizeb(ObjetA)
	Debug MySizec(ObjetA)
   
EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

UpdateMySize(mavariable1.MySize, 5000,15000,"Allo")
UpdateMySize(mavariable2.MySize, 10000,20000,"Le monde")
UpdateMySize(mavariable3.MySize, 15000,25000,"Comment ça va ?")


variable.MySize

For a=1 To 3
   If a = 1
      CopyMySize(variable, mavariable1)
     ; variable = mavariable1
      Debug "Variable quand a = 1"
      DeboggueMySize(variable)
      
   EndIf
   If a = 2
      CopyMySize(variable, mavariable2)
      ; variable = mavariable2
      Debug "Variable quand a = 2"
      DeboggueMySize(variable)
   EndIf
   If a = 3
      CopyMySize(variable, mavariable3)
      ; variable = mavariable3
      Debug "Variable quand a = 3"
      DeboggueMySize(variable)
   EndIf
Next
A+
Guimauve
Répondre