n/m

Just starting out? Need help? Post your questions and find answers here.
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

n/m

Post by jassing »

[withdrawn]
Last edited by jassing on Sat Jun 03, 2023 9:01 pm, edited 1 time in total.
User avatar
idle
Always Here
Always Here
Posts: 5042
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: constant when used by reference.

Post by idle »

I would expect that, it works as a string so why not by address, the string is constant and so is it's address
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

Re: constant when used by reference.

Post by jassing »

idle wrote: Sat Jun 03, 2023 5:51 am I would expect that, it works as a string so why not by address, the string is constant and so is it's address
Thanks. I found the error a little odd too.
Mesa
Enthusiast
Enthusiast
Posts: 345
Joined: Fri Feb 24, 2012 10:19 am

Re: constant when used by reference.

Post by Mesa »

The explanation is in the help here
https://www.purebasic.com/documentation ... rules.html
Constants

All constants are preceded by the hash # character. They can only be declared once in the source and always keep their predefined values. (The compiler replaces all constant names with their corresponding values when compiling the executable.)
In addition, help does not clearly indicate that the operator '@' only works with variables and procedures.

But indeed, everyone was mistaken one day or another with the use of @. :?

M.
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

Re: constant when used by reference.

Post by jassing »

[withdrawn]
Last edited by jassing on Sat Jun 03, 2023 9:02 pm, edited 1 time in total.
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: constant when used by reference.

Post by jacdelad »

jassing wrote: Sat Jun 03, 2023 3:16 pm
Mesa wrote: Sat Jun 03, 2023 10:26 am The explanation is in the help here
https://www.purebasic.com/documentation ... rules.html
how does that explain it?
As Mesa wrote:
The compiler replaces all constant names with their corresponding values when compiling the executable.

It may work for a string, because a string has an address, but what about

Code: Select all

#MyConst = 123
Debug @#MyConst
which is basically, when following the explanation:

Code: Select all

Debug @123
...won't work.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: n/m

Post by Olli »

@jassing

What happened to you to delete your messages? It is normal to ask this question.

And the direct string address (which seems to be confusing) is a feature that was requested and added quite late for convenience.
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

Re: n/m

Post by jassing »

Olli wrote: Sun Jun 04, 2023 8:22 am What happened to you to delete your messages? It is normal to ask this question.
issue has "already been discussed" and is expected behaviour - so there's no point in continuing ... I wasted people's time & forum space. I assumed constant replacement was similar to macro expansion - the token is replaced by the value. but I made an ass out of myself by assuming incorrectly.
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: n/m

Post by NicTheQuick »

jassing wrote: Sun Jun 04, 2023 4:01 pm
Olli wrote: Sun Jun 04, 2023 8:22 am What happened to you to delete your messages? It is normal to ask this question.
issue has "already been discussed" and is expected behaviour - so there's no point in continuing ... I wasted people's time & forum space. I assumed constant replacement was similar to macro expansion - the token is replaced by the value. but I made an ass out of myself by assuming incorrectly.
If anybody would do this this forum would be just unnecessary. Please don't do that.

Seemingly dumb questions are important questions too.

Now this thread has lost its sense and it can safely deleted.
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.
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: n/m

Post by Olli »

jassing wrote:but I made an ass out of myself by assuming incorrectly.
:lol:

It's not necessary to make this work. If I had to change all my nonsense, I wouldn't have time!
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: n/m

Post by mk-soft »

Would also be something for a features request to get the addresses on string constants.

As already written, this has been mentioned before.
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
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: n/m

Post by Fred »

@jassing, it's not good behavior to delete your post contents, it leaves unusable topics. It's not an issue if you asked something wrong, nobody will come at you :D
Axolotl
Enthusiast
Enthusiast
Posts: 435
Joined: Wed Dec 31, 2008 3:36 pm

Re: n/m

Post by Axolotl »

@jassing,
maybe you should add the appropriate title in the first post.
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 11 Home
Post Reply