AnsweredAssumed Answered

USING C~~ how to pass frequency point to array

Question asked by JosephChoi on Aug 18, 2010
Latest reply on Aug 18, 2010 by odanzy
hi all.

i was visual basic user. im talking about frequency return.
below is previously VB code.
    Call OutputSiclLan(ENA_Address, ":SENS1:SEGM:SWE:POIN?")
    Call EnterSiclLan(ENA_Address, Number_Of_Point_ENA)    /////we just return +1227 it's hardware setting///////

    Number_of_Measurement_Point As Integer
    Number_of_Measurement_Point = CInt(Val(Number_Of_Point_ENA))    ////insert  1227

    ReDim Freq_List_result(Number_of_Measurement_Point - 1)   ///declare array
    Call OutputSiclLan(ENA_Address, ":SENS1:FREQ:DATA?")  // read out the freq point
    Dim NumData_tr As Long
    NumData_tr = EnterSiclLanArrayReal64(ENA_Address, Freq_List_result)
////////we made array for freq point and  ":SENS1:FREQ:DATA?") this command return //////
////////all frequency ,, and we just put in array Freq_List_result /////////////////////////
//////// NumData-tr return  1227  ////////////////////////////////////////////////////
////////// and below is just for your reference, class  EnterSiclLanArrayReal64////////

Public Function EnterSiclLanArrayReal64(addr As Integer, databuf() As Double) As Long

  Dim status As Integer
  Dim actualcnt As Long
  Dim buf As String * 8
  Dim size As Long
  Dim Dummy As Integer
  On Error GoTo ErrHandler

  status = SICL4_1.Iread_Equipment(addr, buf, 8, SICL_Constant.I_TERM_MAXCNT, actualcnt)
  size = Val(Mid$(buf, 3, 6))
  status = SICL4_1.Iread_Equipment(addr, databuf, size, SICL_Constant.I_TERM_MAXCNT, actualcnt)
  status = SICL4_1.Iread_Equipment(addr, buf, 1, SICL_Constant.I_TERM_MAXCNT, actualcnt)
  EnterSiclLanArrayReal64 = size / 8
  Exit Function

  Show_Error Error$, "Sub OutputSiclLan() clsENA", Show_On_Screen
  Dummy = SICL4_1.Siclcleanup_Equipment
End Function

above VB coding is working successfully. now i just want convert to C#.
below is C#  i just develop.....

myNa01.WriteString("SENS" + Channel.ToString() + ":SEGM:SWE:POIN?", true);
Number_Of_Point_ENA = myNa01.ReadString();     ///// return 1227
         int Number_Of_Point;
         Number_Of_Point = Convert.ToInt32(Number_Of_Point_ENA);   ///insert 1227
         Number_of_Measurement_Point = Convert.ToInt32(Number_Of_Point);
         float [] Freq_List_result = new float [Number_of_Measurement_Point-1];  ////make array
         myNa01.WriteString(":SENS" + Channel.ToString() + ":FREQ:DATA?", true);   ////working good,,
         Freq_List_result = (float[])myNa01.ReadIEEEBlock(IEEEBinaryType.BinaryType_R4, true, true);
         int k;                                      //////// just check number of array by Joseph.   just want know how many
         k = Freq_List_result.Length;   /////////////////it return ...k=2454...
////after using IEEEBlock  ,,i just think something wrong in my C# has to be 1227 ,,, but return 2454,,
////  need advice about this issue..