Hi, SMALL BASIC programmer, welcome.
In this tutorial, we will learned about removing unwanted element from an array, in this case from a single line multi colomn (SLMC) array not multi line multi colomn (MLMC). So, watch it.
For example, we want to remove element that have value FAILED from an SLMC array.
There are couples method that you can do to this, but I prefer this. If you do this differently, you will get different experience.
x[0] = "SUCCESS"
x[1] = "FAILED"
x[2] = "SUCCESS"
x[3] = "SUCCESS"
k = 0
m = 0
For i = 0 To 3
If x[i] = "FAILED" Then
x_l = Array.GetItemCount(x) - 1
'Move the front and the back
For j = i + 1 to x_l
y[k] = x[j]
k = k + 1
EndFor
For l = i - 1 To 0
z[m] = x[l]
m = m + 1
EndFor
'Merge y and z, merge y to the back of z
'1st. Search the length of z
z_l = Array.GetItemCount(z) - 1
'2nd. And then transfer one by one
For transfer_index = 0 To z_l
y[Array.GetItemCount(y)] = z[transfer_index]
EndFor
EndIf
EndFor
TextWindow.WriteLine(y)
In this tutorial, we will learned about removing unwanted element from an array, in this case from a single line multi colomn (SLMC) array not multi line multi colomn (MLMC). So, watch it.
For example, we want to remove element that have value FAILED from an SLMC array.
There are couples method that you can do to this, but I prefer this. If you do this differently, you will get different experience.
x[0] = "SUCCESS"
x[1] = "FAILED"
x[2] = "SUCCESS"
x[3] = "SUCCESS"
k = 0
m = 0
For i = 0 To 3
If x[i] = "FAILED" Then
x_l = Array.GetItemCount(x) - 1
'Move the front and the back
For j = i + 1 to x_l
y[k] = x[j]
k = k + 1
EndFor
For l = i - 1 To 0
z[m] = x[l]
m = m + 1
EndFor
'Merge y and z, merge y to the back of z
'1st. Search the length of z
z_l = Array.GetItemCount(z) - 1
'2nd. And then transfer one by one
For transfer_index = 0 To z_l
y[Array.GetItemCount(y)] = z[transfer_index]
EndFor
EndIf
EndFor
TextWindow.WriteLine(y)
Tidak ada komentar:
Posting Komentar