assign values to an array

V+ discussions, tips and tricks, sample code, Q & A

assign values to an array

Postby Joerg.Vogel » Mon Sep 26, 2016 7:48 am

I'd like to fill an array with several numerical values. How can I pass list of values into a one dimensional array? If that is possible, how is the structure built to fill a more dimensional array in V+.
Many Thanks!
Regards,
Jörg Vogel
Joerg.Vogel
 
Posts: 10
Joined: Tue Dec 06, 2011 5:13 am

Re: assign values to an array

Postby Guenter Grass » Tue Sep 27, 2016 5:19 am

Hello Mr. Vogel,

to create a 1-dimensional array you can use a command like this
val[1] = 10
2-dimensional
val[2,1] = 10
3-dimensional
val [1,3,0] = 10

There is no command to add a list of values directly into an array.
But... if the values originate from a string you could do something like this
(Assuming the numbers are always 5 characters in the string)
pos.string = 1
FOR i = 1 to LEN($input)/5
val[i] = VAL($MID($input, pos.string, pos.string+4))
pos.string = pos.string + 5
END

Best Regards
Günter
Guenter Grass
 
Posts: 189
Joined: Thu Oct 16, 2008 4:34 am


Return to V+

Who is online

Users browsing this forum: No registered users and 1 guest