Code Folding error combines commented VB blocks.

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Code Folding error combines commented VB blocks.

Post by gdyvig » Thu Feb 26, 2009 5:32 pm

If a VB block ends with a comment and a subsequent VB block starts with a comment, the two VB blocks and all non-VB script in between is combined into a single block. Paste the code below and see.

Gale

===========================================


VBSTART
MsgBox Hi
'end vbblock2
VBEND

SRT>Srt1
//whatever
END>Msg

VBSTART
MsgBox How are you?
VBEND

SRT>Srt2
//whateverelse
END>Srt2

VBSTART
'begin vbblock3
MsgBox Bye

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Problem is intermittant or caused by syntax error

Post by gdyvig » Mon Mar 02, 2009 5:04 pm

I didn't get any responses so I thought I would submit some screen prints to show what I was talking about. But I was unable to reproduce the problem.

The VB and SRT blocks are still chained together when I add the VB comments as described in the previous post. But you can expand and collapse the individual blocks no problem.

The problem I was having last week with the chained together blocks had to do with the AutoInsertion feature. If I tried to add a line to the end of Srt1 the editor would Autoinsert "END>Srt2" just before "END>Srt1". It was happending in a large script, so I wrote a minimal temporary script (which I never saved) and had the same problem. I tried it several times in separate Macro Scheduler sessions, always the same result.

This week I am not having the AutoInsertion problem with Code Folding blocks that are chained together. I have no idea why. Maybe a syntax problem somewhere else in the script. Maybe a memory problem since I was working with an unsaved script.


Anyone else see anything like this?

Thanks,
Gale

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

MS reserved words in vb comments

Post by gdyvig » Thu Mar 19, 2009 9:04 pm

I am seeing the code folding problem again.
It occurs if you use the VB commenting style in a VB code block or anywhere else in your script and it contains Macro Scheduler reserved words used for code folding.

This VB comment will cause no problems:

Code: Select all

'This is a VB comment
Neither will this one:

Code: Select all

'The script should repeat looping
'continuously until the test condition is true
But this will cause code folding and autoinsertion problems because of a repeat/until unbalance:

Code: Select all

'The script should repeat looping
'continuously while the test condition is false
Repeat>x
  Let>x=x+1
Until>x=3
In the above example, if you try to insert a line after the Let> statement, an extra Until> will be autoinserted.


This problem does not occur if you use the MS standard style of commenting:

Code: Select all

//The script should repeat looping
//continuously while the test condition is false
Repeat>x
  Let>x=x+1
Until>x=3
The same problem can occur for any nonMacroScript comment characters (#, -, whatever) containing any other highlighted words (SRT, END) used to define a MacroScript code block.

Can anyone duplicate this problem?

Thanks,

Gale



[/quote]

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Mar 20, 2009 9:30 am

Yes, because the parser has only been told that // and /* .. */ are comments and therefore to ignore things within them.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Can ' and Rem be made comments?

Post by gdyvig » Wed Mar 25, 2009 5:33 pm

Hi Marcus,

Can the Code Folding parser be instructed to treat ' and Rem as comments, especially if they are found within VBSTART/VBEND blocks?

Code Folding supports folding of vbscript functions, subroutines, if/endif blocks, it should ignore vbscript comments also.

Perhaps ' and Rem should also be treated as MacroScript comments by the parser if that would be simpler to impleement, maybe simpler for users also.

The workaround is to use Rem> as the universal comment.

Gale

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Re: Can ' and Rem be made comments?

Post by jpuziano » Wed Mar 25, 2009 7:31 pm

Hi Marcus,
gdyvig wrote: Can the Code Folding parser be instructed to treat ' and Rem as comments, especially if they are found within VBSTART/VBEND blocks?

Code Folding supports folding of vbscript functions, subroutines, if/endif blocks, it should ignore vbscript comments also.

Perhaps ' and Rem should also be treated as MacroScript comments by the parser if that would be simpler to impleement, maybe simpler for users also.

The workaround is to use Rem> as the universal comment.
Gale
I second Gale's request in that if the script engine is smart enough to be able to recognize ' (and whatever else) as denoting the line as a comment inside some VBScript code... then it would be nice if the "code folding" understood that as well and behaved accordingly.

However, Marcus, if improvements to code folding behavior are not possible or practical at this time... then in the Help File where it talks about how to enter a Remark/Comment line... perhaps it should list all the known ways we can denote a Comment line and the implications:

Remark> good inside MS and VBScript
Rem> good inside MS and VBScript
' only allowed inside VBScript, not supported by code folding
// good inside MS code only

If we know the implications, we can choose accordingly.

Thanks and take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Mar 26, 2009 11:16 am

Gale, John,

I've sent you a PM with a new version to test out.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Fri Mar 27, 2009 10:39 pm

Thanks Marcus.

Gale, did the improvements in version 11.1.07 address all the code folding issues you found?
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

My test results for 11.1.07

Post by gdyvig » Sat Mar 28, 2009 7:07 pm

Here are the results I sent to Marcus:
Hi Marcus,

I tested the Code Folding and Remarks.

Outside of VBSTART/VBEND blocks the only comment indicators were:

Quote:

/*...*/
//
'
Rem>
Remark>

This is as expected.


A commented line had these characteristics:
Quote:

All characters were bold navy, no special colors for key words, quoted strings.

No code folding


This is as expected.


A line beginning with a unrecognized charactor or command had these characteristics:

Quote:

All key words and quoted strings were highlighted as though they were in a line of code.

No code folding.

Will be treated by the interpreter as a comment.

This is as expected.

Within VBSTART/VBEND blocks the only comment indicator was:
Quote:

'

It should also recogize "Rem ", but not "Remark "

A VB commented line had these characteristics:
Quote:

All characters were normal pale yellow, no special colors for key words, quoted strings.


VBS Code folding occurred for a block of contiguous remarks, but not for code folding key words within the block


This is as expected.

A VBS ine beginning with a unrecognized charactor or command had these characteristics:

Quote:

All key words and quoted strings were highlighted as though they were in a line of code.

Code folding occurred on key word pairs if/end if, function/end, sub/end regardless even when they occurred in the middle of a line.

Will of course fail the due to a vbscript compilation error.

The code folding looks incorrect.


Code Folding starting within VBSTART/VBEND blocks

Quote:

Code Folding starting within a VBSTART/VBEND block does not autoinsert outside the block.

Code Folding occurs for all vbs control structures such as if/else/end if, functions, subroutines, etc.


No code folding for For/Next loop. Did not check beyond this.


Did not test user defined code folding blocks.


Gale
Code Folding worked as I hoped. After I reported the problem for For/Next loops Marcus added Code Folding for some additional code structures.

As I recall, there is still Code Folding following the vbscript "Rem " command, but Code Folding is properly ignored after the ' character.

After the official release:

I did not catch the problem with keyword "CR" highlighting in remarks and elsewhere.

Within VB blocks, remarks are not highlighted in pale yellow after "Rem ". Maybe the VB Rem command works differently than the ' character. I believe VB accepts "Rem ", but not "Remark " as a valid remark command.

Occasionally you will find that indented remarks after the ' character are not pale yellow. Removing the indentation and then reapplying it fixes that. There must be some some types of white space preceding a remark that messes up the highlighting.

Gale


Gale

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts