Charmed Quark Systems, Ltd. - Support Forums and Community

Full Version: Error writing value to field
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is my first trigger attempting to set a value of a field to a value from another field & I get the error "Cannot convert the passed value to a form legal for field <target field>."

I am attempting to take the value from OpenWeather ( WEATH#curTemp [Type: MEng.Int4]) and write it to the outside temp of my RCS serial thermostats (Main_OutsideTempStat [type: MEng.INT4]).


I am able to type a value in the driver directly & have it write to the thermostat correctly, but I cannot get the action of the trigger to work.  I'm really new to CQC, but is there some form of typecasting that I need to do?

Thanks
(05-26-2021, 05:04 PM)Spot Wrote: [ -> ]This is my first trigger attempting to set a value of a field to a value from another field & I get the error "Cannot convert the passed value to a form legal for field <target field>."

I am attempting to take the value from OpenWeather ( WEATH#curTemp [Type: MEng.Int4]) and write it to the outside temp of my RCS serial thermostats (Main_OutsideTempStat [type: MEng.INT4]).


I am able to type a value in the driver directly & have it write to the thermostat correctly, but I cannot get the action of the trigger to work.  I'm really new to CQC, but is there some form of typecasting that I need to do?

Thanks
What is the trigger?  Is it any field change for a value from WEATH#curTemp?

Can you provide the actual FieldWrite command you have in the trigger?  Just want to make sure you are taking the value from the curTemp and not the text of the name.  For example, you should be passing the value from the openweather field to the RCS, and it requires the $() to pass a value.

Devices::FieldWrite
    P1= Thermo.OutsideTempStat
    P2=$(OpenWeather.WEATH#curTemp)
    P3=False
(05-26-2021, 11:15 PM)kblagron Wrote: [ -> ]
(05-26-2021, 05:04 PM)Spot Wrote: [ -> ]This is my first trigger attempting to set a value of a field to a value from another field & I get the error "Cannot convert the passed value to a form legal for field <target field>."

I am attempting to take the value from OpenWeather ( WEATH#curTemp [Type: MEng.Int4]) and write it to the outside temp of my RCS serial thermostats (Main_OutsideTempStat [type: MEng.INT4]).


I am able to type a value in the driver directly & have it write to the thermostat correctly, but I cannot get the action of the trigger to work.  I'm really new to CQC, but is there some form of typecasting that I need to do?

Thanks
What is the trigger?  Is it any field change for a value from WEATH#curTemp?

Can you provide the actual FieldWrite command you have in the trigger?  Just want to make sure you are taking the value from the curTemp and not the text of the name.  For example, you should be passing the value from the openweather field to the RCS, and it requires the $() to pass a value.

Devices::FieldWrite
    P1= Thermo.OutsideTempStat
    P2=$(OpenWeather.WEATH#curTemp)
    P3=False
Nothing was added on your last post, so hope you got it figured out. With this forum, sometimes it's better to not use the "reply" where it quotes everything, as it can get quite confusing if it is a long quote.
(05-27-2021, 10:42 PM)kblagron Wrote: [ -> ]Nothing was added on your last post, so hope you got it figured out.  With this forum, sometimes it's better to not use the "reply" where it quotes everything, as it can get quite confusing if it is a long quote.

My apologies, I saw that my response had posted, but I failed to ensure that my message content was there...

Your solution worked perfectly.  Using the $([fieldname]) put the correct value into the field and it has been working without issue.  

That wasn't exactly the behavior I expected, but I'm wondering if I missed something in my perusal of the documentation.  

Thanks
The $(driver.field) syntax works in any action parameters. But you can also use the Devices::ReadField and Devices::ReadField2 action commands to read the values into a variable. The latter can be useful for a couple reasons. One is that you don't have to read it multiple times if you need to use it multiple times. And the other is that those action commands can be fault tolerant, i.e. you can react to not being able to read the field and do something, whereas the $(x) form will always cause the action to fail if the field value is not available.

This section of the help on token replacement covers the details:

https://www.charmedquark.com/Web2/CQCDoc...eplacement
Dean,

Thanks for the information and the link.  I am sure as I progress, it will become intuitive, but for now it really helps to have the support of the forum.