Common structures across several scripts in same panel

Discussion about recent product features & solutions!
4 posts • Page 1 of 1
Smiffy
Posts:45
Joined: Thu May 18, 2017 4:21 pm

Common structures across several scripts in same panel

Post by Smiffy »

Is there any way of defining structure types in such a way that they are acessible from all scripts in the same panel?
I have tried putting the structure defs in the scope lib, but this is not possible as this gives a syntax error (function defs are fine but structure defs are not).
The usual way in 'c' is to put them in a header file and incluse this is the individual source files.
The workaround that I have had to employ is to have copies of the structures in each script, which is naff as this then means that you have to remember to update all structure defs in each file instead of just in one file - not good.

Smiffy
Posts:45
Joined: Thu May 18, 2017 4:21 pm

Re: Common structures across several scripts in same panel

Post by Smiffy »

Well I have tried a bit of experimentation.
I you have the structure type definitions in common area such as ScopeLib in doesn't work as any script that uses the type (execpt for functions in ScopeLib) will not compile as they do not understand the definitions (cannot see them it seems despite them being defined in a common area). Functions it seems are fine and can be defined once in ScopeLib and used in any script within that panel.
Ah well I tried another rather silly approach (I was getting deparate) by including the same structure definitions in each object script that uses it. This compiles OK, but sadly, fails with a runtime error about the definitions being defined multiple times.
So iot seems that you have to "pick your error" - you can have a syntax error or a runtime error.

Gertjan van Schijndel
Posts:634
Joined: Mon Aug 02, 2010 10:37 am

Re: Common structures across several scripts in same panel

Post by Gertjan van Schijndel »

Is it not an option to define the structure types in a library and use this library in the panel?

morpurgo
Posts:4
Joined: Mon Mar 28, 2011 11:04 am

Re: Common structures across several scripts in same panel

Post by morpurgo »

I think this problem (of structures defined in scopeLib but not immediately recognized inside panel scripts) was fixed in the most recent 3.15 versions.

4 posts • Page 1 of 1