none
Array.Get Value & ors Syntax RRS feed

  • Question

  • The commands Array.GetValue, Array.SetValue and Array.RemoveValue do not show the syntax to the right of the editor.  Have also looked across the web for the syntax and been unable to find.  Can someone assist please.

    Also seems to me this is a bug and would be worth fixing in the next release.

    Regards,

    Friday, May 31, 2013 4:38 AM

Answers

  • AFAIK, those actions were deprecated. But they're still present and should work!

    But anyways, just access Arrays using square braces like : myArr[10] = 5

    To delete index 10 -> myArr[10] = ""

    And finally, to erase whole Array -> myArr = ""


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    • Proposed as answer by Allen Shmallen Saturday, June 1, 2013 3:59 AM
    • Marked as answer by Franganistan Sunday, June 2, 2013 12:47 AM
    Friday, May 31, 2013 10:37 AM
    Answerer
  • The syntax for the Array.GetValue function is:

    val = Array.GetValue(ArrayName, index)

    where ArrayName is the name of the array to be searched, index is the location in the array to get the value from, and val is the value returned from the array at the given index.

    The syntax for Array.SetValue is

    Array.SetValue(ArrayName, val, index)

    where ArrayName is the name if the array, index is the location to set the value to, and val is the value to be inserted at the given index.

    The syntax for Array.RemoveValue is

    Array.RemoveValue(ArrayName, index)

    Where ArrayName is the name of the array you wish to remove the value from and index is the location of the value you wish to remove.

    It is key to note that Array.GetValue and Array.RemoveValue will only work with values that were set using the Array.SetValue function. 


    • Proposed as answer by WriterCoder Friday, May 31, 2013 1:02 PM
    • Marked as answer by Franganistan Sunday, June 2, 2013 12:47 AM
    Friday, May 31, 2013 1:00 PM
  • These methods "must?" of been deemed superfluous to sb v1.0. Below is a copy of a post by gungan37 

    http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/b499f6d0-e3a5-4717-911f-c390ecaf508e

    Quote: "According to an ILSpy search of SmallBasicLibrary.dll, these are the methods adorned with the [HideFromIntellisenseAtrribute] attribute: 

    Array.GetValue(arrayName, index)
    Array.SetValue(arrayName, index, value)
    Array.RemoveValue(arrayName, index)
    TextWindow.ReadKey()

    I believe these only exist for backwards compatibility (that is, they were from older SB version and were later replaced but still exist so old programs will run.) " Unquote.

    You have to have a dream so you can get up in the morning. - Billy Wilder


    Friday, May 31, 2013 9:38 PM
    Moderator
  • TextWindow.ReadKey() deprecated & superfluous?

    There's no other way to read a key pressed within TextWindow!

    And besides, SB should offer a way to read current held-down keys w/o halting the program. Something like:

    TextWindow.InKey() returning an Array of current pressed keys!  :P


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Friday, May 31, 2013 10:49 PM
    Answerer
  • I reckon goto. I wonder if someone could write an ext for that, if possible. Should be native but. V1.1


    You have to have a dream so you can get up in the morning. - Billy Wilder



    Saturday, June 1, 2013 10:33 AM
    Moderator

All replies

  • This commands do not exists in the standard SmallBasic.

    Do you an extension?


    Greetings Timo


    • Edited by Timo Sö Friday, May 31, 2013 10:25 AM
    Friday, May 31, 2013 10:25 AM
  • AFAIK, those actions were deprecated. But they're still present and should work!

    But anyways, just access Arrays using square braces like : myArr[10] = 5

    To delete index 10 -> myArr[10] = ""

    And finally, to erase whole Array -> myArr = ""


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    • Proposed as answer by Allen Shmallen Saturday, June 1, 2013 3:59 AM
    • Marked as answer by Franganistan Sunday, June 2, 2013 12:47 AM
    Friday, May 31, 2013 10:37 AM
    Answerer
  • The syntax for the Array.GetValue function is:

    val = Array.GetValue(ArrayName, index)

    where ArrayName is the name of the array to be searched, index is the location in the array to get the value from, and val is the value returned from the array at the given index.

    The syntax for Array.SetValue is

    Array.SetValue(ArrayName, val, index)

    where ArrayName is the name if the array, index is the location to set the value to, and val is the value to be inserted at the given index.

    The syntax for Array.RemoveValue is

    Array.RemoveValue(ArrayName, index)

    Where ArrayName is the name of the array you wish to remove the value from and index is the location of the value you wish to remove.

    It is key to note that Array.GetValue and Array.RemoveValue will only work with values that were set using the Array.SetValue function. 


    • Proposed as answer by WriterCoder Friday, May 31, 2013 1:02 PM
    • Marked as answer by Franganistan Sunday, June 2, 2013 12:47 AM
    Friday, May 31, 2013 1:00 PM
  • These methods "must?" of been deemed superfluous to sb v1.0. Below is a copy of a post by gungan37 

    http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/b499f6d0-e3a5-4717-911f-c390ecaf508e

    Quote: "According to an ILSpy search of SmallBasicLibrary.dll, these are the methods adorned with the [HideFromIntellisenseAtrribute] attribute: 

    Array.GetValue(arrayName, index)
    Array.SetValue(arrayName, index, value)
    Array.RemoveValue(arrayName, index)
    TextWindow.ReadKey()

    I believe these only exist for backwards compatibility (that is, they were from older SB version and were later replaced but still exist so old programs will run.) " Unquote.

    You have to have a dream so you can get up in the morning. - Billy Wilder


    Friday, May 31, 2013 9:38 PM
    Moderator
  • TextWindow.ReadKey() deprecated & superfluous?

    There's no other way to read a key pressed within TextWindow!

    And besides, SB should offer a way to read current held-down keys w/o halting the program. Something like:

    TextWindow.InKey() returning an Array of current pressed keys!  :P


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Friday, May 31, 2013 10:49 PM
    Answerer
  • I reckon goto. I wonder if someone could write an ext for that, if possible. Should be native but. V1.1


    You have to have a dream so you can get up in the morning. - Billy Wilder



    Saturday, June 1, 2013 10:33 AM
    Moderator
  • you can remove only those values from array which are assigned using set value. Though you removed the value it's index remain there. Whether due to such problems these methods are removed from intilisense? Once you try to use = sign for assigning values all values assigned by set value function becomes un-accessable. Here are my two sample code for checking out this fact.

    'An array contains number 1 to 20 sequentialy
    'Remove numbers from it randomly
    'NOTE Only numbers added by SetValue(...) method can be removed
    'Though value removed index remains
    '=========================================
    Seq = "Empty"
    For i = 1 To 20
      Array.SetValue(Seq,i,i)
    EndFor
    Array.RemoveValue(Seq,7)
    For i = 1 To 20
      TextWindow.WriteLine(i + ") " + Array.GetValue(Seq,i) )
    EndFor

    Problem of mixing = and set value is shown in following code

    'An array contains number 1 to 20 sequentialy
    'Remove numbers from it randomly
    'NOTE Only numbers added by SetValue(...) method can be removed
    'Though value removed index remains
    'We will check what happens with value set by using = notation
    'Checked all value vanishing. 
    'hence Array.SetValue and Array.RemoveValue not available in intelisense
    '=========================================
    Seq = "Empty"
    For i = 1 To 20
      Array.SetValue(Seq,i,i)
    EndFor
    Array.RemoveValue(Seq,7)
    Seq[21] = 21
    Seq[22] = 22
    Seq[23] = 23
    Seq[24] = 24
    Seq[25] = 25
    Array.RemoveValue(Seq,23)
    For i = 1 To 25
      TextWindow.WriteLine(i + ") " + Array.GetValue(Seq,i) )
    EndFor

    Saturday, June 8, 2013 1:45 PM