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

Testing for Null Time value.

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

  • Testing for Null Time value.

    I'm trying to verify a value of type time exists before I create a new record. I've tried several methods to test if the value in the "end_time" field is Null, but none seems to work.

    How do you test for a Null time value in a browse?

    The documentation in the "Null Table Field Values" says if you want to test for a NULL time value use:
    "fieldname" = 00/00/0000 12:00:00 00 am
    That is the value that the Object Explorer shows in my application.

    My code:
    parentform:BROWSE2.Fetch_Last()
    if (parentform:Browse2:End_Time.Value = 00/00/0000 12:00:00 00 am)
    ui_msg_box("Info", "Value Found", UI_OK)
    endif

    This results in a "no such field" error.

    To test that End_Time.Value existed, I tried the following:
    parentform:BROWSE2.Fetch_Last()
    if (parentform:Browse2:End_Time.Value = ctodt("08/05/0000 12:00:00 00 am"))
    ui_msg_box("Info", "Value Found", UI_OK)
    else
    ui_msg_box("Info", "Value Not Found", UI_OK)
    endif

    No error from this, and it returned "Value Not Found", which was expected.

    Next test:
    parentform:BROWSE2.Fetch_Last()
    if (parentform:Browse2:End_Time.Value = ctodt("00/00/0000 12:00:00 00 am"))
    ui_msg_box("Info", "Value Found", UI_OK)
    else
    ui_msg_box("Info", "Value Not Found", UI_OK)
    endif

    Resulted in the error "Not a valid time format."

    Since it said the default null time was not a valid time format, I thought I'd test to see if the value in the field was not valid, and go based on that.

    if(IsTime(parentform:Browse2:End_Time.Value))
    ui_msg_box("Info", "Value Found", UI_OK)
    else
    ui_msg_box("Info", "Value Not Found", UI_OK)
    endif

    This resulted in the error "Variable is of different type."

    I've run out of ideas. What simple thing have I missed that will see if the time field is null?

    Tony

  • #2
    RE: Testing for Null Time value.

    what do these functions report?

    IsTime()
    IsShortTime()

    ???

    -- tom

    Comment


    • #3
      RE: Testing for Null Time value.

      Tony,

      Is Time_end a field tye "Time" in your table?
      Is Time_end the header name in your browse?

      Make sure that the field is in fact a "time" type in your table by checking the table structure.

      Since ctodt("08/05/0000 12:00:00 00 am")) did return the correct responce, its my guess you have time end as a "Character" type.

      If not then check your column header. If it is something different then Time_end or Time end, then you need to reference that. For example, if your browse header says "Ending Time" then your syntax would be:

      parentform:Browse2:Ending_Time.Value

      Hope this helps.

      Scott

      Comment


      • #4
        RE: Testing for Null Time value.

        The ISTIME() function returns .T. if the Time_String is a valid representation of a time value. The parameter should be of type character, so it should not give me the correct result.

        I was grasping at straws when I tried that function, but should have realized it would not work.

        The IsShortTime() function returns .T. if the Time_String is a valid representation of a short time value. This wouldn't work for two reasons. One, I'm dealing with a field that's of type "time", not type "short time". Two, it takes a parameter of type "character".

        Comment


        • #5
          RE: Testing for Null Time value.

          End_Time is of type "time" is is 17 units long. I did check the table structure. Many times. ;)
          End_Time is also the header name in the browse.

          ctodt() returns a time format, not a character format. I tested that again, and it works perfectly if I have a valid time that is not 00/00/00 12:00:00 00 am.

          Not sure of where to go from here.

          Comment


          • #6
            RE: Testing for Null Time value.

            try this:

            t=table.get("tablename")
            if t.datefield.is_blank()
            'xxx
            end if
            Cole Custom Programming - Terrell, Texas
            972 524 8714
            martin_w_cole@msn.com

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

            Comment


            • #7
              RE: Testing for Null Time value.

              Martin,

              That worked.

              I was hoping to do this with forms, but tables should work.

              Thanks,
              Tony

              Comment


              • #8
                RE: Testing for Null Time value.

                Ok. I can see that now, too.

                I've just worked up an example that approaches the problem differently.

                1) instead of reading the column value from the browse object, I established a pointer to the table being displayed in the browse object.

                2) I used convert_type() to take the time value and convert it to a character string.

                3) I compare the character string to the null field string value

                It seems to work just fine. Perhaps there's an easier more direct way, but this is what I would up with, where START is a table fieldname, with data type of T.

                If convert_type(tbl.start,"C") = "00/00/00 00:00:00 00 AM" then 'time field is empty

                Hope this helps.

                -- tom

                Comment


                • #9
                  RE: Testing for Null Time value.

                  Tom,

                  That also worked.

                  I tried doing the same thing on the column value form browse but it didn't work. I wonder why it's possible to do this two ways using tables, but it doesn't seem to work using the form/browse object.

                  Thanks for the help.
                  Tony

                  Comment


                  • #10
                    RE: Testing for Null Time value.

                    BROWSE2.Fetch_Last()
                    if parentform:tables:tablename.datefield.is_blank()ui_msg_box("Info", "Value Found", UI_OK)
                    end if
                    Cole Custom Programming - Terrell, Texas
                    972 524 8714
                    martin_w_cole@msn.com

                    ____________________
                    "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: Testing for Null Time value.

                      Thanks Martin,

                      I'm impressed with the multitude of ways to do this. You and Tom have been very helpful.

                      Tony

                      Comment


                      • #12
                        RE: Testing for Null Time value.

                        Tony,

                        You can use the column value in the browse object, but it seems you must convert its data type to character in order to use it in other expressions:

                        In my case START is a field in the table and the column title:

                        convert_type(Parentform:browse1:start.value,"C") returns
                        "00/00/0000 12:00:00 00 am" if the field is empty.

                        -- tom

                        Comment


                        • #13
                          RE: Testing for Null Time value.

                          Hi Tom,

                          I tried that code and it didn't work. That why I said for some reason it doesn't seem to work in the form browse object.

                          This code works:

                          tbl as p
                          tbl = table.get("work_time")
                          tbl.fetch_last()
                          if (convert_type(tbl.end_time,"C") = "00/00/0000 12:00:00 00 AM")
                          ...
                          end if

                          This code doesn't work:

                          parentform:BROWSE2.Fetch_Last()
                          if convert_type( parentform:BROWSE2:End_Time.Value, "C") = "00/00/0000 12:00:00 00 AM"

                          It doesn't give an error, it just never recognizes that the value in end_time is actually blank. I'm assuming that case does not matter. (end_time vs End_Time)

                          Tony

                          Comment


                          • #14
                            RE: Testing for Null Time value.

                            Tony,

                            I'm not sure what I'm doing that you are not, but I have no difficulty with the embedded browse object, and disagree with your conclusion that my script won't work.

                            Here's an example for you.

                            Open the only form you'll find. It has one button. This button examines each of the three rows in the browse object. If the Start field is not null the field value is dumped to the trace window. If the start field is empty a statement to that effect is dumped to the trace window. Push the button. Check the trace window. The script is able to determine if the column value is empty just fine.

                            Perhaps you're using a fieldname in your expression, instead of the column name? This often trips me up.

                            -- tom

                            Comment


                            • #15
                              RE: Testing for Null Time value.

                              Hi Tom,

                              What I'm about to say isn't going to make an sense.

                              I ran your demo and it worked, as expected. I then compared the code, and noticed I had some space in my code that you didn't have in your code. These spaces should not make any difference. I removed those spaces and retried.

                              Original:
                              if convert_type( parentform:BROWSE2:End_Time.Value, "C") = "00/00/0000 12:00:00 00 AM"

                              Without spaces:
                              if convert_type(parentform:BROWSE2:End_Time.Value,"C") = "00/00/0000 12:00:00 00 AM"

                              My code now worked like a charm. I then put the spaces back in and it still worked, like it should.

                              I'm sorry to put you through all this. Obviously I was doing something wrong, but I'm not sure what it was. Your code looked like it should have worked, it just wasn't working for me. Didn't mean to say your code didn't work.

                              Tony

                              Comment

                              Working...
                              X