Passing string constants through a data file

Use this forum to post Vensim related questions.
Post Reply
rob_n
Senior Member
Posts: 53
Joined: Thu Feb 22, 2018 6:12 pm
Vensim version: DSS

Passing string constants through a data file

Post by rob_n »

Hi,

I can pass string constants through a .cin file. But when I am interested to use only a subset, I get errors like
"Too many values or unrecognizable value format" and
"bad type, incorrectly subscripted or not found".

I'd like to avoid .cin input errors by having all model data, including string constants in a .vdfx data model.

Are string constants save to a .vdfx file? Can string constants be read in from a .vdfx file?

Best regards,
Rob
rob_n
Senior Member
Posts: 53
Joined: Thu Feb 22, 2018 6:12 pm
Vensim version: DSS

Re: Passing string constants through a data file

Post by rob_n »

Here are two example models that show the problem.
Attachments
sample_uses_datamodel.mdl
(1.38 KiB) Downloaded 139 times
sample_datamodel.mdl
(1.15 KiB) Downloaded 138 times
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Passing string constants through a data file

Post by tomfid »

I think data i/o only works for numeric values. Strings would have to be in a .cin.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Passing string constants through a data file

Post by Administrator »

String variables are stored in the VDFX file. I think the only way to get them would be a new function like "GET STRINGVAR FROM VDFX FILE" as you cannot define a data variable to be of type string.

I'll add it to the list of things to do.
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: Passing string constants through a data file

Post by tomfid »

What's the use case for this?
rob_n
Senior Member
Posts: 53
Joined: Thu Feb 22, 2018 6:12 pm
Vensim version: DSS

Re: Passing string constants through a data file

Post by rob_n »

The application is supply chain for raw materials. There are ~1600 finished goods, and ~7300 raw parts. Since the FG and raw part names are long and awkward, I'd rather define subscript names in a convenient way,
FG : (f1-f600) and
part: (r1-r7300)
Since I cannot remember what part number r4545 is, I want to put a string in the plot title, e.g. \rname[r4545]/
So there string constants with the names of the finished goods and part numbers, fname[FG], rname[part]. These are long, and don't change, so I don't want to have to mess with them very much.

Since the model ends up being large (read: slow), I'd like to test it out with only a few finished goods and their complete bills of materials. I do this by
FG: f140,f256,f1234

But when I pass the string constants in the .cin files, I get errors for all the subscripts that are no longer defined.

The only way I can see to do this now is to make new .cin with only the subset of finished goods and part numbers (which makes it somewhat harder to construct the test case, but is doable).
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Passing string constants through a data file

Post by Administrator »

rob_n wrote: Fri Feb 12, 2021 5:42 pmBut when I pass the string constants in the .cin files, I get errors for all the subscripts that are no longer defined.
Are they errors or warnings? We changed the behaviour some time ago so that if an error was encountered, you could still contine.
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: Passing string constants through a data file

Post by tomfid »

One other option: use GET XLS SUBSCRIPTS or the GET DIRECT equivalent to define them.
rob_n
Senior Member
Posts: 53
Joined: Thu Feb 22, 2018 6:12 pm
Vensim version: DSS

Re: Passing string constants through a data file

Post by rob_n »

Administrator wrote: Fri Feb 12, 2021 8:58 pm
rob_n wrote: Fri Feb 12, 2021 5:42 pmBut when I pass the string constants in the .cin files, I get errors for all the subscripts that are no longer defined.
Are they errors or warnings? We changed the behaviour some time ago so that if an error was encountered, you could still contine.
The messages are errors.
Picture1.png
Picture1.png (749.94 KiB) Viewed 4742 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Passing string constants through a data file

Post by Administrator »

Try
pname[p3] :is: 'Third'
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: Passing string constants through a data file

Post by tomfid »

Right - the syntax should be the same as an equation: = for numbers, :is: for strings.
rob_n
Senior Member
Posts: 53
Joined: Thu Feb 22, 2018 6:12 pm
Vensim version: DSS

Re: Passing string constants through a data file

Post by rob_n »

I get basically the same result.

I should have mentioned that the .cin file for my test had three elements. Only the element in the .cin file but not in the model causes the error. Sample model and both .cin files attached.

Best regards,
Rob
Picture2.png
Picture2.png (745.7 KiB) Viewed 4724 times
Attachments
pname.cin
(65 Bytes) Downloaded 144 times
test_string.mdl
(1.12 KiB) Downloaded 149 times
rob_n
Senior Member
Posts: 53
Joined: Thu Feb 22, 2018 6:12 pm
Vensim version: DSS

Re: Passing string constants through a data file

Post by rob_n »

Here's the second .cin file
Attachments
pname2.cin
(74 Bytes) Downloaded 142 times
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Passing string constants through a data file

Post by tomfid »

The model has

part : (p1-p2)

so the error for p3 is expected.

However, we can downgrade it to a warning so that it still runs.
Post Reply