Jump to content
Melde dich an, um diesem Inhalt zu folgen  
ademes

Variable into variable

Empfohlene Beiträge

Hello, (german follows)

I'm searching since a few days without seing the solution...  So, I need your help.

Situation :

I have a track called "section" in which I have the variable "Canton" with the value "section_1"; this value is the name of a variable in the object "itinary".

I have another object called "Itinary" describing the traject for the train; in this object itinary, I have defined the variable "section_1" having the value "section_3" which is the next section.

I need to set the object variable "section.next_section" to the value from the object variable itinary.XX where XX stands for the name found in the variable canton from object "section"

Section.canton = section_1 - (section_1 this is the name of the variable from itinary containing the name of the next section for this section)

Object                 variable                             value
Section                canton                              section_1
itinary                  section_1                          section_3

Event
Train enters track               Section
No conditions
Actions :
  1  set variable A =
$((_Trigger2.data)._Name).canton                                                          ==>  A = section_1 (= name of the variable in itinary)
  2  set variable $((_Trigger2.data)._Name).next_section = $(itinary._Name).????                ==> next section = section_3
                                                       where ???? must be the variable's name which value is contained in the variable A

how to build this action?

Thank you for your help
regards

 

Hallo, folgt

Ich suche seit ein paar Tagen ohne die Lösung zu sehen ... Also brauche ich deine Hilfe.

Situation :

Ich habe eine Spur namens "section", in der ich die Variable "Canton" mit dem Wert "section_1" habe. Dieser Wert ist der Name einer Variablen im Objekt "itinary".

Ich habe ein anderes Objekt namens "Itinary", das den Trajekt für den Zug beschreibt. Ich habe in diesem Objekt itinary die Variable "section_1" mit dem Wert "section_3" definiert, der den nächsten Abschnitt darstellt.

Ich muss die Objektvariable "section.next_section" auf den Wert aus der Objektvariablen itinary.XX setzen, wobei XX für den Namen steht, der im Variablenkanton aus Objekt "section" gefunden wird.

Section.canton = section_1 - (section_1 Dies ist der Name der Variablen aus itinary, die den Namen des nächsten Abschnitts für diesen Abschnitt enthält.)

Objekt                 variablen                           wert

Section                canton                              section_1
itinary                  section_1                          section_3


Event
Train enters track               Section
No conditions
Actions :
  1  set variable A =
$((_Trigger2.data)._Name).canton                                                          ==>  A = section_1 (= Name der Variablen in itinary)
  2
et variable $((_Trigger2.data)._Name).next_section = $(itinary._Name).????                   ==> next section = section_3
                                                       woher ???? muss der Name der Variablen sein, deren Wert in der Variablen A enthalten ist

Wie baut man diese Aktion auf?

Danke für deine Hilfe
Grüße

André

 

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen

Unfortunately for an indirect access you can just peek the name of an object, but not the name of an object variable.
So this leads to nothing:

vor 20 Minuten schrieb ademes:

this value is the name of a variable in the object "itinary"

 

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen

Hi Andy

Do you mean "NO SOLUTION"?  No turn around?

André

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen
Geschrieben (bearbeitet)

I'd be glad if someone could tell a solution, I'd need it too.
Perhaps, if you can describe the whole situation more detailed, we can find another workaround.
So far, the only solution is a pack of events looking like this:
event: train enters track  condition: variable got value: _Trigger2.canton  value: section_1   action: _Trigger2.next section = $itinary.section_1;
event: train enters track  condition: variable got value: _Trigger2.canton  value: section_x.   action: _Trigger2.next section = $itinary.section_.x;
...

Andy

btw: you don't need to write $((_Trigger2.data)._Name). ,  _Trigger2 is enough.

Bearbeitet von Andy

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen

Hi Andy,

The purpose is to build a common event able to pilot a train through the succeeding sections of the layout, according to an itinary (traject).  This means that each time a decision has to be taken for the next section to reserve, I would find the name of this next section as the value of the object variable called itinary._Trigger2.  But this combination doesn't work!

In addition, I will assign the same name to all tracks acting as section : the name will be section and this object will have a pointer to an external table called "variable_sec_n" (n varying for each section) where all needed data will reside.  This permits to copy this table easier than if the data are part of the track itself.  So, I hope to have only one event to manage all sections in my layout.  But, as Martin Luther King said : " I had a dream..!".

The itinary to be followed by a specific train  is defined as the object variable itinary in the object train.  So, changing the traject for a train becomes very simple.

Have a look to the event "test" in the following layout used for the different tests I'm doing.  The results of this event are displayed in the center of the layout (value of A / B / C).  However, the value of C is currently coded as $((_trigger1._Name).itinéraire).section_1 where I hope to replace section_1 by the content of another variable and that is the current objective I'm trying to reach.

I hope that it is now clarified for you.  Anyway, thank you for your help.

Regards

André

test itinéraire 2.mbp

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen

Hi Andre'

I had a look at your layout. There is a board that looks like the template for your EM. What I cant find are the objects you labeled as objects and allocated variables to with values. No object by the name section_1 or sec_1.....

ademes.thumb.JPG.f011bbf23a1966451efdc79107ab8fc9.JPG

I noticed the 5 cube-objects named "Variable_sec_1" to 5 with lots of object-variables but can't see those referenced in the EM entries. Likewise I could not find the objects referenced in the EM either. Maybe those cubes should be the objects Section_1 to 5?

Cheers

Tom

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen

Hi Tom,

This layout is my "laboratory" where I test different thinks.  So, don't be scared if you don't find any logic between the layout and the events.

1. The 5 cubes you discovered are well object containing variables normally attached to a specific track (say section_n) within a block.  The only reason is the following : if those variables were really attached to a track, it becomes impossible to just copy them if the new track is different (straight><curved, long><short,...).  Having independant object solved this problem.

2. The board you discovered there is only a way to remember the syntax.

3. Each block has a track called "section"; their usage is to manage the block mentionning all needed data such as reservation, name, signal, etc...  But, as earlier explained, these object-variables are set into the 5 cubes you discovered and the section track object contains only one variable "section.data", linking that track to its specific cube.  The purpose was to have one and only one event for all "section track", but it seems to be impossible in V4 as discovered earlier in this thema : the variable's name must always be hardcoded and cannot be the value of another variable : VAR1 has the value TRK01 but one may not use $VAR1 as the name of the variable TRK01.  In other words, the syntax $(VARx._Name).$VAR1 is wrong.                                    André

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen
vor 28 Minuten schrieb ademes:

This layout is my "laboratory" where I test

somehow that looks pretty familiar :)

vor 28 Minuten schrieb ademes:

The board you discovered there is only a way to remember the syntax

just like here too ;)

@metallix

vor 30 Minuten schrieb ademes:

.$VAR1 is wrong

that's the one I explained to you. That's not possible. The concept is pretty interesting, but forced to wait. I'm just glad that those things happen more and more.
Still hope that this will be a fluffy place again.

regards
  Andy

notes.jpg

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen

Hi André,
this is the easiest solution to the problem. It's this 'event pack' filtering the optional variables.
First switch: Initializes the system, sets the 'object' indirect to the 'switch' Traject1 and feeds that one with a functions name. It also feeds 'return', because in each more switch 'return' gets given to the parameter 'par'.
More switches: always feeds 'par' with 'return' and switches 'object'. 'object' contains Traject1, and that one's function is 'get section'.
The other events are each for one possible variable in Traject1.
With the _Trigger-trick all switches may be possible, so we filter it with a 'Typ' defined in 'Traject1' and the function (here 'get section').
Then the approbiate object variable gets picked depending on the content of 'par' and is given to 'return'.

regards
  Andy

traject.mbp

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen

Hi Andy,

Thank you for your suggestion.  Unfortunatally, this is not what I'm searching as you still hardcode the block names.  However, your reflexion on using soft switches could be the opening of a new way to solve my problem, but I'm just thinking abot that.

I'll come back to you if I find a solution.

Regards

André

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen

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
Melde dich an, um diesem Inhalt zu folgen  

×