Microsoft Small Basic

Program Listing: SPT104
' SmallBasic Version 1.2
' Program: ArrayGetIndex
' Changelog:
' Author: Pappa Lapub
' Website: https://social.msdn.microsoft.com/Forums/en-US/3c63ce4f-e5a3-4a4d-b8e3-b8f9c4e662c7/challenges
' ImportURL: http://smallbasic.com/program/?
' SBOnline: http://smallbasic-publicwebsite-dev.azurewebsites.net/Program/view.aspx?
' Extension: (LitDev)
' Comment:
'
' Variables:
' ToDo:
' ==============================================================================
'idx = LDArray.GetIndex(arr, val) ' FIRST idx found

arr = "-2=A;0=20;3=5;b=2.4;xy=abc;-de=-100.5;6z=a;7.5=ABC;z=abc;" ' test array
val = "abc" ' search for value

allIdcs = "True" ' search through ALL Indices (True) or only 1st matching index (False) ?
valCaseInsens = "" ' should searched Value be case-INsensitive (True) or not (False) ?
'bTrim = "" ' you could also search for values (which are L/R space-trimmed) OR..
'bIsInVale = "" ' ... does array value CONTAIN the searched val (resp.)

nArr = Array.GetItemCount(arr)
idcs= Array.GetAllIndices(arr)

If valCaseInsens Then
arr = Text.ConvertToLowerCase(arr)
val = Text.ConvertToLowerCase(val)
EndIf

For n = 1 To nArr
If arr[idcs[n]] = val Then
If allIdcs Then
len = len + 1
res[len] = idcs[n]
Else
res = idcs[n]
n = nArr ' ExitFor
EndIf
EndIf
EndFor

TextWindow.WriteLine(arr)
TextWindow.WriteLine("")
TextWindow.WriteLine("Value '"+ val +"' found in index(indices):")
TextWindow.WriteLine(res)
TextWindow.WriteLine("")