DEFINE CLASS test as Custom OLEPUBLIC oWM = NULL oSAS = NULL PROCEDURE AddRow(tcDesc, tcValue) INSERT INTO test_it (when, desc, value) values(DATETIME(),; TRANSFORM(tcDesc), TRANSFORM(tcValue)) ENDPROC PROCEDURE Main() IF NOT used('test_it') CREATE TABLE test_it (pk i autoinc, when t, desc c(20), value c(100)) ENDIF This.AddRow('Start Main', 'Testing') This.oWM = CREATEOBJECT('SASWorkspaceManager.WorkspaceManager') oServerDef = CREATEOBJECT('SASWorkspaceManager.ServerDef') oServerDef.Protocol = 2 && PROTOCOLBRIDGE oServerDef.MachineDNSName = 'machinename' oServerDef.Port = 12010 errorstring = '' This.oSAS = This.oWM.Workspaces.CreateWorkspaceByServer("UnixName",; 1, oServerDef, "username", "password", errorString) oLibRef = This.oSAS.DataService.AssignLibref("unixlib","","/m01/usx714a","") This.AddRow('olibref.name', olibref.name) *-- all above works fine DIMENSION lax[2] AS string lax = 'a' && force to a string This.CallSAS( @lax ) FOR lni = 1 TO ALEN( lax,1 ) This.AddRow('lax['+ALLTRIM(STR(lni)) + ']', lax[lni]) NEXT PROCEDURE CallSAS( ax[] AS String @) TRY *-- tried ComArray as 10 and 11 COMARRAY( This.oSAS.DataService, 10 ) this.oSAS.DataService.ListLibrefs( @ax ) FOR lni = 1 TO ALEN( ax,1 ) This.AddRow('ax['+ALLTRIM(STR(lni)) + ']', ax[lni]) NEXT CATCH FINALLY *-- shut down SAS this.oWM.WorkSpaces.RemoveWorkSpace( This.oSAS) This.oSAS.Close() ENDTRY RETURN ax ENDPROC ENDDEFINEhere is an extract from the help file related to using Safe Arrays:
cArrayName[] [AS Type ][@][AS Type] Specifies the name of the array used in the creation of a type library using the first AS Type clause. Using the cArrayName[] [AS Type][@] clause, you can specify strong typing for arrays so they can be correctly written as safe arrays to a type library. For example: DEFINE CLASS foo AS Session OLEPUBLIC PROCEDURE GetWidgets1(aWidgets[]) ENDPROC PROCEDURE GetWidgets2(aWidgets[] AS Integer) ENDPROC PROCEDURE GetWidgets3(aWidgets[] AS Integer @) ENDPROC PROCEDURE GetRS(oRS[] AS ADODB.RECORDSET @) ENDPROC ENDDEFINE Note Strong typing for arrays is used primarily for type library creation and is not enforced at run time. The type that you specify must be a valid COM data type (see the previous table). The type can also be a reference to a COM CoClass ProgID such as ADODB.Recordset. If you specify an argument for the first AS Type clause, Visual FoxPro creates a SAFEARRAY with the specified type. If you do not specify an argument for the first AS Type clause, Visual FoxPro creates a SAFEARRAY of Variant data types. If the type specified is invalid, Visual FoxPro defaults to using the Variant data type. Note When specifying an array, you must use square brackets ([]); DEFINE CLASS does not recognize parentheses (()) notation. A safe array is a one or multidimensional array of a single data type, which can be of type VARIANT, allowing you to create arrays of mixed types. The safe array stores its lower bound, which does not have to be zero, and its size. Safe arrays allow locking and unlocking so you can be sure that the pointer you receive to the data is valid.