Hello
use a function in a For next loop, the loop does not wait until the function returns the value. I don’t understand. I mainly program with vb.net in Visual Studio, where the loop is interrupted when the function is called. What should I take into account? the loop breaks at:
Uncaught TypeError: Cannot read properties of undefined (reading ‘coinpair’)
→ without the function the error does not occur.
Here is my Code:
For lintLoop = 0 To UBound(lDynCoinList)
If Not IsNull(CStr(lDynCoinList[lintLoop].coinpair)) Then
'console.log(CStr(lDynCoinList[lintLoop].coinpair))
If CStr(lDynCoinList[lintLoop].coinplatform) = "MexC" Then
lintArrayIndex = Get_Array_Index(lDynCoinMexC, CStr(lDynCoinList[lintLoop].coinpair))
If lintArrayIndex <> -1 Then
console.log(CStr(lintArrayIndex))
lstrAktuellerKurs = CStr(lDynCoinMexC[lintArrayIndex].price)
End If
End If
CoinList.addItem(CStr(lDynCoinList[lintLoop].coinpair) & " / " & lstrAktuellerKurs)
End If
Next
Function Get_Array_Index(lDynCoin, lstrCoinName)
For lintLoop = 0 To UBound(lDynCoin)
'console.log(lDynCoin[lintLoop]["symbol"])
If UCase(CStr(lDynCoin[lintLoop].symbol)) = UCase(lstrCoinName) Then
Get_Array_Index = lintLoop
Exit Function
End If
Next
Get_Array_Index = -1
End Function
kind regards
ramon