Kamis, 02 April 2020

SMALL BASIC: Adding or appending elements to array

Hello, SMALL BASIC programmer, welcome.

In this tutorial we will learn how to adding or appending elements to an array. These are few tips or few methods:

1. Adding or appending elements one by one
2. Adding or appending elements one array by one array whole

So, lets discuss this one by one:

1. Adding or appending elements one by one

object_1[0] = "A"
object_1[1] = "B"
object_2[0] = 1
object_2[1] = 2

'Appending one element after one element to an array
'1st. Find the length adder and the length of addee, but
'except the object_1 don't substract it with 1
object_2_l = Array.GetItemCount(object_2) - 1
object_1_l = Array.GetItemCount(object_1)

For i = 0 To object_2_l
  object_1[object_1_l+i] = object_2[i]
EndFor


'2. Get the length of the new object
object_1_l = Array.GetItemCount(object_1)
For i = 0 To object_1_l - 1
  TextWindow.WriteLine(object_1[i])
EndFor
  



Tidak ada komentar:

Posting Komentar