[pycon] AuxArrayTestUDF

Viewer

copydownloadembedprintName: AuxArrayTestUDF
  1. scn AuxArrayTestUDF
  2.  
  3.  
  4.  
  5. array_var aArray
  6. int iSize
  7. int iIndex
  8.  
  9. int iNum
  10. string_var sv_Type
  11. string_var sv_Temp
  12.  
  13. short bSkip
  14.  
  15. begin Function {bSkip}
  16.  
  17.  
  18.         print "== Beginning MultiDimensional AuxVar Test =="
  19.  
  20.         let aArray := ar_construct "array"
  21.         let aArray[0] := ar_construct "array"
  22.         let aArray[1] := ar_construct "array"
  23.  
  24.         let aArray[0][1] := 154
  25.         let aArray[0][2] := 30
  26.  
  27.         let aArray[1][1] := 14
  28.         let aArray[1][2] := 63
  29.  
  30. ;--------------------
  31.  
  32. if bSkip != 1
  33.  
  34.         print "== Checking starting array == "
  35.  
  36.         let iSize := ar_size aArray
  37.         print "Ar Size: " + $iSize
  38.         ar_dump aArray
  39.  
  40.         let iIndex := -1
  41.         while (iIndex += 1) < iSize               
  42.                 let sv_Type := TypeOf aArray[iIndex]
  43.  
  44.                 ;---The code below accurately returns code "Array", and ar_dump aArray[iIndex] performs as expected---;
  45.  
  46.                 if eval (sv_Type) == "Array" 
  47.                         ar_dump aArray[iIndex]
  48.                 else
  49.                         print "ERROR: The type of content held at Index #" + $iIndex + " is: " + $sv_Type
  50.                         print "It should be type Array"
  51.                 endif
  52.         loop
  53.  
  54. else
  55.         print "== Skipped the dump of the actual array. == "
  56. endif
  57.  
  58. ;------------
  59.  
  60.         print "== Checking converted array == "
  61.         player.AuxVarSetFromArr "someVarName" aArray 
  62.         let aArray := ar_Null
  63.  
  64.         let aArray := player.AuxiliaryVariableGetAsArray "someVarName"
  65.  
  66. ;---------------------
  67.  
  68.         let iSize := ar_size aArray
  69.         print "Ar Size: " + $iSize
  70.         ar_dump aArray
  71.  
  72.         let iIndex := -1
  73.         while (iIndex += 1) < iSize               
  74.                 let sv_Type := TypeOf aArray[iIndex]
  75.  
  76.                 ;---The code below returns an error, since type Number somehow shows up.---;
  77.  
  78.                 if eval (sv_Type) == "Array"
  79.                         ar_dump aArray[iIndex]
  80.                 else
  81.                         print "ERROR: The type of content held at Index #" + $iIndex + " is: " + $sv_Type
  82.                         print "It should be type Array"
  83.                 endif
  84.         loop
  85.  
  86.  
  87.  
  88.  
  89.         print "== End Test =="
  90.  
  91.  
  92.         sv_destruct sv_Type, sv_Temp
  93. end

Editor

You can edit this paste and save as new:


File Description
  • AuxArrayTestUDF
  • Paste Code
  • 16 Mar-2021
  • 1.8 Kb
You can Share it: