Does anyone know the correct MySQL data format to allow me to use the Named Query result as a controller for the Vision checkbox? I tried BIT(1), TINYINT but no luck?
I don't, but I can see that the Default/Expression is '1' which is a string.
SQL syntax, surely, would be TRUE
or 1
?
Do I see more apostrophes on the next columns default as well?
I use TINYINT(1) which i believe is what BIT(1) is an alias for.
DEFAULT 'TRUE'
is also a string.
Try DEFAULT TRUE
.
'TRUE'
is a string. TRUE
is a boolean.
I got it to work by doing the TINYINT and setting default to = 1
I noticed once I write this change to the database, it will go back and reset that 1 to equal '1'. Seems like it doesn't mind in this case.
I got the checkbox to be happy querying this type. But, when reading back the checkbox value, it will convert 1 = 'TRUE', 0 = 'FALSE', which is a problem when reading the checkbox value and updating the database.
I figured this script would do it:
But, it considers 'etchingenable' as undefined if I put that into the parameters string. What would be the correct way to format that change?
Please see Wiki - how to post code on this forum so that someone can copy it and edit.
Is etchingenable
a string? You're assigning a string variable to it.
Here's the script:
recipe_selected = system.tag.readBlocking('[default]Internal/ActiveHeatRecipe')[0].value
readetching = event.source.parent.getComponent('Etching Parameters').getComponent('Enable Field').selected
if readetching == 'False':
etchingenable = '0'
if readetching == 'True':
etchingenable = '1'
etchingpressure = event.source.parent.getComponent('Etching Parameters').getComponent('Starting Pressure Field').text
etchingvoltage = event.source.parent.getComponent('Etching Parameters').getComponent('Discharge Voltage Field').text
etchingmins = event.source.parent.getComponent('Etching Parameters').getComponent('Etching Mins Field').text
etchingsecs = event.source.parent.getComponent('Etching Parameters').getComponent('Etching Secs Field').text
preprocesspeed = event.source.parent.getComponent('Rotation Parameters').getComponent('Preprocess Speed Field').text
processspeed = event.source.parent.getComponent('Rotation Parameters').getComponent('Process Speed Field').text
heaterpressure = event.source.parent.getComponent('Heat Parameters').getComponent('Pressure Field').text
ventenable = event.source.parent.getComponent('Vent Parameters').getComponent('Auto Vent Field').selected
venthours = event.source.parent.getComponent('Vent Parameters').getComponent('Delay Hours Field').text
ventmins = event.source.parent.getComponent('Vent Parameters').getComponent('Delay Mins Field').text
depositionpressure = event.source.parent.getComponent('Process Parameters').getComponent('Starting Pressure Field').text
parameters = {'recipe_selected' : recipe_selected, 'etchingEnable' : txetching, 'etchingPressure' : etchingpressure, 'etchingVoltage' : etchingvoltage, 'etchingMins' : etchingmins, 'etchingSecs' : etchingsecs, 'processSpeed' : processspeed, 'heaterPressure' : heaterpressure, 'ventEnable' : ventenable, 'ventHours' : venthours, 'depositionPressure' : depositionpressure}
system.db.runNamedQuery('PROCESS NQ/PARAMETERS/SAVE PARAMETERS', parameters)
There shouldn't be any issues with writing a Boolean back to the database. You cannot write a string back, why type is your parameter that is writing back to the database?
Also i dont see where you have defined "txetching" 'etchingEnable' : txetching
txetching should read etchingenable, almost certainly
Sorry, I deleted txetching = etchingenable line because it was throwing an error. Issue is etchingenabled goes undefined with these if statements
You didn't address my earlier comments about is etchingenable
a string?
if readetching == 'False': # <--- You're checking for a string, not a bool.
etchingenable = '0' # <--- You're writing a string.
if readetching == 'True': # <--- You're checking for a string, not a bool.
etchingenable = '1' # <--- You're writing a string.
Take care with your writing. The variable name is etchingenable
.
Yes etchingenable was a string in the NQ, which was throwing the whole thing off. I am able to ignore this whole set of if statements and just use readBlocking on the checkbox. Everything is happy with that. Thanks you!