not

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

not

Post by blueznl »

#true = 1
#false = 0

a.l = true

if a
...
endif

if not a
...
endif

what more can i say? :P
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Post by LCD »

Good idea, it works fine in Sinclair BASIC, and this was written in 1982. Another good addition from Sinclair Basic would be the string handling
a$="Test"
res$=a$(2 TO 3)
gives "es" in res$.
There is also a bug in Text command. If I try to add a chr()<32 or >127, the added string has a length of 0.
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

a$(2 to 3) might confuse people with string arrays...

and there's mid(), isn't there
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

LCD wrote:Good idea, it works fine in Sinclair BASIC, and this was written in 1982. Another good addition from Sinclair Basic would be the string handling
a$="Test"
res$=a$(2 TO 3)
gives "es" in res$.
The Basic-Version of the Atari XL/XE do something simulat
Res$=a$(2,3)
This Basic-Variant has also no arrays for strings....

I don't think, that this solution is a good idea. You have mid().

GPI
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

xl... damn, that brings back memories, got 2 400's, one 800, one 600xl with 256kB laying around here somewhere...
( 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... )
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Post by LCD »

blueznl wrote:a$(2 to 3) might confuse people with string arrays...

and there's mid(), isn't there
Sure, there is MID(), but MID uses a length operator for string length, and a$(2 to 3) uses non-relative position pointers, so they can co-exist.
I don't think this will confuse people, as in arrays there is no TO.
I just got now a Atari 800 XL and check this...
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

mmmm true but it wouldn't be a big gain imho, but heh, it's fred's call...
( 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... )
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

;Sure, there is MID(), but MID uses a length operator for string length, and
;a$(2 to 3) uses non-relative position pointers, so they can co-exist.

I would prefer a new command:
MidPart(a$,start,end)

debug MidPart(a$,2,3)

is better then A$(2 to 3) because there is no confusion with dims. (also i think it is easier to add.)

GPI
Last edited by GPI on Tue Oct 07, 2003 11:23 pm, edited 1 time in total.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

yup
( 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
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

i've been thinking about wishes for commands that are easily to emulate in code... there's little need for them, unless they make life a lot easier, but unfortunately it can't be solved all the time

see the following code:

#false = 0
#true = 1

Procedure not(expression)
If expression = false
ProcedureReturn true
Else
ProcedureReturn false
EndIf
EndProcedure

OpenConsole()

a.s="a"
b.s="b"

If not(a.s=b.s)
PrintN("<>")
EndIf

If a.s=b.s
PrintN("=")
EndIf

Repeat
Until Inkey()>""
( 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... )
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

A NOT operator would be more than nice.
User avatar
geoff
Enthusiast
Enthusiast
Posts: 128
Joined: Sun Apr 27, 2003 12:01 am
Location: Cornwall UK
Contact:

Post by geoff »

A NOT operator would be more than nice.
I agree.
Kris_a
User
User
Posts: 92
Joined: Sun Feb 15, 2004 8:04 pm
Location: Manchester, UK

Post by Kris_a »

Can't you just use ~ to get the compliment of the expression? That sounds (and works) just like 'not', AFAIK.

Edit: ah i see :( nevermind
Last edited by Kris_a on Tue Feb 17, 2004 12:29 am, edited 1 time in total.
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

It's not the same, and don't work the same, the only time it works the same is when the expression you use it on is False -then it produces the right result..

Example:

Code: Select all

a = 2 ; This will be interpreted as TRUE in a logical statement
b = ~a ; so this should then be FALSE??

if a
  Debug "a: TRUE"
else
  debug "a: FALSE"
endif

if b
  Debug "b: TRUE"
else
  Debug "b: FALSE"
endif
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Using ~ and adding 1 seems to be the same as multiplying by -1, that is, it appears to negate a value. Using ~ is like (val * -1) - 1

Whereas my understanding of NOT is that it returns the opposite of true and false:

Code: Select all

If a=0   ;OR a=#false
  a=#true
else
  a=#false
endif
I think Psychophanta created an asm NOT routine for small fast NOTing.
Post Reply