locked
"When" firing after "Valid" RRS feed

  • Question

  • Hi all;

    I am temporarily using an older SPR in VFP 9 as it is. I have had some problems with the code, and after using the debugger I have learned that in a "Get, when, valid" command, the "When" fires AFTER the "Valid".

    Anyone had experienced a simillar probem? Any ideas why?

    Thanks,
    Aleniko
    Thursday, August 3, 2006 11:47 AM

Answers

  • I'm not sure whether this is relevant to your situation or not, but I found this paragraph in our explanation of When and Valid in the Hacker's Guide:

    Second, the When for some controls fires more than once when you use the control. When you use a button (command or option), check box, or combo, if focus will still be on that control afterwards, the When fires following the Valid. If you click on the control, you get the following sequence: When, GotFocus, Valid, When.

    Tamar
    Monday, August 7, 2006 8:46 PM
    Answerer

All replies

  • When fires before the next control receives the focus. So when you are leaving a control, and the focus is going to the next one in the sequence (in a form or container for example), the next control's When fires.

    See:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_foxhelp9/html/a06d2f38-2e33-4e77-bca2-c71d99bb6af9.asp?frame=true

    http://fox.wikis.com/wc.dll?Wiki~FocusFocusWhosGotTheFocus

     

    Thursday, August 3, 2006 12:12 PM
  • Alex;

    I'm obviously refering to the "when" of the control firing AFTER the "valid" of the same control.

    Aleniko
    Thursday, August 3, 2006 3:06 PM
  • Oh. I misunderstood then.

    Are you taking about the very old @..GET command?

    If that is the case, I don't even remember the sequence as I have not used an @..GET in over 14 years!

    Maybe somebody can chime in.

     

    Why are you using @..GET in VFP code? Don't!

    Thursday, August 3, 2006 3:41 PM
  • I found the problem.

    There is no problem using @ gets in VFP code. It works fine. The reason I use it is because temporarily I need to use old code in VFP until we do conversion.

    The problem was caused by the way SPR files are generated in the OLD foxpro versions. In some cases the WHEN function had no 'return' at the end of the function. So, in FP the code would work fine but under VFP it would go crazy.

    Thanks for your attention,

    Aleniko
    Thursday, August 3, 2006 4:59 PM
  • Aleniko,

    Now you confused me:) Why would it go crazy in VFP if there is no 'return' at the end? What has changed from FP to VFP for that matter?

    Friday, August 4, 2006 9:23 AM
  • Cetin;

    Correction. Problem still there but I think it is caused by the get command. Run this code in VFP9 and in Foxpro2.6 (If you still got one...) and see how the 'When' clause runs again after the valid in VFP9. This causes the final value to be different when run in VFP9.
    I have simplified the original code to the code bellow. Thanks for your input.

    SET TALK off
    clear
    STORE "Screen" TO m.whereto
    @ 2,3 GET m.whereto ;
        PICTURE "@*HN \<Screen;\<Printer" ;
        WHEN _16r0knd6u() ;
        VALID _16r0knd6v()
    READ

    store left(m.whereto,1) to mret
    WAIT "Final result "+m.whereto wind
    return mret   


    * When
    FUNCTION _16r0knd6u
    WAIT "In when" wind
    store "Screen" to m.whereto
    return

    * Valid
    FUNCTION _16r0knd6v
    WAIT "In valid" wind
    CLEAR read
    return .T.

    Saturday, August 5, 2006 12:36 PM
  • I'm not sure whether this is relevant to your situation or not, but I found this paragraph in our explanation of When and Valid in the Hacker's Guide:

    Second, the When for some controls fires more than once when you use the control. When you use a button (command or option), check box, or combo, if focus will still be on that control afterwards, the When fires following the Valid. If you click on the control, you get the following sequence: When, GotFocus, Valid, When.

    Tamar
    Monday, August 7, 2006 8:46 PM
    Answerer
  • Tamar;

    Exactly the case. Not sure if its by design...

    Aleniko.
    Tuesday, August 8, 2006 1:14 AM