Page 1 of 1

[Implemented] With EndWith

Posted: Fri Sep 30, 2005 2:44 pm
by ts-soft
Example:

Code: Select all

Structure Test
  First.l
  Last.l
  Text.s
EndStructure

MyTest.Test
With MyTest
  First = 1000
  Last = 9999
  Text = "Hello PureBasic"
EndWith
Is clear Syntax, i hope

Posted: Fri Sep 30, 2005 3:12 pm
by Dreglor
i see one problem if your using varibles to set the structure that have the same name of the structure field you have problems

Posted: Fri Sep 30, 2005 3:25 pm
by Trond
EDIT: Oh my I'm thick sorry.

Posted: Fri Sep 30, 2005 3:30 pm
by ts-soft
Or so:

Code: Select all

MyTest.Test
With MyTest
  \First = 1000
  \Last = 9999
  \Text = "Hello PureBasic"
EndWith
like other programming languages

Posted: Fri Sep 30, 2005 3:34 pm
by Fred
Yes, it's planned.

Posted: Fri Sep 30, 2005 3:48 pm
by ts-soft
thx :D

Posted: Fri Sep 30, 2005 5:01 pm
by GedB
Excellent. 8)

Will it work with Interfaces, too?

Posted: Fri Sep 30, 2005 5:49 pm
by Fred
This will works as a real macro, which means you could put any expression after 'With', and it will be inserted before each orphan '\'.

Posted: Fri Sep 30, 2005 6:02 pm
by Psychophanta
BB 2 from Amiga supported this feature.
It used an easy way to do, something like this:

Code: Select all

Structure Test 
  First.l 
  Last.l 
  Text.s 
EndStructure 
MyTest.Test
Structure Test1
  a.l
  b.l
EndStructure
NewList li.Test1()
USEPATH MyTest.Test
\First = 1000 
\Last = 9999 
\Text = "Hello PureBasic" 
AddElement li()
USEPATH li()
\a=24
\b=25

Posted: Fri Sep 30, 2005 6:06 pm
by Psychophanta
Fred wrote:This will works as a real macro, which means you could put any expression after 'With', and it will be inserted before each orphan '\'.
Aha!, just replace the 'USEPATH' word by 'With' word :wink:

Posted: Fri Sep 30, 2005 6:47 pm
by GedB
Hmmmm, Reaaaal Maaaaacrooooooooos!

imagine Homer like drool.