[Implemented] I miss these features

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
akee
Enthusiast
Enthusiast
Posts: 496
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

[Implemented] I miss these features

Post by akee »

Fred,

Please give us a NOT operator... I miss doing...

Code: Select all

while not eof(1)
  ...
wend

Is there a spring feature for the StatusBar? Example...

Code: Select all

AddStatusBarField(-1)
would maximize the field according to the remainder window width


Any chance to have C like math syntax?

Code: Select all

a += 10
b++
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Hello,
First and 3rd requests are only syntax matter.
You can do:

Code: Select all

While Eof(1)=0
...
Wend
And i've tested that the 0 comparing is as fast as ASM :wink:

And for the 3rd req, you can do a+10 instead a+=10, and b+1 instead b++

I'd prefer the syntax, power and flexibility of the C "for" loops as an alternative "for-next" loops syntax in PB, don't you? :)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Re: I miss these features

Post by Num3 »

akee wrote:Fred,

Please give us a NOT operator... I miss doing...

Code: Select all

while not eof(1)
  ...
wend

Code: Select all

Repeat
...
Until EOF(1)
akee
Enthusiast
Enthusiast
Posts: 496
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

Post by akee »

Psychophanta wrote:Hello,
First and 3rd requests are only syntax matter.
You can do:

Code: Select all

While Eof(1)=0
...
Wend
And i've tested that the 0 comparing is as fast as ASM :wink:

And for the 3rd req, you can do a+10 instead a+=10, and b+1 instead b++

I'd prefer the syntax, power and flexibility of the C "for" loops as an alternative "for-next" loops syntax in PB, don't you? :)

hey thanks for the 3rd req tip... :)

yes i agree with you... however this is basic and for(a=0;a<10;a++) might create a hybrid language... :wink:
akee
Enthusiast
Enthusiast
Posts: 496
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

Re: I miss these features

Post by akee »

Num3 wrote:
akee wrote:Fred,

Please give us a NOT operator... I miss doing...

Code: Select all

while not eof(1)
  ...
wend

Code: Select all

Repeat
...
Until EOF(1)


Well it seems that PB has smart reads... I remember if coding...

open some file handle = 0
repeat
a = readsomething(0) <- this will trigger run-time "input past end" error if the file is empty.
until eof(0)
close (0)


thanks for the tip
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

I use that snippet o code all the time when i need to read an entire file, never had a problem!
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

if the file is empty, then you might get a runtime error when using the Repeat loop... otherwise, it shouldn´t be a problem.. (as long as the file exists)

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Post by Justin »

I second the not operator, yes is only about syntax but it will be hard to find a language that does not have it.

but please use a single letter otherwise there won't be much difference in typing

while !EOF()

wend
User avatar
geoff
Enthusiast
Enthusiast
Posts: 128
Joined: Sun Apr 27, 2003 12:01 am
Location: Cornwall UK
Contact:

Post by geoff »

but please use a single letter otherwise there won't be much difference in typing
NOT is clearer when you are reading a listing.

While NOT Eof(1)

While ! Eof(1)

Sometimes I used to type | instead of ! in another language, then spend ages wondering why the code would not work. In some fonts the difference was only 1 pixel on the screen.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

readability is all, it's simply easier to read:

if not eof(...)
if eof(...)

than it is

if eof(...)=0
if eof(...)<>0
( 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... )
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> if the file is empty, then you might get a runtime error when using the Repeat loop

You don't. Like Num3 said, I also use it that way and never get a runtime
error, even with 0-byte files.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

And in good programming you should always check the file size, before opening it, no need to waste cpu when there's nothing to read:

Code: Select all

file.s="myfile.txt"
If FileSize(file)>0
  If ReadFile(0,file)
    Repeat
      Debug ReadString()
  Until Eof(0)
EndIf
EndIf
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

akee wrote: however this is basic and for(a=0;a<10;a++) might create a hybrid language... :wink:
However, the only thing basic about purebasic is the word "basic" in the title :) We already have a "hybrid" language, why not continue adding keywords? :)
akee
Enthusiast
Enthusiast
Posts: 496
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

Post by akee »

Hmmm... How about some pointers to the Status Bar spring feature that wouuld resize itself to the width of the window...?

Code: Select all

AddStatusBarField(-1)
akee
Enthusiast
Enthusiast
Posts: 496
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

sigh!

Post by akee »

Did some Pure Basic file coding these last few days... Still feels kinda naked without the NOT operator... :cry:
Post Reply