none
Array Question

    Question

  • I have read some very good tech articles on Arrays but have not found an explanation for how and when to use an array such as Nonki used in his program NVH911 (example listed below)

    jointType = "1=Head;2=Neck;3=SpineShoulder;4=SpineMid;5=SpineBase;"

    Have also seen something similar in calculator program SNG664 on Simple-Talk.com.

    This looks like a good method to use one array entry to convey several items about a variable.

    Can someone explain how to use, load, access these types of array entries?

    Tuesday, January 10, 2017 3:25 PM

Answers

  • If you use jointType[2] in your program the value is "Neck"

    e.g. you can list all values of this Array:

    for i=1 to Array.GetItemCount(jointType)

      TextWindow.WriteLine(jointType[i])

    endFor


    Jan [ WhTurner ] The Netherlands

    • Marked as answer by jswlhw Tuesday, January 10, 2017 9:33 PM
    Tuesday, January 10, 2017 4:09 PM
    Answerer
  • You can use arrays with other then numerical keys! 

    So ButtonValue="legend=mc;key=none;alt=none;act=mem;color=dimGray;" works also.

    You get then  ButtonValue["act"]= mem or even  key3="act"  and then use ButtonValue[key3]

    The drawback is that the use in a For-loop is not possible, without the use of  Array.GetAllIndices()

    The backslashes are in the internal representation of arrays. 


    Jan [ WhTurner ] The Netherlands

    • Marked as answer by jswlhw Wednesday, January 11, 2017 2:07 PM
    Wednesday, January 11, 2017 10:33 AM
    Answerer

All replies

  • If you use jointType[2] in your program the value is "Neck"

    e.g. you can list all values of this Array:

    for i=1 to Array.GetItemCount(jointType)

      TextWindow.WriteLine(jointType[i])

    endFor


    Jan [ WhTurner ] The Netherlands

    • Marked as answer by jswlhw Tuesday, January 10, 2017 9:33 PM
    Tuesday, January 10, 2017 4:09 PM
    Answerer
  • So the other way to write the array below:

    ButtonValue[1]="legend=mc;key=none;alt=none;act=mem;color=dimGray;"

    WOULD be:

    ButtonValue[1]["legend"]= mc

    ButtonValue[1]["key"] = none

    ButtonValue[1]["alt"] = none

    etc ?

    If you do just print ButtonValue[1]

    it does show the rest of the values with the index and back slashes. 

    Thanks Jan

    Tuesday, January 10, 2017 9:33 PM
  • You can use arrays with other then numerical keys! 

    So ButtonValue="legend=mc;key=none;alt=none;act=mem;color=dimGray;" works also.

    You get then  ButtonValue["act"]= mem or even  key3="act"  and then use ButtonValue[key3]

    The drawback is that the use in a For-loop is not possible, without the use of  Array.GetAllIndices()

    The backslashes are in the internal representation of arrays. 


    Jan [ WhTurner ] The Netherlands

    • Marked as answer by jswlhw Wednesday, January 11, 2017 2:07 PM
    Wednesday, January 11, 2017 10:33 AM
    Answerer