Page 1 of 2

A WITH command...

Posted: Sun Jun 12, 2005 8:50 pm
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

Posted: Sun Jun 12, 2005 8:54 pm
by yashaa
I found it in other (OOP) languages, and was pretty handy...

Posted: Sun Jun 12, 2005 11:52 pm
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

Posted: Mon Jun 13, 2005 12:39 am
by yashaa
Right, to not confuse with normal variables... :) Great!

Posted: Mon Jun 13, 2005 11:14 pm
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

Posted: Tue Jun 14, 2005 10:45 am
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 :))

Posted: Tue Jun 14, 2005 10:52 am
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...

Posted: Tue Jun 14, 2005 12:02 pm
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. :)

Posted: Tue Jun 14, 2005 12:04 pm
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.

Posted: Tue Jun 14, 2005 12:06 pm
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 ;)

Posted: Tue Jun 14, 2005 12:19 pm
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.

Posted: Tue Jun 14, 2005 12:40 pm
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...

Posted: Tue Jun 14, 2005 12:46 pm
by PB
I see... on English keyboards you just hit the "\" key alone.

Posted: Tue Jun 14, 2005 1:46 pm
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...

Posted: Tue Jun 14, 2005 1:56 pm
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 ;)