Variable Table Name

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Roma
Posts: 6
Joined: Monday 08 July, 2013 - 10:54

Variable Table Name

Post by Roma »

Hello ED Community,

I allready came to this forum and it was really helpfull!

Now I have a problem were I'm really stuck with, so hopefully you can help me out this time as well.

Personally I think it must be possible, but how:

I have simulated a distribution system, with different magazines in table form. For example: Magazine_Amsterdam, Magazine_Rotterdam, Magazine_Utrecht, etc, are all different tables.

What I need:
In my central warehouse table I have the names Amsterdam, Rotterdam, Utrecht, at different lines (each line is a order for a different sub magazine). Now I want to transport each line to the table of the different sub magazines (the name of the submagazines is in colom 4). I tried to use:

Help :=Concat(Magazine,[_],Table(i,4). And than call by the use of the name: help, but the system does not see this string as the table name. So how can I call this "help" (Sting/variable) in the normal settable syntax.

Hope you can help!





a possibility to write to this magazine tables in a concat function.

I've got a couple of tables,
menno
Posts: 45
Joined: Tuesday 29 March, 2011 - 16:01

Re: Variable Table Name

Post by menno »

Hello Roma,

You cannot use the word 'Help' as a variable, because it is already in used ED.

I do not know where you are using your piece of code, but you can try to use a local variable, for instance 'strHelp'.
This is how you can declare a variable.

Code: Select all

var([strHelp], vbString)
The type of variable is a string, which is vbString in ED. If you want a value, you must use vbValue and for a atomreference you must use vbAtom.

For the concat part, the are still some things missing. As I said before, I do not know where you use this piece of code, but what is 'i' used for? Probably it is a number relating to a rownumber. You also must give a reference to the table you want to search in. I suggest you try to something similar to the following:

Code: Select all

var([strHelp], vbString)

strHelp := (Concat([Magazine_], Cell(1, 4, refTable, 2)))

trace(strHelp)
This should return the string ''Magazine_Amsterdam'' in your tracer window. If you understand these principles, hopefully you should be able to get your model working. If you have further questions, please ask and try also to use the help (F1), as a lot of syntax is described.

Kind regards,
Menno
Roma
Posts: 6
Joined: Monday 08 July, 2013 - 10:54

Re: Variable Table Name

Post by Roma »

Hello Menno,

Thank you for your response! But I see I wasn't completly clear in my question.

So I attached (a smaller version) of my model in the attachment and hope it makes the problem more clear.

In short: I would like to fill a cell in the table named Magazine_Amsterdam by a reference to the stringvariable strhelp (which is: "Magazine_Amsterdam"). But the attachments makes it more clear.

The line of code is on the entry trigger in the first server.

I'm looking forward to your response!

Thanks in advance,
RoMa
Attachments
MagazijnAmsterdam.mod
(14 KiB) Downloaded 328 times
menno
Posts: 45
Joined: Tuesday 29 March, 2011 - 16:01

Re: Variable Table Name

Post by menno »

Hello Roma,

Try the following:
Instead of using the function 'Magazine Amsterdam' (this is a function!) try to use the reference to the table, which is also automatically build by the table atom. This reference is called 'ref' plus table name. So in your case refMagazine_Amsterdam.
After you've built the right string, then you also should execute the string, otherwise ED will think it is just a string!

So your code will look like this:

Code: Select all

Do(

Var([Locatie],vbString),

Locatie:= Concat([Magazine],[_],[Amsterdam]),

SetCell(2, 2, [Probeer], Execstring(Concat([ref], Locatie)))

)
Hopefully this will help!

Kind regards,
Menno
Roma
Posts: 6
Joined: Monday 08 July, 2013 - 10:54

Re: Variable Table Name

Post by Roma »

Ha Menno,

Thank you very much!

This is exactly what I was looking for,
I did not knew the ExecString command and did not search well enough in the ED help source. But now all works fine.

Thanks,
Roma
Post Reply