FoxDataObjects

Object-Relational Mapping Tool for Visual FoxPro®

 ArrayToString  Method

 

 

Serializes an Array into a binary stream and returns a string value.

 Session.ArrayToString( @aArray )

 

Parameters

 

aArray

 

Array passed by reference.

Return Value

 

String

Remarks

 

This method receives an Array passed by reference, serializes all the array contents into a binary stream and returns the serialized string representation. All the process is done at FLL C++ library level so it performs as fast as native VFP functions.

The serialized string can be used to store the array in a Field Table or to pass the array between application tiers.

All value types within array positions are serialized with an special exception on objects pointers: Objects pointers are stored in the serialized string only if they points to a Persistent object (an object with a valid Object_ID value) at parse time. Actually, only the Object_id value is stored on the serialized stream for such objects.

The Session.StringToArray method is used to fill an array back from the serialized string.

 

Example

DIMENSION myArray[2,3]

 

myArray[1,1]=344

myArray[1,2]="Character value"

myArray[2,3]=DATE()

 

cMyArrayStr=oSession.ArrayToString(@myArray)

 

 

DIMENSION MyArrayIsBack[1]

oSession.StringToArray(cMyArrayStr,@MyArrayIsBack)

 

? MyArrayIsBack[2,3]

 

 

This sample creates an array, fills some positions with values and uses the Session.ArrayToString method to get a string representation of the array contents.
Then , another array is filled from the serialized string using the Session.StringToArray method.

Note both methods receive an array as a parameter passed by reference. Also note the StringToArray method  resizes the array to the dimensions stored on the string.

 

See Also

Session.StringToArray method | Session.ObjectToString method | Session.StringToObject method

Applies to: Session object

Send feedback on this topic to RunAhead Technologies

For Technical support and product issues please contact us at support@foxdataobjects.com or visit http://www.foxdataobjects.com

Copyright (c) 2000-2005 RunAhead Technologies