EndWith keyword; what for?
- Psychophanta
- Always Here

- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
EndWith keyword; what for?
Isn't useless EndWith keyword ? :roll:
Re: EndWith keyword; what for?
It's used after the With keyword so why is it useless?
- Joakim Christiansen
- Addict

- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
- Psychophanta
- Always Here

- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Yes, but if there was omitted nothing would happen.
'With' statement is a precompiler one.
You can write 'With list()' at any place of your code, and after it you can refer to list()\var1 (for example) making: 'With list()\var1' and after it there could be 'With struc2' for example ... and so on... and never need for a EndWith instruction.
So then, why is needed the EndWith statement
The only reason i find is for return to a normal path writing, but i find it a bit nonsense.
(This is a request, it should be in the requests section.)
'With' statement is a precompiler one.
You can write 'With list()' at any place of your code, and after it you can refer to list()\var1 (for example) making: 'With list()\var1' and after it there could be 'With struc2' for example ... and so on... and never need for a EndWith instruction.
So then, why is needed the EndWith statement
The only reason i find is for return to a normal path writing, but i find it a bit nonsense.
(This is a request, it should be in the requests section.)
- netmaestro
- PureBasic Bullfrog

- Posts: 8452
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
- Joakim Christiansen
- Addict

- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
- Psychophanta
- Always Here

- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Well, that's an explanation about how is internally done the With-EndWith stuff.netmaestro wrote:With is a macro that goes along and adds stuff to the lines inside the With-EndWith block, fleshing them out to fully qualify the references. I guess it needs to know when to stop, else it would be adding "MyList()" or whatever to every line in the program.
But my request disregard how or how not it is done.
I only say that 'With' has no need to be ended with a EndWith, but only ending program or with another 'With'.
EndWith is used to close a With block like this:
You couldn't do that without EndWith so that's why it's needed.
Code: Select all
Structure One
OneItem1.b
OneItem2.b
OneItem3.b
EndStructure
Structure Two
TwoItem1.b
TwoItem2.b
TwoItem3.b
EndStructure
With One
\OneItem1=1
\OneItem2=2
\OneItem3=3
EndWith
With Two
\TwoItem1=1
\TwoItem2=2
\TwoItem3=3
EndWith
That's the same for enumerations as well. But we never heard anything about that. In fact, we don't need the enumeration keyword at all, since we can do #Constant = value and the next constant will get the next value!Psychophanta wrote:Well, that's an explanation about how is internally done the With-EndWith stuff.netmaestro wrote:With is a macro that goes along and adds stuff to the lines inside the With-EndWith block, fleshing them out to fully qualify the references. I guess it needs to know when to stop, else it would be adding "MyList()" or whatever to every line in the program.
But my request disregard how or how not it is done.
I only say that 'With' has no need to be ended with a EndWith, but only ending program or with another 'With'.
I think Fred said the obvious about it.
- Psychophanta
- Always Here

- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
- Psychophanta
- Always Here

- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:

