STR$ and hexadecimal format

Here we can discuss about the problem found
Post Reply
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

STR$ and hexadecimal format

Post by Fernando Perez »

It seems to me that there is an error in the help regarding str$ in hexadecimal format or perhaps in the function.
The help manual makes it clear that the [toint] parameter is optional, but if I don't use 1, the result is always zero.
Can you try?
wlog str$(255, "%02X") returns zero and wlog str$(255, "%02X", 1) returns the correct value, FF.
User avatar
cicciocb
Site Admin
Posts: 2061
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1360 times
Contact:

Re: STR$ and hexadecimal format

Post by cicciocb »

Hi Fernando,
there are no errors.
The documentation states that, for integers arguments, the "last optional" parameter must be 1
image.png
Probably the problem is the interpretation of the word 'optional' (in this case required if you want print integer numbers)
You do not have the required permissions to view the files attached to this post.
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: STR$ and hexadecimal format

Post by Fernando Perez »

I understand, Francesco.
The thing is that in my limited English I had interpreted that if the number to be formatted was already an integer, it was not necessary to use it.
But in the example it is clear.
Thank you.
User avatar
cicciocb
Site Admin
Posts: 2061
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1360 times
Contact:

Re: STR$ and hexadecimal format

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Tue Dec 05, 2023 10:10 am I understand, Francesco.
The thing is that in my limited English I had interpreted that if the number to be formatted was already an integer, it was not necessary to use it.
But in the example it is clear.
Thank you.
Maybe someone can propose a text without ambiguity that I can replace in the help.
Any proposal is welcomed
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: STR$ and hexadecimal format

Post by Fernando Perez »

For hexadecimal and octal formats, its use is mandatory.
User avatar
cicciocb
Site Admin
Posts: 2061
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1360 times
Contact:

Re: STR$ and hexadecimal format

Post by cicciocb »

In fact all is written in the help but probably is not clear
image.png
You do not have the required permissions to view the files attached to this post.
bugs
Posts: 143
Joined: Mon Feb 08, 2021 10:10 pm
Location: Scotland
Has thanked: 47 times
Been thanked: 51 times

Re: STR$ and hexadecimal format

Post by bugs »

Possibly something like:-
The additional ",1" is required for the number types marked integer in the table below.
:?:
User avatar
Electroguard
Posts: 861
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 276 times
Been thanked: 323 times

Re: STR$ and hexadecimal format

Post by Electroguard »

Or maybe instead of :
The last optional format ‘toint’, if =1, permits to convert the number in integer format.

Replace with:
when using the format$ option, an optional end ‘toint’ can be used to convert the number to integer format if toint=1.
Post Reply