String to 4DScript without execution

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
WurED_002
Posts: 1
Joined: Thursday 15 September, 2011 - 17:18

String to 4DScript without execution

Post by WurED_002 »

I made a source producing product atoms which are given an article number by a label:

Code: Select all

sDdb([Art_nr],1,cs)
The label value is here stated as "1" but can have integer values up to infinity (the article numbers).

If a product atom with a certain article number enters a certain queue, I want to register this by increasing a global value with 1. This global value was declared as:

Code: Select all

Repeat(ADOTableCountRecords,Dim(Concat([cArt_],ValueToString(Count)),vbValue,0))
This actually works fine, the global variables are declared well. There is the right amount of global variables created (cArt_1, cArt_2, cArt_3, cArt_x) as there are articles in my database (ADOTableCountRecords).

So if an article with a certain article number (which is given in label [Art_nr]) enters a certain queue, I want to increase the value of global variable cArt_x with 1. I tried to do this as follows:

Code: Select all

Inc(ExecString(Concat(c[Art_],ValueToString(Ddb([Art_nr],i,1)))))
This ain't working while I get the error "Cannot increment this variable". Although, when only the following code is executed via 4DScriptInteract:

Code: Select all

ExecString(Concat([cArt_],ValueToString(Ddb([Art_nr],i,1))))
There is given the right value of "cArt". I tried this by changing the standard value when cArt_x was defined. It seems for me that the problem is that I am able to get a global value but while it is executed it cannot be incremented.

Any idea how I can get the global variable without executing (giving the value of the variable) so I can register entered products with a certain article number well?
SimonvdW
Posts: 47
Joined: Thursday 06 January, 2011 - 09:52

Re: String to 4DScript without execution

Post by SimonvdW »

It is indeed not possible to use an ExecString command as a parameter in a function like Inc(), as it produces a String while the function requires variable. Result: no valid variable to increase.

A solution including the use of composed global variables is not available.

An optional solution is using a table to store the amount of entering products per article number, instead of all these global variables. A table is very flexible, easy to access (alias functions) and you can store the amount per article number easlily, for example by using the article number (the label value) as row number.

And you know the size of the output table on forehand, as it is the same as the number of records in the ADOTable you use.
Post Reply