A WITH command...

Got an idea for enhancing PureBasic? New command(s) you'd like to see?

Want this?

Yes
22
85%
No
4
15%
 
Total votes: 26

User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

A WITH command...

Post by Joakim Christiansen »

It's not important, but it might be handy.
Maybe something like this:

Code: Select all

Structure Player
  Name.s
  X.w
  Y.w
  Direction.w
EndStructure

Player1.Player

With Player1
  Name = "Player 1"
  X = 100
  Y = 100
  Direction = 90
EndWith

NewList Players.Player()

AddElement(Players())
With Players()
  Name = "Player"
  X = 100
  Y = 100
  Direction = 90
EndWith
Example of some code i'm writing right now:

Code: Select all

Box(Window()\X,Window()\Y,Window()\Width,Window()\Heigth,RGB(92,92,92))
Box(Window()\X+1,Window()\Y+1,Window()\Width-2,Window()\Heigth-2,RGB(148,148,148))
Box(Window()\X+2,Window()\Y+2,Window()\Width-4,16,RGB(128,128,128))
It would look much bether like this:

Code: Select all

With Window()
  Box(X,Y,Width,Heigth,RGB(92,92,92))
  Box(X+1,Y+1,Width-2,Heigth-2,RGB(148,148,148))
  Box(X+2,Y+2,Width-4,16,RGB(128,128,128))
EndWith
Last edited by Joakim Christiansen on Sun Jun 12, 2005 9:00 pm, edited 1 time in total.
I like logic, hence I dislike humans but love computers.
yashaa
User
User
Posts: 19
Joined: Sun Jun 12, 2005 8:19 pm

Post by yashaa »

I found it in other (OOP) languages, and was pretty handy...
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

It's on the todo list but will requiers the '\' before the variables:

Code: Select all

With Players()
  \x = aa
  \y = vv
EndWidth
yashaa
User
User
Posts: 19
Joined: Sun Jun 12, 2005 8:19 pm

Post by yashaa »

Right, to not confuse with normal variables... :) Great!
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

Fred wrote:It's on the todo list but will requiers the '\' before the variables:

Code: Select all

With Players()
  \x = aa
  \y = vv
EndWidth
I can live with that, thanks Fred :D
I like logic, hence I dislike humans but love computers.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Hum, just to say that the "\" character is really slow to write, that would consume time in the programming :D (Ok, I'm joking, but seriously I would rather have "/" or something like that :))
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post by Blade »

Silly. ;)
\ is already used in PB for structures, so why introduce anothe way to do the same?
Other languages uses . but I find \ pretty handy...
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> the "\" character is really slow to write

Why is it slow? It's not like you need to press Shift to type it... it's got its
own key on the keyboard... typing $ is slower because you need Shift. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

on a danish keyboard you have to press AltGR+the button to make it ;)
so its likely that way on other european keyboards too.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

PB wrote:It's not like you need to press Shift to type it... it's got its
own key on the keyboard...
Errm, apart from this being kinda redundant, I have to use [Alt-Gr] and [?] :)

EDIT: ah, thefool was (much) faster ;)
Good programmers don't comment their code. It was hard to write, should be hard to read.
ColBoy
Enthusiast
Enthusiast
Posts: 143
Joined: Fri Feb 13, 2004 2:37 pm
Location: Ottawa, Canada
Contact:

Post by ColBoy »

Instead of a "\" could we not have a "." instead. This then follows the same convention as other languages and makes code a lot easier to read.
Colin
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

ColBoy wrote:Instead of a "" could we not have a "." instead. This then follows the same convention as other languages and makes code a lot easier to read.
Yes, this is not a bad idea.
As thefool said, it's not that easy to type it, need to push altGr and 8 on my keyboard...
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

I see... on English keyboards you just hit the "\" key alone.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

on my iBook keyboard, there is no key/key combination for this at all :D

Dunno what the Apple people thought here, but it just isn't there...
quidquid Latine dictum sit altum videtur
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post by Blade »

In italian kb I have the \ key :)
Instead, ~ is not present, and have to press ALT + 126 to obtain it.
Lukily it's not too used here ;)
Post Reply