xsharp.eu • better error message: for instead of foreach
Page 1 of 2

better error message: for instead of foreach

Posted: Tue Sep 17, 2019 9:17 am
by wriedmann
Hello,

one of my frequent errors when using the "foreach" statement is to write "for" instead of "foreach". i.e. to write

Code: Select all

for oItem as MyItem in oList
next
instead of

Code: Select all

foreach oItem as MyItem in oList
next
In this case the compiler gives a similar error message:

Code: Select all

error XS9002: Parser: unexpected input ....
Would it be possible to specify it better?
Thank you very much!
Wolfgang
P.S. I'm asking here before adding a ticket because I'm not sure if such a request is appropriate

better error message: for instead of foreach

Posted: Tue Sep 17, 2019 1:05 pm
by FFF
Wolfgang,
not what you asked, but are you aware of this in template.cfg in XIDE:
..
fore,FOREACH c AS IN rNEXTr
forei,FOREACH IMPLIED c IN rNEXTr
...

I know, i use the shortcuts not enough, as i code too little to memorize them, but in this case it might be helpful.

BTW, @Chris: i think i asked for this years ago ;), but the icing on the cake for this would be:
fore <Tab>
myItem <Tab>, Cursor jumps behind the "AS "
myType <Tab>, Cursor jumps behind the "IN "
myCollection <Tab>, Cursor jumps to next line

I just think you and you baby could do this ;-)

better error message: for instead of foreach

Posted: Tue Sep 17, 2019 1:42 pm
by wriedmann
Hi Karl,

yes, I'm aware of it. My main problem is that I'm not able to remember all these templates - I'm using only very few of them.

Wolfgang

better error message: for instead of foreach

Posted: Tue Sep 17, 2019 2:08 pm
by FFF
wriedmann wrote:Hi Karl,

yes, I'm aware of it. My main problem is that I'm not able to remember all these templates
B)
So i'm not alone...
But, as i wrote, the "multi tab" would enhance the usefullness a lot further...

better error message: for instead of foreach

Posted: Tue Sep 17, 2019 2:26 pm
by wriedmann
Hi Karl,

maybe I will add a context menu entry to select a template to insert - that could help.

Wolfgang
P.S. did you knew I'm driving a "poor mans Tesla" now?

better error message: for instead of foreach

Posted: Tue Sep 17, 2019 2:38 pm
by Chris
Wolfgang - Yeah, agreed, there are several places where parser errors could become more straightforward. As time passes, more an dmore of them will be improved, it's just not of highest priority. Will log this particular one.

Karl - Every single time I use the FOREACH template, this is exactly what I am also thinking, so it is not that I have forgotten about it :). It's just a lot of work to implement it and it will be useful in only 2-3 templates, but will finally do it in one rainy day!

better error message: for instead of foreach

Posted: Tue Sep 17, 2019 2:42 pm
by wriedmann
Hi Chris,

thank you very much!
It is of course a lot of work to prodice useful error messages, but it will be very helpful for people starting with X#, I think.

Wolfgang

better error message: for instead of foreach

Posted: Tue Sep 17, 2019 2:55 pm
by FFF
wriedmann wrote:P.S. did you knew I'm driving a "poor mans Tesla" now?
A "3"? Congratulations! Meanwhile i'm at 62,5k km in < 18 months, still grinning everytime i see my car ;-)

better error message: for instead of foreach

Posted: Tue Sep 17, 2019 2:58 pm
by wriedmann
Hi Karl,

no, a Renault Zoe. The 3 is still off limits for me, but maybe in a few years <g>.
10.000 km in about 4 months... and very happy with it.

Wolfgang

better error message: for instead of foreach

Posted: Tue Sep 17, 2019 3:05 pm
by Chris
Hi Wolfgang,

The problem is not writing messages, this is the very easy part. The big task is not letting the parser handle those situations in a general way, but provide specialized error identifying and reporting for every single different case.

Btw, congrats for your Zoe! (which means "life" in Greek)