[Implemented] new constant : #String = 4

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

[Implemented] new constant : #String = 4

Post by Froggerprogger »

Just a simple one:

constant #String

I often need this and define it as 4, because :

Code: Select all

#String = 4
Debug #Byte
Debug #Word
Debug #Long
Debug #Float
Debug #String
%1>>1+1*1/1-1!1|1&1<<$1=1
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Strings doesn't have any fixed length.

But i think you mean the "length" in a structure (for example), but a better name would be:

#Pointer=4

(Strings are special kind of pointers)
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

...the variables #Byte, #Word, etc. are not giving the length, but an Type-Identifier:

Atm they are defined as:
#Byte = 0
#Word = 1
#Long = 2
#Float = 3

#String = 4 would make it complete.

I use it often, because for some kind of SortAlgorithms/Queues/Stacks/Trees, etc. I use the following 'Objects' as elements:

Code: Select all

Structure Object
  StructureUnion
    b.b
    w.w
    l.l
    f.f
    s.s
  EndStructureUnion
  type.l
EndStructure
where type.l holds the identifier and may be #Byte, ... , #Float, #String (and #Structure - of course i would love a further identifier #Structure as well, but I think not many people would need this)
%1>>1+1*1/1-1!1|1&1<<$1=1
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

..

Post by NoahPhense »

Froggerprogger wrote:...the variables #Byte, #Word, etc. are not giving the length, but an Type-Identifier:

Atm they are defined as:
#Byte = 0
#Word = 1
#Long = 2
#Float = 3

#String = 4 would make it complete.

I use it often, because for some kind of SortAlgorithms/Queues/Stacks/Trees, etc. I use the following 'Objects' as elements:

Code: Select all

Structure Object
  StructureUnion
    b.b
    w.w
    l.l
    f.f
    s.s
  EndStructureUnion
  type.l
EndStructure
where type.l holds the identifier and may be #Byte, ... , #Float, #String (and #Structure - of course i would love a further identifier #Structure as well, but I think not many people would need this)
Why don't you create a .res file with all your customizations in it?

Code: Select all

; my customizations

#String = 4
whatever.pb

Then drop it into the compiler directory, and type:
pbcompiler.exe whatever.pb /RESIDENT whatever.res

Then put that .res file in your /PureBasic/Residents/ folder..

Check out freaks post here:
viewtopic.php?t=7815

- np
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

@Noah
Of course I could, I'm just wondering if this could be implemented in PB.
Each of PB's build-in types has it's own identfier - all but string - so introducing #String would make it complete.
%1>>1+1*1/1-1!1|1&1<<$1=1
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

..

Post by NoahPhense »

Froggerprogger wrote:@Noah
Of course I could, I'm just wondering if this could be implemented in PB.
Each of PB's build-in types has it's own identfier - all but string - so introducing #String would make it complete.
*edit*
I just meant that until (or if) it gets added, you can always use the
resident file way until then.

- np
Last edited by NoahPhense on Wed Jul 07, 2004 11:12 pm, edited 2 times in total.
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

10-4.. that'll keep you going though
Sorry, my English isn't good enough to understand what you wanted to say with this 8O :)
%1>>1+1*1/1-1!1|1&1<<$1=1
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

wouldn't this only make real sense with a typeof() instruction?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

OK, now I see :)
I just meant that until (or if) it gets added, you can always use the
resident file way until then.
Yes, I'll do so. But it's not so comfortable for sharing with other's. They would have to 'install' this resident, too, or to define this constant by hand with the same value, which could make complications with so easy names like #String (perhaps they already use it with another value).

This whole theme is no big problem, of course, but I cannot see any reason that is against introducing #String.
wouldn't this only make real sense with a typeof() instruction?
At the moment #String would make 'the same sense' as #Byte, etc. already are doing. But of course a typeof() instruction would be cool in addition, if it would work e.g. on structureparameters, so we could copy a structure.
%1>>1+1*1/1-1!1|1&1<<$1=1
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

added the #String=4 constant.

Timo
quidquid Latine dictum sit altum videtur
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

TypeOf()? pretty pretty please?

:-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

This is a compiler thing.. you'll have to ask Fred for that one :)

Timo
quidquid Latine dictum sit altum videtur
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

well, if fred feels bored, i happen to have a little wishlist somehwere around here... http://www.xs4all.nl/~bluez/datatalk/pu ... 2_wishlist

not totally sure it's up to date, but at least it's somewhat motivated :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Post by helpy »

blueznl wrote:TypeOf()? pretty pretty please?
I do not see any sense in this command!

This command makes only sense, if one variable can change its datatype. And this is not possible in PureBasic. It makes sense if there would be a data type "VARIANT" (like in VB, VBA, VBScript, ...), but there is no data type like this in PureBasic.

So, why would you need a comman like TypeOf()?

cu, helpy
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

typeOf would be useful, I think. I know I would use it.

Variants would also be nice.

Imagine if we could pass unknown (to the function) arithmetic types as arguments, have the function do a typeOf() and then take appropriate action.

Then we could have doSomething(v) instead of multiple functions like doSomethingLong(v.l), doSomethingFloat(v.f), etc.

Esp. useful for for dlls, libs, etc.

Overhead would be relatively small.
@}--`--,-- A rose by any other name ..
Post Reply