Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Create table via method

Pioneer
Pioneer

Hey guys,

i have a problem with the creation of a table.

 

I want to create a table via method after a vehicle left his source. The source produces more than 1 vehicle so i want that every table is named after the vehicle for later editing in the following processes.

 

I got this code so far..

is
do
	if existsObject(@ & "_Bestand") then
		@ & "_Bestand".deleteObject;
	end;
	
	local obj := .Informationsfluss.Tabelle.erzeugeObjekt(current,100,200); --createobject
	obj.Name := @ & "_Bestand";
	obj.setzeDatenTyp(1,"object");  --setdatatype
	obj.setzeDatenTyp(2,"integer");
	obj.setzeDatenTyp(3,"string");

end;

The problem is everywhere ' @ & "_Bestand" ' stands. With that way i want to name the first table for exampe Vehicle:1_Bestand.

 

I think it's because i couldn't use ":" for a table name, but how can i solve this problem when i don't know how much vehicles i must create? I'm also open for new ideas Smiley Happy

 

Thanks in advance

 

Greetings

Carsten

4 REPLIES 4

Re: Create table via method

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

@ returns an object, the number of the object you can read with @.id, then you need to follow some restrictions in naming in Plant Simulation ":" doesnt work, you can connect all with underscores

 

for deleteObject you need an object  --> convert the string with str_to_obj to an object

 

try this instead:

 

if existsObject(@.name+"_"+to_str(@.id)+"_Bestand") then
str_to_obj(@.name+"_"+to_str(@.id)+"_Bestand").deleteObject;
end;

 

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Create table via method

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi Carsten,

 

If you need a table for each vehicle, you can also create a user-defined attribute of type table for your Transporter in its class and format it there. Every instance that is created then automatically has its own table int he correct format.

 

The "&" is not valid syntax. You should either use "AND" (for conditional statements) or "+" to make summations and to concatenate strings.

 

The naming of objects is restricted to numbers, letters and the "_" sign, but it cannot start with a number.

 

If you need one centralized place for keeping some administration, I would create a single table-file and a column with sub-tables. Each vehicle then gets a sub-table of its own.

 

SimTalk: createNestedList()

 

Regards,
Gert Nomden


Gert Nomden
Digital Factory Consultant
cardsplmsolutions.com

Re: Create table via method

Pioneer
Pioneer

Thanks for the good explanation and the very quick response. It works how i want it and i learnded something new.

 

Thank you very much

 

Greetings

Carsten

 

Edit://

@Nomden: Thank you i will try your way,too. Sounds like a good solution to avoid a bunch of tables over each other Smiley Very Happy

I reply if i need another hint with that way Smiley Happy

 

Re: Create table via method

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi Carsten,

 

If you need a table for each vehicle, you can also create a user-defined attribute of type table for your Transporter in its class and format it there. Every instance that is created then automatically has its own table int he correct format.

 

The & is not valid syntax. You should either use AND (for conditional statements) or + to make summations and to concatenate strings.

 

The naming of objects is restricted to numbers, letters and the _ sign, but it cannot start with a number.

 

If you need one centralized place for keeping some administration, I would create a single table-file and a column with sub-tables. Each vehicle then gets a sub-table of its own.

 

SimTalk: createNestedList()

 

Regards,
Gert Nomden


Gert Nomden
Digital Factory Consultant
cardsplmsolutions.com