doedit usage

Jose Lerebours fp at fpgroups.com
Tue Oct 7 12:42:53 PDT 2008


Scott Walker wrote:
> I have a sort/select process.
> 
> In an input statement, the user enters a Post Date in pd(8,mdy/)
> 
> If they enter "09/31/08" the edit on pd will not take it.
> 
> If they enter "093108" and press <del> ONE TIME, and then press <Enter>,
> the "093108" is accepted and the processing moves on to the next line.
> 
> Testing for @sk eq "BRKY" does not seem to prevent this since the last
> @sk is really "ENTR".
> 
> So I'm trying to use "doedit" as an extra check of the validity of the
> date entered.
> 
> I tried:
> 
> dt=doedit(pd,"mdy/")
> 
> Then I test to see if dt is blank, as I thought it would be since the
> value of "093108" should not pass the mdy/ edit.
> 
> But the value of dt shows "093108"
> 
> Any suggestions?
> 

Check out this routine, nothing out of this world but a slick way to 
absolutely control date entry.  I just put this together and ran a 
couple of quick tests, it seems to work ... Please test before using if 
you choose to use it!

   1  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
@keym  þ If: 

        Then: zw=""; gosub GETDATE 

   2  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: show "@"&zw 

   3  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: end 

   4  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
GETDATEþ If: 

        Then: show ("22","2") "Enter Date: "&zw&"        " 

   5  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: len(zw) eq "8" or @sk eq "BRKY" 

        Then: goto VALDATE 

   6  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: show ("22","2") "Enter Date: "&zw; zx(1,*)=waitkey 

   7  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: @sk eq "BRKY" 

        Then: zw=""; goto GETDATE 

   8  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: @sk eq "BKSP" and len(zw) eq "1" 

        Then: zw=""; goto GETDATE 

   9  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: @sk eq "BKSP" and len(zw) eq "3" 

        Then: zw=mid(zw,"1","1"); goto GETDATE 

  10  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: @sk eq "BKSP" and len(zw) eq "6" 

        Then: zw=mid(zw,"1","4"); goto GETDATE 

  11  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: @sk eq "BKSP" and len(zw) gt "1" 

        Then: zw=mid(zw,"1",len(zw)-"1"); goto GETDATE 

  12  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: zx eq "/" and zw eq ""   'Accept slash as today's date
        Then: zw=@td; return 

  13  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: not("0123456789" co zx)     'Does not pass the smell test
        Then: goto GETDATE 

  14  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: zw=zw{zx; zv(2,.0)=len(zw)
  15  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: zv lt "2"                   'Do nothing, get one more key
        Then: goto GETDATE
  16  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: zv eq "2"                   'Check and validate month
        Then: goto MTHDATE 

  17  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: zv eq "5"                   'Check and validate day of 
month  þ
        Then: goto DAYDATE 

  18  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: goto GETDATE 

  19  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
MTHDATEþ If: zw eq "00"                  'Cannot have this as a month
        Then: zw=""; goto GETDATE 

  20  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: not("01" co mid(zw,"1","1")) 

        Then: zw="0"{mid(zw,"1","1"){"/"{mid(zw,"2","1"); goto GETDATE 

  21  -------   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: zw=zw{"/"; goto GETDATE 

  22  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
DAYDATEþ If: 

        Then: zv=mid(zw,"4","2") 

  23  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: zy(8,mdy/)=mid(zw,"1","3")&"01/"&mid(@td,"7","2"); zy=eom(zy)
  24  -------   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: zv gt mid(zy,"4","2") 

        Then: zw=mid(zw,"1","3"); goto GETDATE 

  25  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: zw=zw{"/"; goto GETDATE 

  26  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
VALDATEþ If: @sk eq "BRKY" or zw eq "" 

        Then: return 

  27  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If:                          'Check potentially bad leap year
        Then: zv=mid(zw,"4","2") 

  28  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: zy=mid(zw,"1","3")&"01/"&mid(zw,"7","2"); zy=eom(zy) 

  29  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: zv gt mid(zy,"4","2") 

        Then: zw=mid(zw,"1","3"); goto GETDATE 

  30  -------   -   -   -   -   -   -   -   -   -   -   -   -   -
        þ If: 

        Then: return 



Jose Lerebours
954-559-7186
http://www.fpgroups.com


More information about the Filepro-list mailing list