Vensim introducing backslashes in Var names before each underbar. Bug?

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

Vensim introducing backslashes in Var names before each underbar. Bug?

Post by kleemax »

I am working with underbars turned on in variable_names.
In an important model I am working in, when I edit a variable name, quotes and backslashes are introduced to the pre-existing part of variable names. Then the variables in which these variable names are used are complaining that they can't find the variables (in the equation editor, in the variables sections they do not appear.
The problem does not occur when I am working with underbars turned off. And the problem does not appear in all models but in only one specific model. I cannot share the model in which the problem is occurring due to intellectual property rights policy in the company I work for. However I have pasted an example of the problem into another model that I have attached.
If you have underbars turned off there is a variable that appears as ‘another_variable edited’. If underbars are turned on it appears as another_variable_edited, in the equation editor (and in the text view of the model it appears as "another\_variable edited" (with the quotes). I would expect this result if I had underbars turned off and typed an underbar. Because then vensim would think the underbar is part of the variable name and the quotes and the backslash are Vensims way of implementing that. However, this happens if I have underbars turned on and type a space! It does not happen when I first create a variable but it happens when I edit an existing variable.
One could also think that this happens because when editing a variable, an underbar is shown and then a space is used in the second variable. However, if I try the same in other models, the problem does not occur. This suggests that there is something in the model that causes vensim to do what it should not do. Do you have any idea what this is? It’s almost as if while the settings tell vensim that underbars are turned on, something in the model is telling vensim that they are turned off.
I can work normally if I turn underbars off. The problem is though that multiple people are working on the model which resides in a versioned repository and the convention is to have underbars turned on. This convention is somewhat important as it affects the text form of the model when it is saved. So right now, as a workaround I work with underbars turned-off and then before I update the version shared with the other modellers, I have to be extra careful to remind myself to turn them on again before saving the model.
Is this a known bug in Vensim 8.0.9 that has been solved in subsequent Vensim Versions? I am asking because a colleague of mine is also in negotiations with you about updating our companie’s licences for Vensim.
Attachments
Vensim Problem underbar backslash.mdl
(1.25 KiB) Downloaded 204 times
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Vensim introducing backslashes in Var names before each underbar. Bug?

Post by tomfid »

I haven't checked the logs yet to see if we've changed any of these behaviors, but I doubt it.

I can replicate your model by typing an explicit underbar in a new variable name, when underbars are turned off. It's sensible that an escape character (\) is needed in this case.

However, I can't replicate is this:
If you have underbars turned off there is a variable that appears as ‘another_variable edited’. If underbars are turned on it appears as another_variable_edited, in the equation editor (and in the text view of the model it appears as "another\_variable edited" (with the quotes). I would expect this result if I had underbars turned off and typed an underbar. Because then vensim would think the underbar is part of the variable name and the quotes and the backslash are Vensims way of implementing that. However, this happens if I have underbars turned on and type a space! It does not happen when I first create a variable but it happens when I edit an existing variable.
If I turn on underbars and type a space, the space gets replaced by an underbar, even if I enclose the new name in quotes and manually add an escape character. I think I need more information to replicate this:
- Are you working in the text editor or the equation editor?
- If the eqn editor, are you changing the variable name field (LHS), or something in the expression (RHS)?
- When you say "this" do you mean that you type var<space>name and get var\<space>name, or var\_name, or something else?
kleemax
Senior Member
Posts: 125
Joined: Tue Jan 26, 2016 3:50 pm
Vensim version: PRO

Re: Vensim introducing backslashes in Var names before each underbar. Bug?

Post by kleemax »

Thank you for trying to help me.
I am typing neither in the equation editor nor in the text editor but I use the variable tool (the tool you'd use to create an auxilliary var) to edit a variable name. When I do that with underbars turned on in the settings, when entering it it looks like 'variable_name edited# if the word 'edited' (both without the quotes) is what I have added. Now when I open the equation editor what I see is "variable\_name_changed". NOte that both underbars were typed as spaces.
Note again that this happens with underbars turned on, only. Note taht I have not done anything in the equation editor nor the text view.
By "this" I mean "variable\_name_changed".
And note also that it must be something in the model causing this behavior, because I can only reproduce that behavior in that model not in other freshly created models.bThere must be something in the model that causes Vensim to exhibit the kind of behavior one would expect with underbars turned-off, when they are turned on.
My hypotheses/questions:
1. what would vensim do, if in text view there is a mix, some vars with underbars and some without?
I mean normally if you don't work in text-view this could never happen because depending on whether underbars are turned on or off, vensim would save the model with our without underbars, converting it if the setting had been changed. However, we have several people working with the model.
2. Also I should tell you that those people working in the model use different versions of vensim, some as new as 8.0.9 and some as old as 5.3, if I am not mistaken. Other yet 6.4. Could that cause issues?
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Vensim introducing backslashes in Var names before each underbar. Bug?

Post by tomfid »

I think your comments explain why I couldn't replicate this in a new model.

1. As far as I can tell from experimentation, the only problematic combination is an escaped underbar added manually (with underbars off). It doesn't cause crashes or parse failures, but it does persist unnecessarily. I couldn't discover a combination effect.
2. I'm not aware of changes back as far as about 5.11, but there are 2000 log entries over that time, so it's hard to be sure.

One thing to check might be to use an external text editor (Notepad++) to search the model for \_ or \<space> and delete the backslashes (saving to a different name or using source control to preserve the original). Just be careful that \<space> doesn't occur as a line extender for long lines - I don't think that could happen. After a cleanup, this might improve behavior, though I can't think of a reason for it to spill over from one equation to another, so it's a long shot.
kleemax
Senior Member
Posts: 125
Joined: Tue Jan 26, 2016 3:50 pm
Vensim version: PRO

Re: Vensim introducing backslashes in Var names before each underbar. Bug?

Post by kleemax »

Have done a search for \_ or \<space>. No hits.
Any further ideas?
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Vensim introducing backslashes in Var names before each underbar. Bug?

Post by tomfid »

A few:
- If you look at it with a text editor, does the troublesome model start with {UTF-8} consistently? Mixing pre- and post-unicode versions of Vensim could be an issue.
- Try a Model>Reform & Clean before you start editing to see if the problem goes away (but be cautious before checking in, as it could introduce whitespace or order changes).
- Can you post the text of a single equation before/after editing, maybe using the Document tool?

The latest version has some big improvements for cross-platform source-control friendliness, largely inspired by ClimateInteractive's workflow. Reform/Clean can be automated to preserve alphabetical order. Diagram items move around less. In our betas, we've also moved some of the settings that aren't relevant to model structure into a sidecar file.
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Vensim introducing backslashes in Var names before each underbar. Bug?

Post by tomfid »

I'd completely forgotten about it, but there's one more setting to check:
2021-03-03_14-38-35.png
2021-03-03_14-38-35.png (8.49 KiB) Viewed 2274 times
This might explain why you only have trouble with the one model.
Post Reply