Dynamic Char Array for RecipeQueryGetData

Dynamic Char Array for RecipeQueryGetData https://forum.weintekusa.com/uploads/db0776/original/2X/b/b1e82b0a5c994806f1120cb17bc6629a47520fcd.png
none 0.0 0
  • HMI Model: cMT3162x
  • EasyBuilder Pro Version: 6.08.02.449
  • Serial Number or supplier: Not Available

this works
result = RecipeQuery(“SELECT * FROM positions WHERE RecipNo ==%(recipeSelected)”, total_rows)

No variation of this will work, what am I missing?
I get an error that tag does not exist. So I would rem out the line to make it compile and see the char array.
success = RecipeQueryGetData(xRecVal[x], “%(query[0])”, row_number)

This works
success= RecipeQueryGetData(yRecVal[x], “positions.pos01”, row_number)
I am not able to successfully get data using char array

Hi @cncgeorge,

If possible, I would recommend that you use a GetData() function to retrieve the current parameters at the selected index. Here is an example:


Can you please try this alternative solution and advise if it resolves the issue?

1 Like

Note: The RecipeQuery() function is more appropriate for searching a large db. When the item index is the “selected” item, you should use GetData() instead. It is not possible to search where the index is equal to the selected index, because the selected index is not a field within the database that can be queried.

1 Like

Brendon,
Thank you will give it a go, just limits the dynamic nature. Now I have to hard code limits. But will adapt. Thank you and look forward to updating you.
George

Is the RecipeQueryGetData() char array broken as defined in the documentation? The proposed work around requires a lot more macro code to be developed. Is this on a bug report? How bugs tracked?

Brendon,
Hard coding the get data does work. Just not ideal for my situation. I need to read 3 groups of 72 positions. Any way I can read in all of the of one recipe entry in one go?
Regards,
George

@cncgeorge,

As a simple workaround, I would recommend the following solution:

  1. Enable “Bulk Transfer” to send recipe data to a local HMI address within the “Transfer” tab of the recipe database:

  2. Then, configure a macro to read from the address specified wihtin the bulk transfer. Here is an example:

macro_command main()
	short transfer = 5 // Recipe transfer command
	unsigned short sPos[6] = {0, 0, 0, 0, 0, 0} // The data type used in the recipe database is 16-bit Unsigned
	short result = 0
	
	SetData(transfer, "Local HMI", RECIPE, "positions.Command") // Transfer recipe data to an LW memory
	GetData(result, "Local HMI", RECIPE, "positions.Result") // Check if the command is finished
	
	while result == 0 // Wait for command execution to finish
		DELAY(20)
		GetData(result, "Local HMI", RECIPE, "positions.Result")
	wend
	
	if result == 1 then // Execution success
		GetData(sPos[0], "Local HMI", LW, 0, 6) // Retrieve postion data as an array
		result = 0
		SetData(result, "Local HMI", RECIPE, "positions.Result") // Reset result
	else
		// Command failed
	end if
end macro_command
1 Like

@cncgeorge,

My sincere apologies, this is a typo that will be addressed in the next revision of this document. Currently, the “RecipeQueryGetData()” command only works with a static string.

Brendon,
This looks like a better way to solve what I am trying to accomplish. Thank you!! going to test this now. I will report back.
Cheers!
George

@cncgeorge,

The “Macro Reference Guide” was revised, here is a link to a post that contains the latest release: Link

Brendon, Your work around was better than my initial approach. Thank you for the updated link to the Macro Reference Manual and I will mark this solved.
George