Jump to content

Empfohlene Beiträge

Geschrieben

Anyone else having hard time knowing when to use a $ in front of a name in the event handler and when not to....

It seems a little arbitrary...

 

Does anyone have a good explanation of how it works and when u need it.

Geschrieben

$ 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.

 

Geschrieben
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.

 

Geschrieben

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 $

Geschrieben

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

 

Geschrieben

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

Erstelle ein Benutzerkonto oder melde dich an, um zu kommentieren

Du musst ein Benutzerkonto besitzen, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen.

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde dich hier an.

Jetzt anmelden
×
×
  • Neu erstellen...