Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2003
    Posts
    8

    Wink Unanswered: Automatic Date Insertion for FOXPRO 2.5

    I have the user entering the date (ex 03/15/03) and I want the program to automatically add 180 days to the date and display that in one of the fields...

    Can anyone help me out...


    Thanks

  2. #2
    Join Date
    Dec 2003
    Posts
    104
    In the valid snippet or function of the text box you are entering the date into, put code something like this:
    add180()

    Then in your procedure file, or in the cleanup/procedures of the screen file, put this code:

    FUNCTION add180
    REPLACE somefield WITH m.dDateVar + 180 &&... if memvar for @...GET
    *... -or-
    REPLACE somefield WITH MyTable.dDateVar + 180 &&... if table field

    RETURN .T.

    You can do direct numerica calcs with the DATE() function. In these examples, ?DATE() + 180 or ?DATE() - 30, the date will be incremented 180 days or decremented by 30 days.
    DSummZZZ

    Even more Fox stuff at
    www.davesummers.net/foxprolinks.htm

  3. #3
    Join Date
    Dec 2003
    Posts
    8
    tried doing everything that you replied with and I guess I am just doing it incorrect..

    I am going to be upgrading to Visual Fox Pro soon and I guess I can just wait and add this function at a later time...

  4. #4
    Join Date
    Dec 2003
    Posts
    104
    Let me elaborate on something here:
    REPLACE somefield WITH m.dDateVar + 180 &&... if memvar for @...GET

    Will replace a field in a table. If you are just displaying that value, you would nee to redraw the SAY/GET and refresh it:

    m.dDateVar = m.dDateEntered + 180
    SHOW GETS

    Tell me a little more what you are doing and I'm sure we can get it straightened out.
    DSummZZZ

    Even more Fox stuff at
    www.davesummers.net/foxprolinks.htm

  5. #5
    Join Date
    Dec 2003
    Posts
    104
    After reviewing your code, do the following:

    Replace this statement:
    @ 12,20 GET m.purchase ;
    SIZE 1,8 ;
    DEFAULT { / / }

    with this one:
    @ 12,20 GET m.purchase ;
    SIZE 1,8 ;
    DEFAULT { / / } ;
    VALID add180()

    Then add this function at the end of your .prg:
    *...... Add 180 days to warranty date ......*
    FUNCTION add180
    m.warranty = m.purchase + 180
    SHOW GET m.warranty
    RETURN .T.

    Here is a little test routine you can cut and paste to exactly what it supposed to happen. Copy everything between the row of *'s and paste into a single .prg:
    **********************************************
    STORE DATE() TO d1, d2

    @ 10, 1 GET d1 VALID add180()
    @ 11, 1 GET d2
    @ 13,1 GET m.choice ;
    PICTURE "@*HT \<Save;\<Cancel" ;
    DEFAULT 1

    READ CYCLE


    FUNCTION add180
    d2 = d1 + 180
    SHOW GET d2
    RETURN .T.
    **********************************************
    DSummZZZ

    Even more Fox stuff at
    www.davesummers.net/foxprolinks.htm

  6. #6
    Join Date
    Dec 2003
    Posts
    8
    This is weird.. The little snipet that i did worked fine but when I go and replace the parts of my prg file.. I get the following error

    Operator/operand type mismatch


    I just looked at it alittle for I am running out the door but I will look alittle more when I get back in...


    Thanks for all the help

  7. #7
    Join Date
    Dec 2003
    Posts
    104
    Chances are m.purchase, m.warranty and/or m.extended have not been initialized, so their values are currently .F.
    At the beginning of your routine, make sure they have a value.

    Something like:
    STORE DATE() TO m.purchase, m.warranty, m.extended
    -or-
    STORE {} TO m.purchase, m.warranty, m.extended
    DSummZZZ

    Even more Fox stuff at
    www.davesummers.net/foxprolinks.htm

  8. #8
    Join Date
    Dec 2003
    Posts
    8
    You are awesom..

    Thank you very much for all your help for everything worked Great..

  9. #9
    Join Date
    Dec 2003
    Posts
    104
    Glad to hear it and, you're welcome.
    DSummZZZ

    Even more Fox stuff at
    www.davesummers.net/foxprolinks.htm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •