Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I return an array from a form?
Message
 
À
18/01/1999 05:21:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00177095
Message ID:
00177501
Vues:
38
>Hi everybody!
>
>Is there any way to return an array from a form?
>For example, I call a form with...
>
>local laArray[10],laRetArray[10]
>do form Form1 with laArray to laRetArray
>
>... and in its Init event do the following:
>thisform.aItems = taParamArray
>
>( aItems defined as aItems[10,0] )
>When I, in form's Unload event trying to
>...
>...
>return thisform.aItems
>
>it fills the laRetArray with first item's value
>
>Any suggestions?
>
>TIA.
>
>Uri.

Uri,

You'll find some code hereafter that illustrates how I pass arrays to a mover form and return them. I don't like the implementation too much because it involves a PUBLIC array, and the default data session. Therefore I allow this for limited maintenance operations.

My regards to Eylon,

José
*-------------------------------------------------------
Click() method of a Codebook menu

LOCAL loSelect, ;
loChoix, ;
lnRecCnt, ;
lnRetVal, ;
lnIsChanged

loChoix = CREATEOBJECT("ChoixObj")
*-- instantiates a bizobj. Its role is just to provide us a DataEnvironment

IF TYPE( "loChoix") = "O"
*-- on continue
loSelect = CREATEOBJECT( "cSelect", loChoix.cAlias)
Requery()
lnRecCnt = RECCOUNT()
IF lnRecCnt > 0
*-- on continue
IF TYPE("gaSelVehicule") # "U"
=ErrorMsg(MVRINUSEBYANOTHER_LOC)
loChoix.Release()
loChoix = .NULL.
*-- we are on a default datasession
IF USED("Vehicule")
USE IN Vehicule
ENDIF
RETURN .F.
ENDIF

PUBLIC gaSelVehicule[1,2]
DIME laAllVehicule[lnRecCnt,2]

gaSelVehicule[1,1] = ""
gaSelVehicule[1,2] = ""

*-- fill laAllVehicule
SET ORDER TO && order by cVin in query
i = 0
SCAN
i = i + 1
laAllVehicule[ i, 1] = cShortVin
laAllVehicule[ i, 2] = cId
ENDSCAN

*-- call mover
=MOVER(@laAllVehicule, @gaSelVehicule, .T., "Sélection Véhicules crédités à repasser dans le stock")

*-- release asap
Release laAllVehicule

SELECT v_Choix
SET ORDER TO TAG 1

FOR i = 1 TO ALEN( gaSelVehicule, 1)
IF ! EMPTY( gaSelVehicule[i, 2]) AND SEEK( gaSelVehicule[i, 2], "v_Choix")

lcField = loChoix.cAlias + ".mMemo"
REPLACE &lcField WITH EVAL( lcField) + ;
IIF(EMPTY( EVAL( lcField)), "" , CHR(13) + CHR(10)) + ;
"Note de crédit N°: " + v_Choix.cFacSortie + ;
" Client: " + ALLTRIM( v_Choix.cClientId) + ;
" du: " + DTOC( v_Choix.dVente)
lcField = loChoix.cAlias + ".cFacSortie"
REPLACE &lcField WITH ""
lcField = loChoix.cAlias + ".lFacValide"
REPLACE &lcField WITH .F.
lcField = loChoix.cAlias + ".dVente"
REPLACE &lcField WITH { / / }
lcField = loChoix.cAlias + ".lNCEncours"
REPLACE &lcField WITH .F.
lcField = loChoix.cAlias + ".lStock"
REPLACE &lcField WITH .T.
lcField = loChoix.cAlias + ".lStockValide"
REPLACE &lcField WITH .T.
ENDIF
ENDFOR

Release gaSelVehicule
lnIsChanged = loChoix.isChanged()

IF lnIsChanged
lnRetVal = loChoix.Save()
IF lnRetVal = FILE_OK
WAIT WINDOW NOWAIT "Information sauvegardée"
ENDIF
ENDIF
loChoix.Release()
loChoix = .NULL.
*-- we are on a default datasession
IF USED("Vehicule")
USE IN Vehicule
ENDIF
ELSE
ErrorMsg( NORECORDS_LOC)
ENDIF
ELSE
*-- error
WAIT WINDOW NOWAIT "Erreur d'instanciation de ChoixObj"
RETURN .F.
ENDIF

RETURN .T.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform