[Implemented] Command system getting 'messy'?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Kris_a
User
User
Posts: 92
Joined: Sun Feb 15, 2004 8:04 pm
Location: Manchester, UK

[Implemented] Command system getting 'messy'?

Post by Kris_a »

Hi,

Before you go mad at me, please hear me out :D

Since #PB_ANY came out, I think that a lot of commands have become obselete, yet they get used anyway. In particular, Use<something>().

For example:

Code: Select all

x = OpenFile(#PB_ANY,"c:\boot.ini")
y = OpenFile(#PB_ANY,"c:\pbidetest2.rtf")

While Eof(x) = 0 And Eof(y) = 0
   Debug ReadString()
Wend
In this code it's obvious to see that readstring() will read from stream Y, but how on Earth do I get it to read data from Stream X without opening it again?
Usefile(x) and UseFile(y) don't work for this, and they sound like the only way to do it.

I think it would be a lot easier and logical to refer to everything by a returned handle, possibly removing the whole 'ID table' system:

Code: Select all

x = OpenFile("c:\boot.ini")
y = OpenFile("c:\pbidetest2.rtf")

While Eof(x) = 0 And Eof(y) = 0
   Debug ReadString(x)
   Debug ReadString(y)
Wend
I know this brings backward-compatibility issues, but it wouldn't exactly be hard to sift through an old program and convert it to this sort of system. Backward-compatibility seems to be what makes Microsoft's programs so big, bloated and buggy.

The same general rule applies to things like directories. The other day I tried to make a recursive directory browser in PB. I ended up with a bunch of "UseDirectory()" calls in completely illogical (at first glance) places, just to get it to work, whereas in Blitz (sorry to bring this up, but it's true) I could just refer to each directory with a handle that expired once it dropped out of scope, so I didn't have to worry about it again.

Don't get me wrong, I love the PB language, it just seems that there's a lot of power being left out because of this system, and although the system has changed, the artifacts of the old one are still there.

-Kris
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

UseFile() doesn't work with a #PB_Any file?
That sure is a bug then.

btw, i vote for both ways..

The UseXXX() way is pretty good when you have to work with the same
object with several commands, then you won't have to specify the 'object'
on each function you call for it.. just one UseXXX() before and you're done.

The direct access way is good when you mix them a lot. For example read
a line from one file and write it to another.

So the ReadString( [File] ) would just be a optional parameter. No backward
compatibility issue then.


Some commands allready support that (like WindowID), and afaik, this
is planned to be added for every command.

Timo
quidquid Latine dictum sit altum videtur
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hi Kris_a,

Fred has made a fix for useFile(returnedID), a download from the update folder is available.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

i vote for both options to make the use of the language more flexible
( 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... )
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Both, if nothing else for backwards compatibility.
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Both, and apply across all PB

Post by USCode »

I agree, both would be nice for backwards compatibility but at a higher level, Kris_a is asking that this apply throughout PB.

I've never liked any of the Use...() functions and would much prefer the clarity of specifying exactly which object I'm calling a function for as a parameter to that function, rather than setting a "current" reference using the Use...() functions. Not to mention it makes it easier to avoid some tough bugs.

This would apply to any functions that are dependant on any of the Use...() functions, such as:
UseDatabase
UseFont
UseWindow
etc. etc.
Post Reply