Discuss Scratch

thugatwoary
Scratcher
100+ posts

Allow typing of x, A, B, C, D, F, in number inputs.

Scratch's math blocks support hexadecimal but you can't type hex numbers in number inputs. To fix this, x should be typable so people can put 0x to specify it's a hex number, and A, B, C, D, and F should be typable so people can put hexadecimal numbers.
yavuz61035
Scratcher
500+ posts

Allow typing of x, A, B, C, D, F, in number inputs.

maybe something like there would be 2 modes when writing a number input, base-10 (decimal) and base-16 (hexadecimal) and there would be 2 buttons to switch between them (deafult is base-10) and base-16 would probably have a scroll feature to fit the x and A-F characters or the number input frame
would be higher to fit in the other characters

anyways, support.
ScolderCreations
Scratcher
1000+ posts

Allow typing of x, A, B, C, D, F, in number inputs.

I don't think there should be some sort of option, or anything that makes it very obvious, because people who don't know what hexadecimal is won't understand what this means, and might even think this is talking about hex colors. However, I do think it should be possible to type in those letters with your keyboard, that is a good way to allow people to use this without making it too confusing.
ideapad-320
Scratcher
1000+ posts

Allow typing of x, A, B, C, D, F, in number inputs.

thugatwoary wrote:

Scratch's math blocks support hexadecimal but you can't type hex numbers in number inputs. To fix this, x should be typable so people can put 0x to specify it's a hex number, and A, B, C, D, and F should be typable so people can put hexadecimal numbers.
you forgot E.
mybearworld
Scratcher
1000+ posts

Allow typing of x, A, B, C, D, F, in number inputs.

ideapad-320 wrote:

you forgot E.
No they didn't - e is already allowed, try this:
(1e6) + ()
portalpower
Scratcher
1000+ posts

Allow typing of x, A, B, C, D, F, in number inputs.

workaround:
define decimal->hexadecimal (input)
//run without screen refresh
set [input v] to ([abs v] of (input::custom))
set [output v] to []
repeat until <(input::variables) = [0]>
set [output v] to (join (letter (((input::variables) mod (16)) + (1)) of [0123456789ABCDEF]) (output)
set [input v] to ([floor v] of ((input::variables) / (16)))
end
set [output v] to ((output) * ((input) / ([abs v] of (input))))
It doesn't work for decimals though
thugatwoary
Scratcher
100+ posts

Allow typing of x, A, B, C, D, F, in number inputs.

portalpower wrote:

workaround:
define decimal->hexadecimal (input)
...
It doesn't work for decimals though
This is not suggesting decimal->hexadecimal. Please read the title before posting on a topic.
portalpower
Scratcher
1000+ posts

Allow typing of x, A, B, C, D, F, in number inputs.

thugatwoary wrote:

(#7)

portalpower wrote:

workaround:
define decimal->hexadecimal (input)
...
It doesn't work for decimals though
This is not suggesting decimal->hexadecimal. Please read the title before posting on a topic.
Oops, I forgot to put the hexa->deci. Oh well.
If you use the encoders, then you don't really need to type the inputs in hexadecimal.
thugatwoary
Scratcher
100+ posts

Allow typing of x, A, B, C, D, F, in number inputs.

portalpower wrote:

thugatwoary wrote:

(#7)

portalpower wrote:

workaround:
define decimal->hexadecimal (input)
...
It doesn't work for decimals though
This is not suggesting decimal->hexadecimal. Please read the title before posting on a topic.
Oops, I forgot to put the hexa->deci. Oh well.
If you use the encoders, then you don't really need to type the inputs in hexadecimal.
That doesn't change the fact that this suggestion was about allowing the typing of hexadecimal in inputs that support them.
portalpower
Scratcher
1000+ posts

Allow typing of x, A, B, C, D, F, in number inputs.

Entire workaround:
define decimal->hexadecimal (input)
//run without screen refresh
set [i v] to (round ([abs v] of (input::custom)))//for this sprite only
set [output v] to []
repeat until <(i) = [0]>
set [output v] to (join (letter (((i) mod (16)) + (1)) of [0123456789ABCDEF]) (output)
set [i v] to ([floor v] of ((i) / (16)))
end
set [output v] to ((output) * ((i) / ([abs v] of (input))))

define hexadecimal->decimal (input)
//run without screen refresh
set [output v] to [0]
set [input v] to (round ([abs v] of (input)))//for this sprite only
set [i v] to [0]//for this sprite only
repeat (length of (input::variables))
change [output v] by ((round ([e^ v] of ((i) * ([ln v] of (16)))::operators)) * ((item # of (letter ((length of (inputs::variables)) - (i)) of (input::variables)) in [numbers v]::list) - (1)))//numbers list would be numbers 0-F
end

hexadecimal->decimal (...::grey)//how to use
set [var v] to (*operations*(output)::grey)
decimal->hexadecimal (var)
There.
thugatwoary
Scratcher
100+ posts

Allow typing of x, A, B, C, D, F, in number inputs.

Since someone is posting a workaround to something entirely different, I figured I'd post an actual workaround that's… actually kinda simple.
((join [0x] [...]) + (...))
Despite how simple this is, I still feel like it'd make sense to add support for these characters. Actually, how simple this is makes me feel like there's even less of a reason not to as it is already nearly entirely supported, and supporting these characters would make other users who might want to use hex numbers know that they are actually supported, since the workaround is still a somewhat hacky one that most users wouldn't think of.

Last edited by thugatwoary (June 24, 2022 23:13:53)

portalpower
Scratcher
1000+ posts

Allow typing of x, A, B, C, D, F, in number inputs.

thugatwoary wrote:

(#11)
Since someone is posting a workaround to something entirely different, I figured I'd post an actual workaround that's… actually kinda simple.
((join [0x] [...]) + (...))
Despite how simple this is, I still feel like it'd make sense to add support for these characters. Actually, how simple this is makes me feel like there's even less of a reason not to as it is already nearly entirely supported, and supporting these characters would make other users who might want to use hex numbers know that they are actually supported, since the workaround is still a somewhat hacky one that most users wouldn't think of.
It also doesn't stay in hexadecimal. You have to use a custom function to convert it back.
thugatwoary
Scratcher
100+ posts

Allow typing of x, A, B, C, D, F, in number inputs.

portalpower wrote:

thugatwoary wrote:

(#11)
Since someone is posting a workaround to something entirely different, I figured I'd post an actual workaround that's… actually kinda simple.
((join [0x] [...]) + (...))
Despite how simple this is, I still feel like it'd make sense to add support for these characters. Actually, how simple this is makes me feel like there's even less of a reason not to as it is already nearly entirely supported, and supporting these characters would make other users who might want to use hex numbers know that they are actually supported, since the workaround is still a somewhat hacky one that most users wouldn't think of.
It also doesn't stay in hexadecimal. You have to use a custom function to convert it back.
True, but having it stay hex was not what was suggested, as the title only says “Allow typing of x, A, B, C, D, F, in number inputs.”
TheReal_BestGamer
Scratcher
33 posts

Allow typing of x, A, B, C, D, F, in number inputs.

ScolderCreations wrote:

I don't think there should be some sort of option, or anything that makes it very obvious, because people who don't know what hexadecimal is won't understand what this means, and might even think this is talking about hex colors. However, I do think it should be possible to type in those letters with your keyboard, that is a good way to allow people to use this without making it too confusing.
Perhaps there could be an option in a more subtle way, such as making you only able to do Hex if they type ACBDEF first then the actual Hex number.
thugatwoary
Scratcher
100+ posts

Allow typing of x, A, B, C, D, F, in number inputs.

bump

Last edited by thugatwoary (June 27, 2022 13:27:32)

Powered by DjangoBB