Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

invalid date trapping in xdialog

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    invalid date trapping in xdialog

    how can you have xdialog trap an invalid date, like 12/32/2010, while still in xdialog?
    Cole Custom Programming - Terrell, Texas
    972 524 8714
    [email protected]

    ____________________
    "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

    #2
    Re: invalid date trapping in xdialog

    Still kinda lost using xdialog, but...

    As you advance from field to field, use code and isdate to test the input.

    There's a good example of that sort of thing here...

    http://msgboard.alphasoftware.com/al...ad.php?t=87342

    Comment


      #3
      Re: invalid date trapping in xdialog

      thanks David

      experimenting, using the isdate() I can trap and then use the goto to set it back in that box, but haven't figured out how to let it out if its an empty date.

      right now I am diasappointed that a technique I have been using for years no longer works - namely displaying a small form as a dialog, with 2 global variables. In 4.0 thru 9, the system would inform the user the date was invalid, but it does no do so in 10.

      in the example below, first test it as is. Then uncomment the goto and try it

      Code:
      'Date Created: 30-Jul-2010 09:00:51 AM
      'Last Updated: 30-Jul-2010 09:00:51 AM
      'Created By  : martin cole
      'Updated By  : martin cole
      'Create an XDialog dialog box to prompt for parameters.
      DIM SHARED bdate as D
      DIM SHARED edate as D
      DIM SHARED varC_result as C
      ok_button_label = "&OK"
      cancel_button_label = "&Cancel"
      varC_result = ui_dlg_box("Enter Dates",<<%dlg%
      {Background=#237+232+211}
      {region}
      From:| [%DATE;P=popup.calendar(dtoc(bdate));I=popup.calendar%.20bdate!bdate_*];
      Thru:| [%DATE;P=popup.calendar(dtoc(edate));I=popup.calendar%.20edate!edate_*];
      {endregion};
      {line=1,0};
      {region}
      <15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
      {endregion};
      %dlg%,<<%code%
      if left(a_dlg_button,6) = "bdate_" then 
       if a_dlg_button = "bdate_killfocus" then 
        bdate = ctod(dtoc(bdate))
        if isdate(dtoc(bdate))
        else
         msgbox("","Invalid Date!")
      '   ui_dlg_ctl_goto("Enter Dates","bdate")
        end if   
       end if 
       a_dlg_button = ""
      end if 
      if left(a_dlg_button,6) = "edate_" then 
       if a_dlg_button = "edate_killfocus" then 
        edate = ctod(dtoc(edate))
       end if 
       a_dlg_button = ""
      end if
      %code%)
      Cole Custom Programming - Terrell, Texas
      972 524 8714
      [email protected]

      ____________________
      "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

      Comment


        #4
        Re: invalid date trapping in xdialog

        This seems to do it... test for a null entry.

        Code:
        'Date Created: 30-Jul-2010 09:00:51 AM
        'Last Updated: 30-Jul-2010 11:41:33 AM
        'Created By  : martin cole
        'Updated By  : PFGate
        'Create an XDialog dialog box to prompt for parameters.
        DIM SHARED bdate as D
        DIM SHARED edate as D
        DIM SHARED varC_result as C
        ok_button_label = "&OK"
        cancel_button_label = "&Cancel"
        varC_result = ui_dlg_box("Enter Dates",<<%dlg%
        {Background=#237+232+211}
        {region}
        From:| [%DATE;P=popup.calendar(dtoc(bdate));I=popup.calendar%.20bdate!bdate_*];
        Thru:| [%DATE;P=popup.calendar(dtoc(edate));I=popup.calendar%.20edate!edate_*];
        {endregion};
        {line=1,0};
        {region}
        <15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
        {endregion};
        %dlg%,<<%code%
        if left(a_dlg_button,6) = "bdate_" then 
         if a_dlg_button = "bdate_killfocus" then 
          bdate = ctod(dtoc(bdate))
          If isnull(cdate(bdate)) then
          else
            if isdate(dtoc(bdate))
        	else
        	  msgbox("","Invalid Date!")
        	    ui_dlg_ctl_goto("Enter Dates","bdate")
            end if
          end if   
         end if 
         a_dlg_button = ""
        end if 
        if left(a_dlg_button,6) = "edate_" then 
         if a_dlg_button = "edate_killfocus" then 
          edate = ctod(dtoc(edate))
         end if 
         a_dlg_button = ""
        end if
        %code%)

        Comment


          #5
          Re: invalid date trapping in xdialog

          on mine, your code change does not trap the bad date
          Cole Custom Programming - Terrell, Texas
          972 524 8714
          [email protected]

          ____________________
          "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

          Comment


            #6
            Re: invalid date trapping in xdialog

            It doesn't trap it for me either.

            I don't think you can really do it with a date prompt because A5 immediately changes it to a blank date. This means you can't differentiate between someone simply leaving the field blank and someone entering a bad date.

            As far as I can tell, it looks like you would have to enter the date as a character value so you could test it then convert it to a date value later. This isn't something I want to take the time to do!

            The only thing I can see that seems reasonable is to check for blank dates when the OK button is pressed. Of course, this assumes that either blank dates aren't allowed or the user will get a message prompting whether or not they intended it to be blank.

            FYI: Take that last {region} off around the buttons and, in my opinion, the dialog box will look better - see attachments. In fact, that extra semicolon on the end adds even more vertical space. Alpha's genie puts lots of regions in that really aren't needed and every region used adds extra blank space at the bottom of the region. I guess that's what we call a "special feature".

            Comment


              #7
              Re: invalid date trapping in xdialog

              Thanks Cal,

              one nice improvement I noticed is that at lest the dates are now handled normally - auto adding the slashes and the year

              I decided to trap/warn on the error, but not go back - since I will handle their responses anyway
              Cole Custom Programming - Terrell, Texas
              972 524 8714
              [email protected]

              ____________________
              "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

              Comment


                #8
                Re: invalid date trapping in xdialog

                OK Martin, you got me on two accounts. This is not me talking, it's that annoying part of my brain that deals with logic!

                If a user is to pick a date from the popup calendar, how could it be invalid?
                It can't.
                But, I will cut you a slack. It can be invalid if the user chooses to type in an invalid date. Which takes us to the second account.

                You ever wonder why alpha does this:
                bdate = ctod(dtoc(bdate)) ?
                Again, it's that annoying part of my brain. Why change a date to character then back to date?
                Alpha does so to translate an incomplete or an abbreviated date to a date.
                This process in and by itself checks for the validity of the date. If the date is invalid, it will return blank as it should.

                So, what you need to check for is if the final bdate is or is not blank:

                Code:
                %dlg%,<<%code%
                if left(a_dlg_button,6) = "bdate_" then 
                 if a_dlg_button = "bdate_killfocus" then 
                  bdate = ctod(dtoc(bdate))
                  if bdate={}
                   msgbox("","Blank or Invalid Date!")
                  end if   
                 end if 
                 a_dlg_button = ""
                end if 
                %code%)

                Comment


                  #9
                  Re: invalid date trapping in xdialog

                  Thanks Gabe,

                  but I think it�s a lost cause - i.e., I can trap and warn, and go back, but I can't also let a blank one through
                  After reading your post got some ideas and tried many iterations, but all failed to both capture an invalid AND let a blank through
                  Cole Custom Programming - Terrell, Texas
                  972 524 8714
                  [email protected]

                  ____________________
                  "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                  Comment


                    #10
                    Re: invalid date trapping in xdialog

                    actually - I think something else is going on - not just in xdialog, but in general

                    I made a form with two global variables [bd and ed] for entering dates and the same behavior exists there too - namely that a blank entry cannot be trapped and also trap an invalid date

                    on the ondepart event on the form here is code that works:

                    Code:
                    if isdate(dtoc(bd.value))
                    else
                     msgbox("Error","Invalid Date")
                    end if
                    but its quite annoying, because it also warns of the date is blank

                    this code won't work, in the same way as in the xdialog:
                    Code:
                    'if isdate(dtoc(bd.value)) .or. bd.value={} 'either if causes it to fail
                    if isdate(dtoc(bd.value)) .or. dtos(bd.value)=""
                    else
                     msgbox("Error","Invalid Date")
                    end if
                    Stuff like this has worked from 4.0 thru 9, and now its changed, (probably for compatibility with the beloved Web side) - its quite annoying, especially if you are trying to convert a large legacy app to V10

                    in fact, in 4.0 thru 9, this wasn't an issue - you could use a global variable on a form for capturing dates and it would warn if it was invalid

                    I also added two fields to the dummy table I use for creating little forms for capturing user options, and using those on the form instead of the variables, and invalid date throws and error

                    reported all as bugs, last night, but haven't heard back yet
                    Cole Custom Programming - Terrell, Texas
                    972 524 8714
                    [email protected]

                    ____________________
                    "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                    Comment


                      #11
                      Re: invalid date trapping in xdialog

                      Martin,
                      I think this should work if you have a field following the date to key on for the set focus event.


                      Code:
                      dim dlg_title as C="Martin"
                      dim dlg_body as C
                      dim dlg_code as C
                      dim vR as C
                      dim vdob as C
                      dim vLG as C
                      	vLG="male"+crlf()+"female"
                      dim vbdT as C			'director variable
                      dim vctrl_dob as C="[.14vdob!evdb_*]"
                      dim vctrl_gen as C="[.20vG^+vLG!evge_*]"
                      
                      dlg_body=<<%dlg%
                      {font=arial,10}
                      {lf};
                      Birth Date: | [.14vdob!evdb_*];
                      Gender: | [.20vG^+vLG!evge_*];
                      {lf};
                      <OK>
                      %dlg%
                      
                      dlg_code=<<%code%
                      IF left(a_dlg_button,5) = "evdb_" 
                       if a_dlg_button = "evdb_killfocus"  
                        	if vdob=""
                        		vbdT="empty"
                        		ui_dlg_ctl_goto(dlg_title,vctrl_gen)
                        	else
                        		vbdT="full"
                        		ui_dlg_ctl_goto(dlg_title,vctrl_gen)
                        	end if   
                       end if 
                       a_dlg_button=""
                      END IF
                      
                      IF left(a_dlg_button,5) = "evge_" 
                        if a_dlg_button="evge_setfocus"
                        	'msgbox("director variable report",vbdT)
                        	if vbdT<>"empty"
                        		if isdate(vdob)=.f.
                                                ui_modeless_dlg_box("ERROR",<<%dlg%
                                                {background=yellow}{lf};
                                               The entered date is not valid
                                               {lf};
                        		%dlg%)
                        		sleep(2)
                        		ui_modeless_dlg_close("ERROR")
                         		vdob=""
                        		ui_dlg_ctl_goto(dlg_title,vctrl_dob)
                        		end if
                        	end if
                         end if
                       a_dlg_button=""
                      END IF
                      %code%
                      
                      vR=ui_dlg_box(dlg_title,dlg_body,dlg_code)
                      Mike W
                      __________________________
                      "I rebel in at least small things to express to the world that I have not completely surrendered"

                      Comment


                        #12
                        Re: invalid date trapping in xdialog

                        Martin,
                        This may work if you have no joy with the bug report.
                        I changed the variable type that the control is based on to character (bdateC), since the date picker returns a character type anyway. Then if it is ok assign the value to your original bdate variable.

                        To my surprise, even though a character type the slashes are still entered. Although not the year. That must be a result of being part of the date picker control. As you will see though the year does get added eventually. So you can still key in 0731 which show as 07/31 and result in 07/31/2010.

                        Will be interesting what the response is to the bug report.


                        Code:
                        'Create an XDialog dialog box to prompt for parameters.
                        DIM SHARED bdateC as C
                        dim shared bdate as D
                        DIM SHARED edate as D
                        DIM SHARED varC_result as C
                        ok_button_label = "&OK"
                        cancel_button_label = "&Cancel"
                        varC_result = ui_dlg_box("Enter Dates",<<%dlg%
                        {Background=#237+232+211}
                        {region}
                        From:| [%DATE;P=popup.calendar(bdateC);I=popup.calendar%.20bdateC!bdateC_*];
                        Thru:| [%DATE;P=popup.calendar(dtoc(edate));I=popup.calendar%.20edate!edate_*];
                        {endregion};
                        {line=1,0};
                        {region}
                        <15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
                        {endregion};
                        %dlg%,<<%code%
                        IF left(a_dlg_button,7) = "bdateC_" THEN
                            IF a_dlg_button = "bdateC_killfocus" THEN
                                IF bdateC = "" THEN
                                    bdate = {}
                                ELSE
                                    IF isdate(bdateC)
                                        bdate = ctod(bdateC)
                                        [COLOR="Red"]bdateC = dtoc(bdate)[/COLOR]
                                    ELSE
                                        msgbox("","Invalid Date!")
                                        ui_dlg_ctl_goto("Enter Dates","bdate")
                                    END IF
                                END IF
                            END IF
                            a_dlg_button = ""
                        END IF
                        if left(a_dlg_button,6) = "edate_" then 
                         if a_dlg_button = "edate_killfocus" then 
                          edate = ctod(dtoc(edate))
                         end if 
                         a_dlg_button = ""
                        end if
                        %code%)
                        
                        msgbox("Result for bdate","bdate is: "+bdate)
                        EDIT: Was able to get the character variable to update to the correct date representation with code line in red.
                        Last edited by Tim Kiebert; 07-30-2010, 08:05 PM. Reason: had an epiphany
                        Tim Kiebert
                        Eagle Creek Citrus
                        A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                        Comment


                          #13
                          Re: invalid date trapping in xdialog

                          most excellent - I wonder is there is an object refresh command in xdialog that would cause the year to fill in?
                          Cole Custom Programming - Terrell, Texas
                          972 524 8714
                          [email protected]

                          ____________________
                          "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                          Comment


                            #14
                            Re: invalid date trapping in xdialog

                            magnificent creativity!!!! thank's a million!!!!!
                            nice thing is ablout Alpha, if you know how there a whole bunch 'a ways to do it!
                            Cole Custom Programming - Terrell, Texas
                            972 524 8714
                            [email protected]

                            ____________________
                            "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                            Comment


                              #15
                              Re: invalid date trapping in xdialog

                              'Date Created: 30-Jul-2010 07:22:26 PM
                              'Last Updated: 30-Jul-2010 07:22:26 PM
                              'Created By : martin cole
                              'Updated By : martin cole
                              OK - Here's keeper

                              DIM SHARED bdateC as C
                              dim shared bdate as D
                              DIM SHARED edatec as c
                              DIM SHARED edate as D
                              DIM SHARED varC_result as C
                              ok_button_label = "&OK"
                              cancel_button_label = "&Cancel"
                              varC_result = ui_dlg_box("Enter Dates",<<%dlg%
                              {Background=#237+232+211}
                              {region}
                              From:| [%DATE;P=popup.calendar(bdateC);I=popup.calendar%.20bdateC!bdateC_*];
                              Thru:| [%DATE;P=popup.calendar(edateC);I=popup.calendar%.20edateC!edateC_*];
                              {endregion};
                              {line=1,0};
                              {region}
                              <15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
                              {endregion};
                              %dlg%,<<%code%
                              IF left(a_dlg_button,7) = "bdateC_" THEN
                              IF a_dlg_button = "bdateC_killfocus" THEN
                              IF bdateC = "" THEN
                              bdate = {}
                              ELSE
                              IF isdate(bdateC)
                              bdate = ctod(bdateC)
                              bdateC = dtoc(bdate)
                              ELSE
                              msgbox("","Invalid Date!")
                              ui_dlg_ctl_goto("Enter Dates","bdate")
                              END IF
                              END IF
                              END IF
                              a_dlg_button = ""
                              END IF
                              if left(a_dlg_button,7) = "edatec_" then
                              if a_dlg_button = "edatec_killfocus" then
                              IF edateC = "" THEN
                              edate = {}
                              ELSE
                              IF isdate(edateC)
                              edate = ctod(edateC)
                              edateC = dtoc(edate)
                              ELSE
                              msgbox("","Invalid Date!")
                              ui_dlg_ctl_goto("Enter Dates","edate")
                              END IF
                              END IF
                              end if
                              a_dlg_button = ""
                              end if
                              %code%)
                              Last edited by martinwcole; 07-30-2010, 08:35 PM.
                              Cole Custom Programming - Terrell, Texas
                              972 524 8714
                              [email protected]

                              ____________________
                              "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                              Comment

                              Working...
                              X