sorry that nobody has responded.. I don't have time for a detailed reply right now, but two things
1. never use Edit Mode, always use CoEdit Mode
2. if I understand your situation, I would Scan the data table, and for each record Locate the lookup record you need, to get the extra field to pass back to the data table
-- Steven Green Myrtle Beach, South Carolina USA http://www.OasisTradingPost.com Collectibles and Memorabilia Vintage Lego Sets and Parts - and Paradox support, too
--
You received this message because you are subscribed to the Google Groups "TheDBCommunity" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thedbcommunit...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/thedbcommunity/aa124e93-bcd8-47e4-b792-2d870e6f5b41n%40googlegroups.com.
Thanks for your answer.
I'm not entirely sure I’ve grasped the full procedure, so let me try to summarize:
1. MOVETO to select FOREX as the active image:
If I understood correctly, since both tables are opened via VIEW and COEDIT, we can switch between them during the SCAN using MOVETO.
2. FOREX table has the following structure:
CURRENCY *(With the first three fields marked as keys)
So, for each record in ITEMS, we want to look up the matching RATE using those three keys.
3. Lookup values are stored in temp vars:
Let’s say we store CURRENCY, FXYEAR, and FXMONTH into temporary variables like TEMP_CURRENCY, TEMP_FXYEAR, TEMP_FXMONTH.
What I'm still unsure about is:
→ How do I use LOCATE inside the SCAN to extract RATE from FOREX using those keys?
I’ve looked through the PAL 4.0 reference manual, but I’m still not quite sure how this would be done in practice. I’m sure it’s something basic, but PAL predates the internet — and unfortunately, examples or working snippets are nearly impossible to find nowadays
---
I ended up using a different approach based on queries:
I created a QUERY joining ITEMS and FOREX on the key fields. ITEMS contain all fields, both the source ones and the calculated or lookup.
Since RATE exists in both tables, the one from FOREX is automatically renamed to RATE-1 in ANSWER table generated by the query.
In a SCAN over the resulting ANSWER, I copied [RATE-1] into [RATE], and performed all the calculations (e.g. VALUECHF = VALUE * RATE, etc.).
Then I made a new QUERY over ANSWER selecting all fields. This automatically discards RATE-1 (which is no longer needed).
I emptied the ITEMS table.
I appended all records from ANSWER into ITEMS.
This works reliably and is easy to follow. But I'm still very curious how the above MOVETO + LOCATE approach would be written idiomatically in PAL — any example particlarly for the LOCATE sentence would be still appreciated.