Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Logic Conumdrum - Volunteers?
Message
From
08/03/2006 15:24:40
 
 
To
08/03/2006 14:25:38
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01102577
Message ID:
01102600
Views:
16
This message has been marked as the solution to the initial question of the thread.
>Given:
>
>If a record exists with und_owner = 1, then it is a guideline for all. Those values are used UNLESS a record exists for the specific agent. Any record for specific agent will override the setting in the record with the und_owner = 1.
>
>
>ag_account = 5608  && und_owner=5608 will be agent specific settings
>ag_pmtnb6 = 5
>ag_maxnb6 = 5
>
>SCAN WHILE NOT EOF()
>   IF UNDGUIDE.UND_EFF <= DATE() AND ( UNDGUIDE.UND_OWNER = 1 OR UNDGUIDE.UND_OWNER = m.ag_account)
>      CASE UNDGUIDE.UGI_ID = UGI_MAX6PMT
>         IF BETWEEN(UNDGUIDE.UND_VALUE,1,6)
>            m.ag_maxnb6 = UNDGUIDE.UND_VALUE  <--und_value = 4 in the record for und_owner = 1
>            m.ag_maxrn6 = UNDGUIDE.UND_VALUE
>            *--Here ag_pmtnb6 is changed to 4 because ag_maxnb6 is now 4
>            IF m.ag_pmtnb6 > m.ag_maxnb6
>              m.ag_pmtnb6 = m.ag_maxnb6
>            ENDIF
>         ENDIF
>
>*Now based on the record with und_owner = 1 above the two values below have been changed:
>
>*ag_pmtnb6 = 4
>*ag_maxnb6 = 4
>
>*Next the record und_owner = 5608 is found which does not change the ag_pmtnb6 back
>
>CASE UNDGUIDE.UGI_ID = UGI_MAX6PMT
>IF BETWEEN(UNDGUIDE.UND_VALUE,1,6)
>    m.ag_maxnb6 = UNDGUIDE.UND_VALUE <--und_value = 5 in the record for und_owner=5608
>    m.ag_maxrn6 = UNDGUIDE.UND_VALUE
>    IF m.ag_pmtnb6 > m.ag_maxnb6    <<<<----Here ag_pmtnb6 is not changed because it is now 4 and 4 < 5
>        m.ag_pmtnb6 = m.ag_maxnb6
>    ENDIF
>ENDIF
>
>This obviously is not working. A value of ag_pmtnb6 should be 5 not 4 when the code finished because we set it to 5 before the code is run and the record for und_owner=5608 with the ag_maxnb6 value allows for 5 as the max value for 5608.
>When the code hits the record for und_owner=1 it sets ag_pmtnb6 to 4. Then it hits the record specific for the agent und_owner=5608 but only the allowed max value is changed and the modified value is under it so it is not changed. The logic is all wrong. ideas?
>The rule is, if no records exist for that guideline for und_owner=ag_account (specific agent), then use the record with und_owner=1(default for all agents). If no record exists for und_owner=ag_account or und_owner=1, then don't change the value. There are probably 50 values to check.

I think I've cramped my brain trying to follow your variable names ;) Might it help if you reversed your logic as follows (pseudocode):
IF Agent_Record_Exists
  * Use Agent values

ELSE
  * Use Owner values

ENDIF
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform