Syntax highlighting? a) in Vensim, b) text exported from Vensim

Use this forum to post Vensim related questions.
Post Reply
kleemax
Senior Member
Posts: 125
Joined: Tue Jan 26, 2016 3:50 pm
Vensim version: PRO

Syntax highlighting? a) in Vensim, b) text exported from Vensim

Post by kleemax »

Syntax highlighting? a) in Vensim, b) text exported from Vensim

Vensim syntax can sometimes become cumbersome to understand (esp. if one tries to understand a model that someone else has built... :? )
Many programming languages feature text highlighting see:https://en.wikipedia.org/wiki/Syntax_highlighting, which makes understanding code much easier.

For example in Vensim it would be helpful if comments had a special color and built-in functions had a special color etc. Ideally different levels of nested parenthesis could also have differing colors.
"View as text" also contains headings if subgroups are defined for variables that could be colored.


I see two avenues with different time horizons:

a) on the medium to long term it would be helpful to have text highlighting implemented in Vensim (esp. "equation editor" and "view as text") Please let me know if I should I post this as a feature request somewhere else, too.

b) on the short term it would be easiest to export text (copy-paste) into a text editor that supports syntax highlighting. Importantly, the text editor would need support defining custom syntax highlighting for programming languages that are not already included with the software. I wonder if anyone has ever used this approach? Is there a format for the definition of syntax highlighting that can be shared (exported by one text editor and imported by another one)? Inter-operability between Windows and Mac would also be desirable in this sense.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Post by Administrator »

We have already build a new text editor for Vensim that includes syntax highlighting for things like VOC files. It will be in the 8.1 release of Vensim when using the new sketch tool.

I don't see how syntax highlighting for a model would work. The Vensim language is not like C/C++ where the language is well defined. We will include highlighting for the Vensim functions, there is not much else we can do though.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Post by tomfid »

Notepad++ has definable highlighting. Not sure how helpful it would be, but seems interesting to try.
kleemax
Senior Member
Posts: 125
Joined: Tue Jan 26, 2016 3:50 pm
Vensim version: PRO

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Post by kleemax »

@ administrator: cool that you are implementing it for some aspects in the next release. I'm not sure what you mean by the "new sketch tool", but I guess that's just because I use 7.3.4?
kleemax
Senior Member
Posts: 125
Joined: Tue Jan 26, 2016 3:50 pm
Vensim version: PRO

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Post by kleemax »

I have found that on the Mac it may be possible by using BB-Edit:
http://www.barebones.com/support/bbedit ... brary.html
http://www.barebones.com/support/develop/clm.html
It's a bit difficult for me because I'm not a programmer by education, but it looks promising
kleemax
Senior Member
Posts: 125
Joined: Tue Jan 26, 2016 3:50 pm
Vensim version: PRO

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Post by kleemax »

I am not sure what administrator means by "well-defined" Let me explain what I would like to do:
all comments in variables look like this in text view
~ comment first line \
comment second line \
|

I mean all comments are in between a tilde "~" and a "|"
Hence it should be possible to give them a defined color (e.g. orange as above).
Similarly, take a function like Delay N, it has a defined syntax DELAY N( _in_ , _dtime_ , _init_ , _order_ ). Hence it should e.g. be possible to color all of these in blue (as I have done above)
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Post by Administrator »

kleemax wrote: Thu May 21, 2020 9:48 am I am not sure what administrator means by "well-defined" Let me explain what I would like to do:
all comments in variables look like this in text view
~ comment first line \
comment second line \
|

I mean all comments are in between a tilde "~" and a "|"
The problem is that all text editors I know of, to highlight syntax, you specify key words. To highlight the comment in your example, we need to tell the text editor that the key words are "comment", "first", "line" and "second". This also means that every occurance of those words would also be highlighted, which is not what is needed.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
kleemax
Senior Member
Posts: 125
Joined: Tue Jan 26, 2016 3:50 pm
Vensim version: PRO

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Post by kleemax »

tomfid wrote: Wed May 20, 2020 5:58 pm Notepad++ has definable highlighting. Not sure how helpful it would be, but seems interesting to try.
Here is a link that outlines what Notepad++ could do in this respect:
https://npp-user-manual.org/docs/user-d ... ge-system/
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Syntax highlighting? a) in Vensim, b) text exported from Vensim

Post by Administrator »

kleemax wrote: Thu Jun 04, 2020 9:56 amHere is a link that outlines what Notepad++ could do in this respect:
https://npp-user-manual.org/docs/user-d ... ge-system/
If you manage to create a syntax highlighter, send it to us and we will add it to the workbench page on vensim.com.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Post Reply