question

Marian Cretu avatar image
0 Likes"
Marian Cretu asked Matthew Gillespie commented

How to transform a pointer to a string

Hello all,

I need to cross reference data between 2 tables.

First I query table 1 and i get the result token.destination as a pointer data.

Then I need to query table 2 based on token.destination as a primary key.

The problem is that token.destination is a pointer and in table 2 I only have string data.

Thank you very much.

Regards,

FlexSim 19.1.1
string
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Joerg Vogel avatar image
2 Likes"
Joerg Vogel answered Matthew Gillespie commented

The method getpath(..) transforms the pointer to a string.

The method find(string path) transforms the string path to a pointer.

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Niket M avatar image Niket M commented ·

@Joerg Vogel What if I am writing the pointer into a label and then want to read the pointer value into a string? I have a pointer like "/Station3A" and want to read last letter of the pointer into a string. I assume there should me something like label.str[-1] but I think C++ will have different syntax.


0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Niket M commented ·

@Niket M First you want to get the name of the object stored on the pointer label, and then you can use the string.substr() method to get the last character in the string like this:

string myName = token.Station.name;
return myName.substr(myName.length, 1);
0 Likes 0 ·