Code: Select all
Option Explicit
Sub Main()
Dim S As String
Dim Sng As Single
Dim Success As Boolean
Dim I As Integer
'Enable Stack Checking
Call StackCheck(True)
'Say Hello
Console.Writeline ("Program Start: ")
'Reset Flags: 2=HW Reset, 4 Brown out, 5=Power, 8=Watchdog, 16 JTAG reset
Select Case Register.ResetFlags
Case 2
Console.Writeline (" [Reset Button]")
Case 5
Console.Writeline (" [Power]")
Case 8
Console.Writeline (" [Watchdog Timeout]")
Console.WriteLine ("Fault Type: " & CStr(Register.FaultType))
Console.WriteLine ("Task Control Block: " & CStr(Register.FaultData))
Console.WriteLine ("Instruction Address: " & CStr(Register.FaultData2))
Console.Writeline ("Reset cause MCUSR : &H" & cstrhex(Register.MCUCSR) )
End Select
Console.WriteLine ("Register.ResetFlags: &H" & CStrHex(Register.ResetFlags))
S = "0A1B2C3D4"
Sng = 0.0
Success = False
Do
For I = 1 To Len(S)
Call ValueS(Mid(S,I,1),Sng,Success) 'THE PROBLEM!
Next I
Loop
End Sub
ZX24a v2.6.2
Zbasic IDE v1.4.5
Compiler version: v2.6.4
I solved my problem by passing a string to the ValueS() function.
Code: Select all
Do
For I = 1 To Len(S)
NewStr = Mid(S,I,1)
Call ValueS(NewStr,Sng,Success)
Next I
Loop
I'm inexperienced with ZBasic and I'm not sure if i am using the ValueS() function incorrectly or if there is a problem in ZBasic.
Also, In my first example, if I comment out either the Do/Loop or the For/Next loop the problem disappears.
Don