***************************************************************************** * Procedure : ArrayTotext * Author : LOH * Purpose : To convert an array to a text string * Date : 19/08/2002 * Parameters: taArray * Returns : Text string ***************************************************************************** Function ArrayToText Lparameters taArray Local lnRows, lnCols, lnColCounter, lnRowCounter, lcText, lcSeparator Local Array laArray(1) lcSeparator = Chr(0) =Acopy(taArray, laArray) * How many rows does the array have ? lnRows = Alen(laArray, 1) * How many columns does this array have ? lnCols = Alen(laArray, 2) * Alen returns 0 if the array is one-dimensional If lnCols = 0 lnCols = 1 Endif * Initialise our target variable lcText = "" * Record the array size lcText = Transform(lnRows) + lcSeparator + Transform(lnCols) + Chr(13) * Record the variable type of each column For lnColCounter = 1 To lnCols lcText = lcText + Iif(lnColCounter > 1, lcSeparator, "") + VarType(laArray(1,lnColCounter)) EndFor lcText = lcText + Chr(13) * Now write out the contents of each row of the array For lnRowCounter = 1 To lnRows lcText = lcText + Iif(lnRowCounter > 1, Chr(13), "") If lnCols = 1 lcText = lcText + Transform(laArray(lnRowCounter)) Else For lnColCounter = 1 To lnCols lcText = lcText + Iif(lnColCounter > 1, lcSeparator, "") + Transform(laArray(lnRowCounter, lnColCounter)) EndFor Endif EndFor Return lcText EndFunc ***************************************************************************** * Procedure : TextToArray * Author : LOH * Purpose : To convert a text string to an array * Date : 19/08/2002 * Parameters: taTargetArray, tcText * Returns : The number of elements in the array ***************************************************************************** Function TextToArray Lparameters taTargetArray, tcText Local Array laTextRows(1), laElements(1), laTypes(1) Local lnTextRows, lnElements, lnNumRows, lnNumCols, lnTypes, lcSeparator lcSeparator = Chr(0) * Break the textual description of the array up into rows lnTextRows = ALines(laTextRows, tcText) * We must have at least 3 rows If lnTextRows < 3 Return 0 EndIf * What is the size of the array? lnElements = ALines(laElements, laTextRows(1), .T., lcSeparator) * There can be only 2 elements in this array, the number of rows and the number of columns If lnElements != 2 Return 0 EndIf * Record the size of the target array lnNumRows = Val(laElements(1)) lnNumCols = Val(laElements(2)) * Check the number of rows If lnNumRows != (lnTextRows -2) Return 0 Endif * What data types do we have? lnTypes = ALines(laTypes, laTextRows(2), .T., lcSeparator) * We must have a type for each column If lnTypes != lnNumCols Return 0 EndIf * Check that each type is a valid one For lnCounter = 1 To lnTypes If !(laTypes(lnCounter) $ "CNDTL") Return 0 Endif EndFor * The remaining rows of text must contain the same number of elements as the array has of columns For lnCounter = 3 To lnTextRows lnElements = ALines(laElements, laTextRows(lnCounter), .T., lcSeparator) If lnElements != lnNumCols Return 0 EndIf EndFor * Having got to here with no errors, we can re-size the target array .... Dimension taTargetArray(lnNumRows, lnNumCols) * ..... and pull in the data For lnCounter = 1 To lnNumRows If lnNumCols = 1 taTargetArray(lnCounter) = ConvertData(laTextRows(lnCounter+2), laTypes(1)) Else lnNumElements = ALines(laElements, laTextRows(lnCounter+2), .T., lcSeparator) For lnColCounter = 1 To lnNumCols taTargetArray(lnCounter, lnColCounter) = ConvertData(laElements(lnColCounter), laTypes(lnColCounter)) EndFor Endif EndFor * Return the number of elements in the array Return Alen(taTargetArray,0) EndFunc ***************************************************************************** * Procedure : ConvertData * Author : LOH * Purpose : Convert text data to the target data type * Date : 19/08/2002 * Parameters: leData, lcType * Returns : The converted data ***************************************************************************** Function ConvertData Lparameters leData, lcType Do Case Case lcType = "C" Return leData Case lcType = "N" Return Val(leData) Case lcType = "D" Return CToD(leData) Case lcType = "T" Return CToT(leData) Case lcType = "L" Return leData = ".T." EndCase EndFunc>I am converting a single tier application into nTier, it needs to work as a "local" application and also accross a WAN using COM+