Page 1 of 2

Posted: Mon Jan 06, 2003 5:54 am
by BackupUser
Restored from previous forum. Originally posted by MrVainSCL.

Hi @ all!
To create a program with PureBasic you need every time ObjectNumbers for Windows, Menus, Sprites, Screen, Gadgets and so on... I think it would be mutch better to use only Handles in future instead to give every object an own ObjectNumber... This would make coding more easy and flexible, due fact... PureBasic uses anyway internal only handles for every ObjectNumber! So i think we dont need to declare and Object giving a specific ObjectNumber...

Code: Select all

    WindowID = OpenWindow(#Window, x, y, w, h, Flags, Title$)

could be in future like:

    hWin_Main  = OpenWindow(x, y, w, h, Flags, Title$)
    hWin_Prefs = OpenWindow(x, y, w, h, Flags, Title$)
I know that PureBasic uses the same methode like Blitz, but just take a look to other languages for example... Please let us discuse about this topic and lets share your opinions... :wink:





PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...

greetz
MrVainSCL! aka Thorsten

Posted: Mon Jan 06, 2003 6:21 am
by BackupUser
Restored from previous forum. Originally posted by Paul.

Um...
First off, not everyone needs to use handles.
Secondly, if you need the handle to a window or gadget, that's what WindowID(), GadgetID(), etc are for. No need to assign another variable.

Example:
OpenWindow(#Window,x,y,w,h,Flags,Title$)

If you need the handle:
WindowID(#Window)

----------
Visit the PB Resources Site at http://www.reelmediaproductions.com/pb

Posted: Mon Jan 06, 2003 6:47 am
by BackupUser
Restored from previous forum. Originally posted by MrVainSCL.

Hi Paul,
i know the stuff with the WindowID() stuff, but in fact that PureBasic always handle the unser ObjectNumbers with handles, it would make coding more easy (in my eyes) if you only have to work with handles instead of hundets dfined ObjectNumbers... So the ObjectNumbers are no longer needed... Its useless when we can direct deal with handles... HWnd = instead WindowID() ...

Ok, now i have go to work.. bye



PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...

greetz
MrVainSCL! aka Thorsten

Posted: Mon Jan 06, 2003 6:53 am
by BackupUser
Restored from previous forum. Originally posted by Franco.

I second the reply of Paul and partially of Mr.Vain.

BTW:
Because of the lack of more functionality with the build-in Event Handler I use my own Event Handler .
My comand examples:

Code: Select all

Open_Window(200, 200, 360, 240, #PB_Window_SystemMenu, "Window", ?Window_RMB)

Button_Gadget(10, 10, 100, 25, "Button", 0, "ToolTip 1", ?Button1)

Run_Application("Question:","Do you want to close this application?",2) ;event handler

End 

Window_RMB:
  ;function for right mouse click on window
  MessageRequester("Title","Text",0)
Return

Button1:
  ;function for Button 1
  MessageRequester("Button 1","Function 1",0)
Return
All test like If OpenWindow(etc.) or If CreateGadgetList() or whatever is build in.
Also all special workarounds for ComboBox, StringGadget etc.
A nice side effect is no Gadget Numbers and no Gadget Handles needed.
And if you need the Handle use:

Code: Select all

Gadget=Button_Gadget(10, 10, 100, 25, "Button", 0, "ToolTip 1", ?Button1) 
GadgetID(Gadget)
So the main code stays clear and simple.

Well till PureBasic 3v4. With 3v5 it's not working anymore - look at the BUG SECTION in this Forum.


Have a nice day...

Franco

Posted: Mon Jan 06, 2003 2:24 pm
by BackupUser
Restored from previous forum. Originally posted by tranquil.

Would be nice to see some ObjectNumbers optional. In the case of 3d Objects there must be handles. Most ppl will code their own editors for their stuff and handling objectnumbers in tables is more work that must not be. (oh dear my bad english hehe)

Objectnumbers should be optional to these:

- Camera
- Mesh
- Texture
- Light
- Sprite
- File
- Memory
- Window

Happy new year to all!

Cheers
Mike

Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
System 2: Mobile Pentium 4 2.4GHz 512 MB DDR GeForce4 420-32, Windows XP Home

Posted: Mon Jan 06, 2003 3:27 pm
by BackupUser
Restored from previous forum. Originally posted by fred.

Yes, I plan to make the fixed number optional very soon for all libs.

Fred - AlphaSND

Posted: Mon Jan 06, 2003 4:16 pm
by BackupUser
Restored from previous forum. Originally posted by plouf.

Optional is a good choice since there are also some people
out there (me) you prefer number under some(most) cases
[;-)]

Christos

Posted: Mon Jan 06, 2003 6:46 pm
by BackupUser
Restored from previous forum. Originally posted by Danilo.

If you want to use handles only, you should
code plain WinAPI without PB-commands.
Its easy and the same like in C or ASM.

PureBasic uses numbers to make the language
and code portable for Windows, Linux and Amiga.
On Amiga and Linux (and future platforms) its
not the same handle like on Windows - keep that in mind.

cya,
...Danilo

(registered PureBasic user)

Posted: Tue Jan 07, 2003 11:08 am
by BackupUser
Restored from previous forum. Originally posted by geoff.

I don't believe it matters too much whether we use object
numbers or handles. More important is that we make a
decision and stick to it.

Fundamental changes like this would require users to recode
all of their existing applications. Imagine the response you
would get if you suggested making such changes to an established
language like C.

Better criteria for such choices are:

1) Can this syntax be used long term?
2) Can the same syntax be used on several OSes

ie Standardisation and Compatibility

Geoff

Posted: Tue Jan 07, 2003 6:08 pm
by BackupUser
Restored from previous forum. Originally posted by tranquil.

Fred said it would be optional. so there should be not problem. use this feature of object-free coding or use it not. Its then on you.

I think PureBasic is a Basic-Language dedicated to thouse who are experied coders. So I hope many ppl will be lucky not to have to use object numbers.

Mike

Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
System 2: Mobile Pentium 4 2.4GHz 512 MB DDR GeForce4 420-32, Windows XP Home

Posted: Tue Jan 07, 2003 8:43 pm
by BackupUser
Restored from previous forum. Originally posted by Froggerprogger.

Sometimes the IDs are very useful for running through a lot of items in a loop in the from the IDs specified way...
But sometimes it could nerve...
So: Optional would be veeery cool...


Purebasic - what a nice name for a girl-friend

Posted: Wed Jan 08, 2003 11:29 am
by BackupUser
Restored from previous forum. Originally posted by geoff.

Optional is OK but I'm not sure about cool.

When you can do the same thing several different ways it can be difficult
to read other people's code. A compiler that allows 3 options for
every command is likely to have 3 times as many bugs.

This is an old subject, do you prefer the "totalitarianism" of Pascal with
its strict rules or the "anarchy" of C with its options?

Should Purebasic use the syntax familiar in other Basics or should it
borrow syntax from a variety of languages?

Why do we use Pow(x,y) as in C instead of x^y as in most Basics?
In which case why not allow x++ and x+=1 and other C constructs?

This sort of thing is quite important when you want to convert code
between one language and another. If we had all the C constructs it
would be easier to make use of the huge amount of C code out there.
If we had all the Basic constructs it would be easier to convert code
to/from Vbasic for example.


Perhaps Fred would be interested in users views?

Posted: Wed Jan 08, 2003 4:12 pm
by BackupUser
Restored from previous forum. Originally posted by tinman.
Originally posted by geoff

Why do we use Pow(x,y) as in C instead of x^y as in most Basics?
In which case why not allow x++ and x+=1 and other C constructs?
Small details such as this I don't think matter. It is very easy (for a programmer who knows at least one high level language) to look up a reference manaul for both languages to find out what the ^ symbol means, or what a certain operator does.

More important is the concepts behind the language or library commands, which is where handles/pointers vs object numbers fits in. In this case you are trying to figure out the best system to be able to reference things you create (such as gadgets, menus etc).

Either way is fine for portability as long as you do not try to do anything fancy with the handles/pointers such as peeking into them or using API calls. The same goes for object numbers though, as there will usually be the option of getting the handle/pointer behind it if you really want to break portability.

The other issue is handling the references to the things. With handles and pointers you only need store a variable for each one if you want/need to. PureBasic would surely maintain an internal list of all handles. This is also true for object numbers - PureBasic would need to maintain an internal list. You get the advantage of being able to use variables or constants for the object numbers although you would need to do this for all things. Making object numbers optional would cure that.

In short, there is very little real difference between handles and pointers and object numbers for this stuff. The only real difference is in how quickly a reference to a thing can be changed to access it directly. With object numbers you need an extra step.

I agree with the points about too many optional methods can be a hassle (not much if it is only 2 though - handles or numbers) and that ideally the chosen should be kept to and not changed (e.g. between major version of PB).



--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)

Posted: Wed Jan 08, 2003 5:13 pm
by BackupUser
Restored from previous forum. Originally posted by fred.

What I plan to do is the following, any comment is of course appreciated:

Static (current) way: OpenWindow(#MyNumber, .........)
Dynamic (planned) way: MyWindow = OpenWindow(#PB_Any, .......)

The #PB_Any will be a special value which will inform than it should return a valid number dynamically. It's NOT an OS handle, it's a reserved PB handle. Of course, you can mix both way without any trouble. I prefere the current way but I should agree than in some situation, a dynamic way is easier.

The only confusion it could implie is than the handle is not an OS one, so you have to use WindowID() to get the valid OS handle in the second case. The first case it can be done in one line: *Handle = OpenWindow(#MyNumber, ....)

Fred - AlphaSND

Posted: Wed Jan 08, 2003 5:58 pm
by BackupUser
Restored from previous forum. Originally posted by tranquil.

@Fred:

Your idea is okay but then there should be a command to get the handle of every object of PB. (eg Gadget handles) Or is there a command yet that returns the current Gadgets handle? This is strongly required as you surely know yourselfe.

If this is garanted th #PB_Any is a good solution and keeps compatiblity.

Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
System 2: Mobile Pentium 4 2.4GHz 512 MB DDR GeForce4 420-32, Windows XP Home