garias
8th October 2008, 21:00
Hi
As you know, when we are programming constraints in Package ti Manufacture module: PCF, we can recover the value of some feature putting the name of the feature between brackets, by example:
!if [color] = "blue" then
! message("Option: %s ",[color])
! validating = true
!else
! validating = false
!endiif
Question:
if I have the name of the same feature in a variable by example:
!option = "color"
How can I do to use this variable option, which has "color", to recover the value of the feature "color"
By example, the actual value of this feature color is "blue".
I tried to put:
a) directly [option]
! option = "color"
! message ("Option: %s", [option])
Result Option: (empty)
b)
! message ("Option: %s, chr$(91)&option&chr$(93))
Result Option: [color] (But don´t revover the value of feature color)
c)
! pointer = expr.compile(quoted.string(
! chr$(91)strip$(option)&chr$(93)))
! value = s.expr$(pointer)
! message ("Value: %s", value)
Result: Option: [color]
Some idea
Regards
Gerard
günther
9th October 2008, 16:18
Hi Gerard,
as I see you are using the PCF in object mode. So you can use all baan programming functions as long as you use the '!' sign.
I'm not really familiar with the PCF, so I made a normal example which you will have to tweak for your needs.
You will see, that get.var(pid, option, result) will be all that you need; pid is the current process id, option is your string that contains the name of the variable (hence no quotes around it!), result is your string that contains the result; option and result must be external.
extern string option(10)
extern string color(10)
extern string weight(10)
extern string result(10)
extern string result2(10)
function TEST()
{
long rc
| the values
color = "red"
weight = "10 tons"
| 1st query
option = "color"
rc = get.var(pid, "option", result)
message("rc=%d result='%s'", rc, result)
rc = get.var(pid, option, result)
message("rc=%d result='%s'", rc, result)
| 2nd query
option = "weight"
rc = get.var(pid, "option", result)
message("rc=%d result='%s'", rc, result)
rc = get.var(pid, option, result)
message("rc=%d result='%s'", rc, result)
}
Günther
garias
9th October 2008, 18:03
Hello Günther:
Thanks for you answer. I tried your clue. But It didn´t work.
That is because in PFC constraint programming, the features that you define (by example color, weight, and so on) are not variables in the programming.
by example:
We have an item with three features: color, weight and size.
After we make a constraint script for one feature and associate it to the feature.
When we pass the feature (when we are configuring the product), if we want to recover the value of some feature we have to put the name of the feature between [], if we put directly color we receive an error, because color is not a declarated variable.
news ideas ?
Regards
Gerard
Hitesh Shah
9th October 2008, 18:11
Hi
c)
! pointer = expr.compile(quoted.string(
! chr$(91)strip$(option)&chr$(93)))
! value = s.expr$(pointer)
! message ("Value: %s", value)
Result: Option: [color]
Some idea
Regards
Gerard
Use one extra expr.compile to parse the value of "value" and pass the returned value (s.expr$(value)) to message function .
Other get.var/ put.var way also should work .
garias
9th October 2008, 19:00
Hello Hitesh
Thanks for you answer.
I tried your idea, but it didn´t work.
Some other ideas ??
Gerard.
steveauckly
9th October 2008, 22:59
Not sure what constraint section you are in, but in the Before Input, you can set the value by simply using the []'s:
[Color] = "blue"
garias
9th October 2008, 23:13
Hello Steve:
The constraints section is validation.
I don´t want to assigned a value a feature.
I want to recover the value of some feature, without putting the feature name between []
I am going to have the name of the feature in a table or in a variable.
Ejem:
tcibd987.cpft = "color" | <---- It is the name of the feature not the value.
option = tcibd987.cpft | <---- I put in a variable because we can´t use directly
| the name of the table field.
if I write in the script [color] then I can recover the value of this feature example "blue"
but
if I write in the script [option] it try to find the feature option no the feature color
Some clue ?
steveauckly
9th October 2008, 23:40
How about this?
!domain tccpva cpva
!domain tcopts opts
!import("tipcf500.cpva",cpva)
!import("tipcf500.opts",opts)
!select tipcf520.copt from tipcf520
!where tipcf520._index1 = {:cpva,:opts}
!and tipcf520.cpft = tcibd987.cpft
!selectdo
! | here you have access to the feature option tipcf520.copt
!endselect
garias
9th October 2008, 23:59
Hello Steve:
It´s a good alternative, I had thought in this option. But, I believed that this maybe has a problem, because when you are passing between features, choosing every option, I supposed that the option selected is not saved into the database (tipcf520) until you press the botton save.
But I tested and every time that you pass from one feature to another feature, the system is saving the value.
Consecuently, It´s a good alternative!!!
Regards and thanks four your time.
I am going to do an extensive test
However, If someone can find other solution. welcome
Gerard