Hello SMALL BASIC Programmer, Welcome.
In this tutorial we will learn about how to search for occurances of a character through out the string, i.e. search for index of occurance of a character through all the string.
string_to_search_in = "192.168.1.1"
character_to_search_for = "."
x = Text.GetSubTextToEnd(string_to_search_in,1)
y = Text.GetIndexOf(x,character_to_search_for)
While y <> 0
x = Text.GetSubTextToEnd(x,y+1)
TextWindow.WriteLine(x)
y = Text.GetIndexOf(x,".")
TextWindow.WriteLine(y)
Program.Delay(1000)
EndWhile
TextWindow.WriteLine(y)
So, if you want to save it into an array, it also can be done below:
host_ip_address = "192.168.1.1"
i=0
found = 0
x = Text.GetSubTextToEnd(host_ip_address,1)
y[i] = Text.GetIndexOf(x,".")
found = y[i]
z[i] = found
While y[i] <> 0
x = Text.GetSubTextToEnd(x,y[i]+1)
'TextWindow.WriteLine(x)
i = i + 1
y[i] = Text.GetIndexOf(x,".")
If y[i] <> 0 Then
TextWindow.WriteLine(i)
found = found + y[i]
z[i] = found
EndIf
'TextWindow.WriteLine(y)
'Program.Delay(1000)
EndWhile
For i = 0 To Array.GetItemCount(z) - 1
TextWindow.Write(i + ": ")
TextWindow.WriteLine(z[i])
EndFor
In this tutorial we will learn about how to search for occurances of a character through out the string, i.e. search for index of occurance of a character through all the string.
string_to_search_in = "192.168.1.1"
character_to_search_for = "."
x = Text.GetSubTextToEnd(string_to_search_in,1)
y = Text.GetIndexOf(x,character_to_search_for)
While y <> 0
x = Text.GetSubTextToEnd(x,y+1)
TextWindow.WriteLine(x)
y = Text.GetIndexOf(x,".")
TextWindow.WriteLine(y)
Program.Delay(1000)
EndWhile
TextWindow.WriteLine(y)
So, if you want to save it into an array, it also can be done below:
host_ip_address = "192.168.1.1"
i=0
found = 0
x = Text.GetSubTextToEnd(host_ip_address,1)
y[i] = Text.GetIndexOf(x,".")
found = y[i]
z[i] = found
While y[i] <> 0
x = Text.GetSubTextToEnd(x,y[i]+1)
'TextWindow.WriteLine(x)
i = i + 1
y[i] = Text.GetIndexOf(x,".")
If y[i] <> 0 Then
TextWindow.WriteLine(i)
found = found + y[i]
z[i] = found
EndIf
'TextWindow.WriteLine(y)
'Program.Delay(1000)
EndWhile
For i = 0 To Array.GetItemCount(z) - 1
TextWindow.Write(i + ": ")
TextWindow.WriteLine(z[i])
EndFor
Tidak ada komentar:
Posting Komentar