title: Python. How to call a function that expect ctypes array. Strand/Straus7
body: <p>I'm using python scripting for Strand/Straus7 importing his DLL.</p>
  
  <p>I'm trying to call a function for set the units, called St7SetUnits, following the manual (<a href="https://i.stack.imgur.com/1Pogu.png" rel="nofollow noreferrer">Img.1</a>) and watching the <em>.py</em> scripting of the DLL that I imported (<a href="https://i.stack.imgur.com/a1gc3.png" rel="nofollow noreferrer">Img.2</a>). The function expected a <em>c_long</em> and a <em>ctypes.POINTER.(c_long)</em>, as specify in the script (<a href="https://i.stack.imgur.com/ZqZNL.png" rel="nofollow noreferrer">Img.3</a>)</p>
  
  <p>Here the complete manual  strand7.com/downloads/Strand7%20R246%20API%20Manual%20TOC.pdf</p>
  
  <p>and here the <em>.py</em> scripting <a href="https://www.dropbox.com/s/88plz2funjqy1vb/St7API.py?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/88plz2funjqy1vb/St7API.py?dl=0</a></p>
  
  <p>As specify at the beginning of the manual I have to convert the list in ctypes array (<a href="https://i.stack.imgur.com/W8JWJ.png" rel="nofollow noreferrer">Img.4</a>).
  The function I call is the same of the example, but I can't call it correctly.
  I write</p>
  
  <pre><code>import St7API as SA
  import ctypes 
  
  SA.St7Init()
  
  unitsArray = ctypes.c_int * SA.kLastUnit
  units = unitsArray()
  units[0] = 0
  units[1] = 1
  units[2] = 3
  units[3] = 1
  units[4] = 1
  units[5] = 2
  SA.St7SetUnits(1, units)
  </code></pre>
  
  <p>But returns error</p>
  
  <pre><code>expected c_long, got c_long_Array_6
  </code></pre>
  
  <p>If I try something else, for example an int from the array</p>
  
  <pre><code>SA.St7SetUnits(1, units[0])
  </code></pre>
  
  <p>the error change in</p>
  
  <pre><code> expected LP_c_long, got int
  </code></pre>
  
  <p>I tried many solution, but no one works.</p>
  
  <p>Can anyone help me?</p>
  
  <p>Thanks a lot</p>