Page 1 of 2

[Implemented] new constant : #String = 4

Posted: Wed Jul 07, 2004 9:07 pm
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

Posted: Wed Jul 07, 2004 9:28 pm
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)

Posted: Wed Jul 07, 2004 10:14 pm
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)

..

Posted: Wed Jul 07, 2004 10:32 pm
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

Posted: Wed Jul 07, 2004 10:42 pm
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.

..

Posted: Wed Jul 07, 2004 10:48 pm
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

Posted: Wed Jul 07, 2004 11:07 pm
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 :)

Posted: Fri Jul 09, 2004 1:45 pm
by blueznl
wouldn't this only make real sense with a typeof() instruction?

Posted: Fri Jul 09, 2004 2:50 pm
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.

Posted: Sat Jul 24, 2004 2:08 am
by freak
added the #String=4 constant.

Timo

Posted: Sun Jul 25, 2004 7:21 am
by blueznl
TypeOf()? pretty pretty please?

:-)

Posted: Sun Jul 25, 2004 1:12 pm
by freak
This is a compiler thing.. you'll have to ask Fred for that one :)

Timo

Posted: Mon Jul 26, 2004 1:05 pm
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 :-)

Posted: Mon Jul 26, 2004 1:47 pm
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

Posted: Mon Jul 26, 2004 1:59 pm
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.