Troubleshooting
Why RecipeGetData fails and GetData finds a Weintek recipe by name
Short answer
RecipeGetData reads only the currently selected record, so it cannot walk a Weintek recipe database by index. The working search macro steps RECIPE/Selection from 0 to Count minus 1, reads each record's name field with GetData, and saves the selection whose name equals the operator's text — all inside the HMI, before any recipe transfer.

On this page
- Why does RecipeGetData return one name but no way to index the records?
- How does stepping RECIPE/Selection expose every record?
- What does the working search macro look like?
- Why does the scan still return or select the wrong record?
- How do you verify the match before the recipe transfer?
- Does the search itself touch the PLC or the network?
- Which lookup do you use for which case?
- Questions asked
The operator types a product name, and the recipe database has no name index to answer with. The working search on a Weintek panel is a macro loop: read the record count, write each record number in turn to RECIPE/Selection, read that record's name field with GetData, and keep the selection whose name equals the typed text. In the reported case — an 8071iE project storing each product name as a 10-word ASCII field — RecipeGetData returned one record's name and no way to step to the next; swapping that call for GetData after the Selection write is what made the search run. Everything below happens inside the HMI; the PLC is involved only in the later recipe transfer.
Why does RecipeGetData return one name but no way to index the records? #
RecipeGetData reads the field of whichever record is currently selected and takes no record number, so a macro cannot use it to walk the table; in the reported 8071iE project, replacing it with GetData after writing the record selector made the scan work. That is one project's reported behavior rather than a published specification, but it matches the shape of the call: one read, of the current record, with no index argument anywhere. A loop that calls it repeatedly reads the same record repeatedly — the name comes back, but nothing moves to the next one.
The recipe database itself gives a macro everything the lookup needs, addressed on the RECIPE device. With Ricetta_modelli5 as the example database name from the reported project (your database carries whatever name it was built with):
Ricetta_modelli5.Count— how many records are stored; read it once before scanning.Ricetta_modelli5.Selection— the number of the record currently exposed; write it to move to another record.Ricetta_modelli5.Nome_modello— the name field of the exposed record; read it after each move.
Count reports the records actually stored, not the database's design capacity — the record and word capacities are tabulated in Weintek recipe database record and word limits explained.
How does stepping RECIPE/Selection expose every record? #
Each value written to the database's Selection entry selects one record, and the GetData that follows returns that record's name field; looping the selector from 0 to Count minus 1 visits every record exactly once. The exchange is strictly write-then-read, and the order is not optional — selection first, name second, every pass:
- Write the pass number into the Selection entry.
- Read the name field; it now belongs to that record.
- Compare it with the operator's key; on equality, copy the name and the number out.
- Increment and repeat through the last valid selection.
The addresses the reported project wired up:
| Role | Location | Width | Carries |
|---|---|---|---|
| Search key | LW 100 | 10 words | The name the operator typed |
| Record count | Ricetta_modelli5.Count on RECIPE |
1 word | How many records exist |
| Record selector | Ricetta_modelli5.Selection on RECIPE |
1 word | Which record is exposed |
| Name field | Ricetta_modelli5.Nome_modello on RECIPE |
10 words | The exposed record's name |
| Matched name | LW 20 | 10 words | Copy of the hit |
| Matched number | LW 30 | 1 word | The selection to reapply later |
| Status | LB 10, LB 11, LB 12 | 1 bit each | Found, failed, scan running |
The result words and status bits are ordinary local memory, so screens can display the running, found and failed states while the loop works.
What does the working search macro look like? #
The macro reads Count, reads the operator's 10-word key from LW 100, then for each selection writes the selector, reads the name field, and copies a hit to LW 20 with its number to LW 30. In the listing, GetData, SetData, the RECIPE device, LW and LB are the runtime names the EasyBuilder Pro macro interpreter expects; var_input, var_confr, selection, count, last, result_number, ok, fail and Compl are this example's own variables, each declared with its type and initial value at the top.
macro_command main()
short var_input[10], var_confr[10]
short selection = 0
short result_number = 0
int count = 0
int last = 0
bool ok = 0, fail = 1, Compl = 0
GetData(count, "Local HMI", RECIPE, "Ricetta_modelli5.Count")
last = count - 1
GetData(var_input[0], "Local HMI", LW, 100, 10)
SetData(ok, "Local HMI", LB, 10, 1)
SetData(fail, "Local HMI", LB, 11, 1)
Compl = 1
SetData(Compl, "Local HMI", LB, 12, 1)
for selection = 0 to last step 1
SetData(selection, "Local HMI", RECIPE, "Ricetta_modelli5.Selection")
GetData(var_confr[0], "Local HMI", RECIPE, "Ricetta_modelli5.Nome_modello")
if var_input[0] == var_confr[0] and var_input[1] == var_confr[1] and
var_input[2] == var_confr[2] and var_input[3] == var_confr[3] and
var_input[4] == var_confr[4] and var_input[5] == var_confr[5] and
var_input[6] == var_confr[6] and var_input[7] == var_confr[7] and
var_input[8] == var_confr[8] and var_input[9] == var_confr[9] then
SetData(var_confr[0], "Local HMI", LW, 20, 10)
result_number = selection
SetData(result_number, "Local HMI", LW, 30, 1)
ok = 1
fail = 0
SetData(ok, "Local HMI", LB, 10, 1)
SetData(fail, "Local HMI", LB, 11, 1)
end if
next selection
Compl = 0
SetData(Compl, "Local HMI", LB, 12, 1)
end macro_command
Three deviations from the reported version, all deliberate:
- The condition compares the whole name field, word 0 through word 9; the reported condition compared words 0 through 4 only, a prefix match over half the field.
- The upper bound is computed as one below the record count before the loop, so the scan cannot select a record that does not exist.
- The scan does not stop at a hit; it finishes and leaves the hit's number in the saved word, expecting the caller to reapply it before any transfer.
Why does the scan still return or select the wrong record? #
Five faults cover the reported failures: a five-word prefix comparison, duplicate names, the selector left on the last record, one loop pass beyond the record count, and unequal padding or letter case between the key and the stored field.
| Symptom | Cause | Correction |
|---|---|---|
| Two different products both match | The condition compares the leading words only | Compare the whole name field for an exact lookup |
| The wrong duplicate wins | Records are filed by number and their contents are never checked, so equal names are legal | Enforce unique names, or guard the copy block so the first hit stands |
| The display shows the right name but another recipe runs | The loop keeps stepping after the hit and leaves the selector on the last record | Reapply the saved number from LW 30 before the transfer |
| The last pass shows a blank or stale name | The loop ran one selection past the record count | End the loop one below the count |
| No match although both texts read identically | The stored field and the key differ in padding or letter case | One case and identical padding on both sides |
Worked example, illustrative: the database stores 12 records, so Count reads 12 and, with selections numbered from 0, the last valid selection is 12 − 1 = 11. The reported loop ran 0 to Count inclusive — 12 + 1 = 13 passes — and its final pass selected record 12, which does not exist, returning a blank or the previous record's name. The corrected bound stops at 11: passes 0 through 11 are 11 − 0 + 1 = 12 passes, exactly one per record.
The compare is numeric equality on character codes, word by word, so texts that look identical on screen can still differ: upper and lower case carry different codes, and trailing spaces differ from the field's unused padding. Keep one case everywhere — store every record name in uppercase with no trailing spaces and have the operator enter the key the same way — and equal text will compare equal.
How do you verify the match before the recipe transfer? #
Verify in this order: watch the selector step once per record while the name changes, confirm the found bit sets and the failed bit clears for a known name, then write the saved selection back and re-read the name before allowing any transfer. On a bench setup with test recipes:
- Enter a name that exists at the key address and trigger the macro; the Selection entry must step once per record and the name field must change at every step.
- Check that the matched name and its number land in their result words, the found bit sets, the failed bit clears, and the running bit drops when the scan ends.
- Search a name that does not exist; the failed bit must stay set and no stale result may be presented as a new one.
- Test the edge records — first record, last record, two names sharing a leading fragment, two identical names — and record which selection each case leaves behind.
- Reapply the saved number to the Selection entry, read the name field back, and compare the full field before the transfer is enabled.
That last comparison is the interlock that matters: a search that quietly lands on the wrong record would send the machine a complete set of someone else's process values, so gate the transfer on the re-read name, not on the search bits alone.
Check the data the scan actually compares, not just the offline project: the recipe database manual documents the retrieval path — open Utility Manager, choose Upload, select HMI, and tick the Recipe database option — and the names that come back are the ones on the panel. The vendor's demo project library also carries a ready recipe-search macro worth opening beside your own; building skill from worked vendor examples is the approach described in Learning advanced HMI features from demo projects.
Does the search itself touch the PLC or the network? #
No: the whole lookup runs in local HMI memory — the key in local words, the recipe datablock, and the result addresses — so a failed name search is a macro or data problem, and Ethernet or PLC diagnostics only apply once the separate recipe transfer starts. Every GetData and SetData in the loop addresses "Local HMI" and nothing else; no controller, port or cable participates. Diagnose in that order: confirm the key words and the stepping first, the comparison logic second, and leave communication troubleshooting for the transfer step, where a controller is finally addressed.
Which lookup do you use for which case? #
Use a direct read when the record number is already known and no search is needed; use the Selection-stepping macro for any name lookup; add a uniqueness rule before shipping a single-result search; and choose a prefix compare only when several hits are acceptable.
| Case | Lookup | Why |
|---|---|---|
| Record number known | Read the field directly | No scan, no compare |
| Name lookup, unique names | The macro above with the full-field compare | Exactly one possible hit |
| Duplicate names possible | Uniqueness rule first, or present every hit | A single-result scan over duplicates keeps whichever duplicate it meets last |
| Partial-name search wanted | Deliberate leading-words compare | Several candidates by design |
For the case that started this — many product names, an operator who types one — the answer is the macro above: full-field compare, unique names, and the saved selection reapplied and re-read before anything reaches the controller.
Questions asked
Can two recipe records carry the same product name?
Yes. Records are filed by number and their field contents are never checked, so identical names are legal. The scan keeps running after a hit, so with duplicates the result words end on whichever matching record the loop met last. Enforce unique names when recipes are written, or guard the copy block so it runs only while the found bit is still off and the first hit stands.
How different are uppercase and lowercase letters to the comparison?
Entirely different. The compare runs word by word on numeric character codes, and in ASCII the same letter sits 32 codes apart between cases — capital A is 65, lowercase a is 97 — so a name stored in one case and typed in the other fails on every word that holds a letter. Store and type in a single case and the problem disappears.
Is RecipeGetData defective?
No defect is documented here. In the reported project it behaved as a read of the currently selected record's data, with no argument for a record number — unusable for walking a table, but fine for reading a record already selected. The indexing problem disappears when GetData follows a write to the Selection entry, so nothing is lost by dropping it from the search.
Can the operator trigger a recipe transfer while the scan is running?
Block that combination. Mid-scan the Selection entry points at whatever record the loop is passing, so a transfer started then pushes the wrong record's values to the controller. Enable the transfer only after the running bit drops and the saved selection has been reapplied and re-read, and disable the search trigger again while a transfer is active.

