PB constants for min-max limits according to variable type

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

PB constants for min-max limits according to variable type

Post by Denis »

For tests with Select it's not posible to write this for positive/negative value (or for another range)

Code: Select all

Select a.i 
case  >0 
case  < 0
case  >=0 
case  <= 0
like this it's Ok for x86, integer value

Code: Select all

Select a.i 
case   1  to  2147483647
case  -2147483648  to  -1
case  0  to  2147483647 
case  -2147483648  to  0
and for x64, integer value

Code: Select all

Select a.i 
case   1  to  9223372036854775807
case  -9223372036854775808  to  -1
case  0  to  9223372036854775807 
case  -9223372036854775808  to  0
1) will it be possible to have PB constants for min-max limits according to variable type?
By this way, it'll we done once for all (all plateforms, all coders).

2) it will be good to have case > etc. for Select test

since last of 2001 i use PB, it seems to me that i remember some of us already ask for that :mrgreen:
A+
Denis
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: PB constants for min-max limits according to variable ty

Post by STARGÅTE »

2) it will be good to have case > etc. for Select test
No, Select:Case is no If:ElseIf.

Code: Select all

If a > 0
ElseIf a < 0
EndIf
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: PB constants for min-max limits according to variable ty

Post by Denis »

STARGÅTE wrote:
No, Select:Case is no If:ElseIf.

Code: Select all

If a > 0
ElseIf a < 0
EndIf
Yes, but it's not because if then else do the trip that select case does not have to do it
A+
Denis
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: PB constants for min-max limits according to variable ty

Post by STARGÅTE »

Denis wrote:Yes, but it's not because if then else do the trip that select case does not have to do it
what?

btw:

Code: Select all

#PB_MinByte    = -$80
#PB_MaxByte    =  $7F
#PB_MinAscii   =  $00
#PB_MaxAscii   =  $FF

#PB_MinWord    = -$8000
#PB_MaxWord    =  $7FFF
#PB_MinUnicode =  $0000
#PB_MaxUnicode =  $FFFF

CompilerIf SizeOf(Character) = 1
  #PB_MinCharacter = #PB_MinAscii
  #PB_MaxCharacter = #PB_MaxAscii
CompilerElse
  #PB_MinCharacter = #PB_MinUnicode
  #PB_MaxCharacter = #PB_MaxUnicode 
CompilerEndIf

#PB_MinLong = -$80000000
#PB_MaxLong =  $7FFFFFFF
#PB_MinQuad = -$8000000000000000
#PB_MaxQuad =  $7FFFFFFFFFFFFFFF

CompilerIf SizeOf(Integer) = 4
  #PB_MinInteger = #PB_MinLong
  #PB_MaxInteger = #PB_MaxLong
CompilerElse
  #PB_MinInteger = #PB_MinQuad
  #PB_MaxInteger = #PB_MaxQuad 
CompilerEndIf
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: PB constants for min-max limits according to variable ty

Post by Denis »

I ask to have PB constant, not mine, no compiler bla bla to put :wink:
Compiler will do the job
A+
Denis
Post Reply