Hi @Jose_Fonseca2,
There are two sections within that post, the first is labeled simple as it is the easiest way to implement searching. However, the “simple” method is not suitable for your application. Instead, you should review the instructions related to the “advanced” method shown here: Link
By using this method you can:
- Use a
GetDatafunction to read a pin typed by the user. - Use a recipe query statement to compare it to pins within the database
- Find the related pin and get the value of gallons in the same row
- Use a
SetDatato transfer the value in gallons to the CODEYS program
Here is some example code:
macro_command main()
char sql[100] = "SELECT * FROM Recipe1 WHERE pin = "
char cPin[4] = {0,0,0,0}
short sPin = 0
// Get pin data
GetData(sPin, "Local HMI", LW, 0, 1)
DEC2ASCII(sPin, cPin[0], 4)
// Form query
StringCat(cPin[0], sql[0])
short n_records = 0
RecipeQuery(sql[0], n_records)
if n_records > 0 then
short recordID = 0, i = 0
short gallons = 0
for i = 0 to n_records
RecipeQueryGetRecordID(recordID, i)
RecipeGetData(gallons[0], "Recipe1.gallons", recordID)
SetData(gallons, "CODESYS V3 (Ethernet)", "PRG.gallons", 1)
next
end if
end macro_command