MAL.Set |
![]() ![]() |
ref_arr_out = MAL.Set( BYREF arr_out AS ARRAY, BYREF arr_in AS ARRAY, [BYVAL nPoint AS INTEGER=ML_ALL], [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE
ref_arr_out = MAL.Set( BYREF arr_out AS ARRAY, [BYVAL value AS REAL=0], [BYVAL nPoint AS INTEGER=ML_ALL], [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE
ref_arr_out = MAL.Set( BYREF arr_out AS ARRAY, BYVAL valueX AS REAL, [BYVAL valueY AS REAL=valueX], [BYVAL nPoint AS INTEGER=ML_ALL], [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE
ref_arr_out = MAL.Set( BYREF arr_out AS ARRAY, BYVAL valueX AS REAL, [BYVAL valueY AS REAL=valueX], [BYVAL valueZ AS REAL=valueX], [BYVAL nPoint AS INTEGER=ML_ALL], [BYVAL nFrameOffset AS INTEGER=0] ) AS REFERENCE
ref_arr_out = MAL.Set( BYREF arr_out AS ARRAY, BYVAL vixa_out AS INTEGER, BYREF arr_in AS ARRAY, BYVAL vixa_in AS INTEGER, [BYVAL nFrames AS INTEGER=ML_ALL] ) AS REFERENCE
ref_arr_out = MAL.Set( BYREF arr_out AS ARRAY, BYVAL vixa_out AS INTEGER, [BYVAL value AS REAL=0], [BYVAL nFrames AS INTEGER=ML_ALL] ) AS REFERENCE
Copy an array (first syntax) or initialize an array with a 1D , 2D or 3D value. If he output array is a multipoint array, then you can use the nPoint argument to specify the point number (or channel) to initialize. The default is to initialize all.
Using the first syntax and the 2 arrays have the same number of array elements and the points and frame offsets are omitted, the function will do a "raw copy" of the elements allowing one array tpo be converted to another array with different dimensions. For example;
DIM tm( 3, 3 ) AS REAL DIM vec( 9 ) AS REAL ' Convert the vec(9) to a (3,3) tranformation matrix MAL.Set( tm, vec )
Note 1; This function does not accept NULL as output array since it would create ambiguities and would not be very useful . Note 2; Point numbers always starts at 1. Frame offsets always starts at 0 (no offset).
Example:
OPTION EXPLICIT ON OPTION BASE 1
' Include the MaxMAL Library $INCLUDE "MyBASIC2_MaxMAL" $LIBRARY "MyBASIC2_MaxMALLib"
' Forward Declare PrintArray DECLARE SUB PrintArray
' Declare variables and arrays DIM Nisse(8,4,3) AS REAL DIM Pelle(8,4,3) AS REAL DIM Kalle AS REFERENCE
' Initialize Nisse to all 0 MAL.Set( Nisse ) CALL PrintArray( REF( Nisse ) )
' Initialize Pelle to all 8 MAL.Set( Pelle, 8 ) CALL PrintArray( REF( Pelle ) )
' Create and initialize point 2 and 3 starting at frame (Offset 4 -> 0 based) Kalle = MAL.Set( NEW( REAL, 8, 4, 3 ), 3, 1, 4, PTS( 2, 3 ), 4 ) CALL PrintArray( Kalle )
' Assign Nisse to this the dynamic Array using MyBASIC2 LET statement LET Nisse = Kalle CALL PrintArray( REF( Nisse ) )
' Assign Pelle to the Dynamic Kalle array using MaxMAL MAL.Set( Pelle, Kalle ) CALL PrintArray( REF( Pelle ) )
END
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Print an array with up to 3 dimensions. Array is passed as a reference ' SUB PrintArray( arr AS REFERENCE ) DIM i AS INTEGER ' Frames DIM j AS INTEGER ' Dimensions DIM n AS INTEGER ' Points
PRINT "-----------------------------------------------------", PRINT FORMAT( "%-12s|", VARNAME( arr ) )
FOR n = 1 TO LEN( arr, 2 ) PRINT " Point ";n;" |"; ENDFOR PRINT ,"-----------------------------------------------------", FOR i = 1 TO LEN( arr, 3 ) IF i < 10 THEN PRINT "Frame[";i;"] = | "; ELSE PRINT "Frame[";i;"] = | "; ENDIF
FOR n = 1 TO LEN( arr, 2 ) FOR j = 1 TO LEN( arr, 1 ) PRINT arr( i, n, j ) IF j < LEN( arr, 1 ) THEN PRINT ", " ENDIF ENDFOR PRINT " | " ENDFOR PRINT , ENDFOR PRINT "-----------------------------------------------------", END SUB
|