Jump to content

To $ or NOT to $..That is the question..


trevor
 Share

Recommended Posts

$ represents a global variable.  one that is generated by MBS itself or results from a call to an embedded function.  A global variable exists only once in a layout and can change when the function that created it is called again.  

object variables are assigned to a specific object in MBS and each object can have different values for the same variable.

 

Link to comment
Share on other sites

9 minutes ago, Curt84328 said:

$ represents a global variable.  one that is generated by MBS itself or results from a call to an embedded function.  A global variable exists only once in a layout and can change when the function that created it is called again.  

object variables are assigned to a specific object in MBS and each object can have different values for the same variable.

 

Not sure that is true Curt, it seems to be more to do with "this is a name not a string"... but sometimes u need it, sometimes you don't.

 

Link to comment
Share on other sites

you could look at my examples...

ScreenShot_20160921201032.pngobject variables are set by clicking on the object, then clicking on the bars at the right edge (Circled in black here) and then entering the name and value of the  variable.  I eScreenShot_20160921200952.pngntered a variable  "Color" and value Black.   I cannot currently make it read speed. 

 

 

 

 

 

 

Here the EV shows 2 global variables,  prestopper and stopper that were created by an event and they change. 

there are also two object variables   

(Object name.variable    value)

construction train.color   black   and

construction train.speed    (some nonworking garbage)

 

prestopper and stopper would be referrenced with a $

Link to comment
Share on other sites

Hello Trevor and Curt,

within the event control handling, there are some actions which allow to assign a text content, e.g. "Set Variable". Here the $ sign is used to distinguish between the variable name and the variable content as shown in the following example:

Let "VariableContent" be the content of the Variable named "OldVariable".
Let "NewVariable" the name of the variable to which "Oldvariable" will be assigned.

If you assign NewVariable = OldVariable, the content of NewVariable is "OldVariable".
If you assign NewVariable = $OldVariable, the content of NewVariable is "VariableContent".

You can test with the following example:   Assign Variable Name or Content.mbp
Click to the switch to turn it on or off.
Consider also the implemented event control.

See also the Wiki:
Einige Felder erlauben sowohl die Angabe von konkreten Zahlen oder Zeichenketten, wie auch den Namen einer Variable (wie z.B. die benutzerdefinierte Objektauswahl oder das Setzen von Beschriftungen). Fügen Sie bei der Angabe von Variablen ein Dollarzeichen ($) vor den Namen ein, um dem 3D-Modellbahn Studio zu verdeutlichen, dass es sich bei der folgenden Zeichenkette um den Namen einer Variable handelt, und nicht um den tatsächlichen Wert.

Many greetings
BahnLand

 

Link to comment
Share on other sites

Yes I understand that principle, but it is weird and inconsistent depending on the test or action selected.
 
Where it expects a NAME the $ can mess it up.
Some places when you think it SHOULD expect a name you need the $.... 

I end up trying it one way, testing (debugging is NOT a simple matter with complex criteria), then adding or removing the $ to see if it helps.

 

Screenshot_57.jpg

Screenshot_58.jpg

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...