Array.getvalue not working

simon_384 21 Reputation points
2021-02-20T23:39:22.487+00:00

Hi, I have a big problem with Arrays in Small Basic program

Cause when I have get value from the Array, action is return empty value. Below is the code (For the sake of the question, I simplified the code)

my_array = "1=firstvalue;2=secondvalue;"  
TextWindow.Write("1: ")  
TextWindow.WriteLine(Array.Getvalue(my_array, 1))  
TextWindow.Write("2: ")  
TextWindow.WriteLine(Array.Getvalue(my_array, 2))  

When I run the program, I get this result:
70294-screenshot-1.png

Any ideas why this program isn't working?

Small BASIC
Small BASIC
A programming language created by Microsoft that serves a stepping stone for beginners from block-based coding languages to more complex text-based languages.
277 questions
0 comments No comments
{count} votes

Accepted answer
  1. Scout 541 Reputation points
    2021-02-21T09:04:05.637+00:00

    Hi Simon,
    there is no array method "GetValue", but a similar one with "ContainsValue".
    The output and further processing takes place simply with the index 1 or [2] ... or depending on the definition.

    my_array = "1=firstvalue;2=secondvalue;"  
    TextWindow.WriteLine("1: " + my_array[1])  
    TextWindow.WriteLine("2: " + my_array[2])  
    TextWindow.WriteLine("ContainsValue 'secondvalue': " + Array.ContainsValue(my_array, "secondvalue"))  
    

    70356-unbenannt.png


0 additional answers

Sort by: Most helpful