Page 1 of 1

Error converting string to int

Posted: Mon Mar 13, 2023 3:17 pm
by Josemar
Hello.

When I try to convert a string that contains a date and time:

Code: Select all

Define txt$  = "20230313143030"
Define num.q = Val(txt$)
Debug num

I see that it runs fine in Windows 10 64 bits... and in Widows XP 32 bits, it runs too, I'm surprised :D
The problem is compiling in MacOS (chip intel, OS Monterrey, PB 6,01 LTS) , it prints 12663CA0EAF6

Is it a bug, or a limitation of Mac version of PureBasic?

// Moved from "Bugs - Mac OSX" to "OS Specific Mac OSX" (Kiffi)

Re: Error converting string to int

Posted: Mon Mar 13, 2023 3:51 pm
by deeproot
The value of num.q is correct - no bug I think. 12663CA0EAF6 is hex and = 20230313143030.

To ensure the output number format from Debug use either Str() or Hex().

Re: Error converting string to int

Posted: Mon Mar 13, 2023 4:45 pm
by mk-soft
You can set which format the debug output should have.
Certainly set in Preferences

Re: Error converting string to int

Posted: Mon Mar 13, 2023 5:51 pm
by Josemar
deeproot wrote: Mon Mar 13, 2023 3:51 pm The value of num.q is correct - no bug I think. 12663CA0EAF6 is hex and = 20230313143030.

To ensure the output number format from Debug use either Str() or Hex().

Thanks, but I have doubts... Is correct that Val() returns an hexadecimal instead a integer value?
Executing that in Windows, it returns an integer.

Re: Error converting string to int

Posted: Mon Mar 13, 2023 5:54 pm
by Josemar
mk-soft wrote: Mon Mar 13, 2023 4:45 pm You can set which format the debug output should have.
Certainly set in Preferences
Thanks mk-soft . Just this was my problem, I was set preferences for debugger in Hex (I didn't remember this)

Solve, thanks a lot and sorry for my mistake