[Deleted]

Just starting out? Need help? Post your questions and find answers here.
BarryG
Addict
Addict
Posts: 4221
Joined: Thu Apr 18, 2019 8:17 am

[Deleted]

Post by BarryG »

Don't worry about it.
Last edited by BarryG on Sun Dec 24, 2023 1:08 pm, edited 13 times in total.
pjay
Enthusiast
Enthusiast
Posts: 277
Joined: Thu Mar 30, 2006 11:14 am

Re: Convert $23 to literal string value?

Post by pjay »

This?

Code: Select all

Macro hexLit(hx) : Str(2000+Val(Hex(hx))) : EndMacro
  
Debug hexLit($0) ; Want "2000"
Debug hexLit($23) ; Want "2023"
Debug hexLit($99) ; Want "2099"
BarryG
Addict
Addict
Posts: 4221
Joined: Thu Apr 18, 2019 8:17 am

Re: Convert $23 to literal string value?

Post by BarryG »

Don't worry about it.
Last edited by BarryG on Sun Dec 24, 2023 1:10 pm, edited 2 times in total.
User avatar
blueb
Addict
Addict
Posts: 1118
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: [Solved] Convert $23 to literal string value?

Post by blueb »

Does this help?

Code: Select all

Debug "20"+ LTrim("$23","$") ; Want "2023"
Edit... drat! to slow. haha
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
BarryG
Addict
Addict
Posts: 4221
Joined: Thu Apr 18, 2019 8:17 am

Re: [Solved] Convert $23 to literal string value?

Post by BarryG »

Don't worry about it.
Last edited by BarryG on Sun Dec 24, 2023 1:10 pm, edited 1 time in total.
User avatar
mk-soft
Always Here
Always Here
Posts: 6324
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: [Solved] Convert $23 to literal string value?

Post by mk-soft »

@BarryG

Do hey mean BCD (binary-coded decimal)
Then your for next loop ist wrong
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
BarryG
Addict
Addict
Posts: 4221
Joined: Thu Apr 18, 2019 8:17 am

Re: Convert $23 to literal string value?

Post by BarryG »

Don't worry about it.
Last edited by BarryG on Sun Dec 24, 2023 1:10 pm, edited 1 time in total.
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Convert hex of $23 to literal string of "23"

Post by NicTheQuick »

If you want your for loop to show you the decimal numbers from 0 to 99, why do you iterate from 0 to 153?
Here's your solution:

Code: Select all

For h = 0 To 99
  Debug Str(h)
Next
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Convert hex of $23 to literal string of "23"

Post by NicTheQuick »

And if you want it to show the hexa decimal numbers from $0 to $99, do it like this:

Code: Select all

For h = $0 To $99
  Debug Hex(h)
Next
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
BarryG
Addict
Addict
Posts: 4221
Joined: Thu Apr 18, 2019 8:17 am

Re: Convert hex of $23 to literal string of "23"

Post by BarryG »

Don't worry about it.
Last edited by BarryG on Sun Dec 24, 2023 1:09 pm, edited 3 times in total.
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Convert hex of $23 to literal string of "23"

Post by NicTheQuick »

A hex value and a base-16 number are the same thing.

Just use `Hex()` as I did in my second example:

Code: Select all

Debug Hex($23)
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Convert hex of $23 to literal string of "23"

Post by NicTheQuick »

And if you want to convert it literally to a decimal number, do this:

Code: Select all

For h = $0 To $99
  Debug Val(Hex(h))
Next
But remember that there are hexadecimal values with letters in it. In this case it will fail of course.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
BarryG
Addict
Addict
Posts: 4221
Joined: Thu Apr 18, 2019 8:17 am

Re: Convert hex of $23 to literal string of "23"

Post by BarryG »

Don't worry about it.
Last edited by BarryG on Sun Dec 24, 2023 1:09 pm, edited 1 time in total.
BarryG
Addict
Addict
Posts: 4221
Joined: Thu Apr 18, 2019 8:17 am

Re: Convert hex of $23 to literal string of "23"

Post by BarryG »

Don't worry about it.
Last edited by BarryG on Sun Dec 24, 2023 1:09 pm, edited 1 time in total.
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Convert hex of $23 to literal string of "23"

Post by NicTheQuick »

That's what I just told you. What are you expecting?

Your request is very silly. What do you want to achieve here?

You can not literally convert the hexa-decimal number 1C to decimal. `Val()` will just convert it to 1.

If you iterate from $0 to $99, you basically iterate from 0 to 153. That means that there are 153-99=54 values that can not be converted to decimal. Just think about it. At this point I get the feeling you just wanna troll me.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Locked