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

else doesn't fire

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

    else doesn't fire

    Hi Everyone,

    I have a function that almost works.
    The problem I am running into is the else statement at line 79 (the last else statement) is being ignored.

    The values are :
    wilog01 = {11/05/2012 02:31}
    delivery_time = {11/04/2012 21:33}
    ptchoice = "P"

    I think I have stepped through this about 100 times, but have not been able to determine why the else statement is being ignored.
    In an effort to make things easier to follow, I put the code into a color coded spreadsheet (http://www.wisux.com/ifthenelse.xls).
    The important lines are the ones in purple.

    Any help would be greatly appreciated.

    Gregg

    Code:
    'Date Created: 22-Sep-2012 02:34:48 PM
    'Last Updated: 23-Sep-2012 12:36:29 AM
    'Created By  : me
    'Updated By  : me
    FUNCTION auth_dltimechange AS C (tc AS P )
    	debug(1)
    	
    	
    	if tc.datasubmitted.wilog01 <>"" .or. tc.datasubmitted.wilog02 <> "" then
    		unsure = utccreate(tc.datasubmitted.delivery_time,val(tc.datasubmitted.delivery_offset),tc.datasubmitted.delivery_dst)
    				if unsure = convert_type(tc.datasubmitted.wilog01,"T") then
    					end
    				end if
    		tc._setElement.tattle.value ="<br>Old time was " + timez("MM/dd/yyyy 0h:0m",utcreverse(tc.datasubmitted.wilog01,val(tc.datasubmitted.delivery_offset),tc.datasubmitted.delivery_dst))
    '		tc._setElement.tattle.value = tc._setElement.tattle.value + "<br>This is test line 1."
    '		tc._setElement.tattle.value = tc._setElement.tattle.value + "<br>This is test line 2"
    				
    				' This section adjusts the Pickup Time to match the new earlier Delivery Time
    				if unsure < convert_type(tc.datasubmitted.wilog01,"T") .and. tc.datasubmitted.ptchoice = "D" then
    					tc._set.wilog01.value = timez("MM/dd/yyyy 0h:0m",unsure)
    					tc._set.wilog02.value = timez("MM/dd/yyyy 0h:0m",unsure - val(tc.datasubmitted.scheduled_drivetime))
    					tc._set.pickup_time.value = time("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog02.value,val(tc.datasubmitted.pickup_offset),tc.datasubmitted.pickup_dst))
    					tc._set.showpzone.value = if(isutcdaylight(convert_type(tc._set.wilog02.value,"T"),val(tc.datasubmitted.pickup_offset)).and. tc.datasubmitted.pickup_dst="Y",left(tc.datasubmitted.pickup_tz,1)+"DT",tc.datasubmitted.pickup_tz)
    					tc._set.showdzone.value = if(isutcdaylight(convert_type(tc._set.wilog01.value,"T"),val(tc.datasubmitted.delivery_offset)).and. tc.datasubmitted.delivery_dst="Y",left(tc.datasubmitted.delivery_tz,1)+"DT",tc.datasubmitted.delivery_tz)
    					tc._setElement.PUFRAME.value = "Pickup"
    					tc._setElement.DELFRAME.value = "Delivery"
    							if isutcdaylight(convert_type(tc._set.wilog02.value,"T"),-6) .and. tc.datasubmitted.pickup_tz+tc.datasubmitted.pickup_dst <> "CSTY" then
    								tc._setElement.PUFRAME.value = "Pickup : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog02.value,-6,"Y"))+" CDT"
    							elseif .not. isutcdaylight(convert_type(tc._set.wilog02.value,"T"),-6) .and. tc.datasubmitted.pickup_tz <> "CST" then
    								tc._setElement.PUFRAME.value = "Pickup : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog02.value,-6,"Y"))+" CST"
    							end if
    							
    							if isutcdaylight(convert_type(tc._set.wilog01.value,"T"),-6) .and. tc.datasubmitted.delivery_tz+tc.datasubmitted.delivery_dst <> "CSTY" then
    								tc._setElement.DELFRAME.value = "Delivery : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog01.value,-6,"Y"))+" CDT"
    							elseif .not. isutcdaylight(convert_type(tc._set.wilog01.value,"T"),-6) .and. tc.datasubmitted.delivery_tz <> "CST" then
    								tc._setElement.DELFRAME.value = "Delivery : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog01.value,-6,"Y"))+" CST"
    							end if
    							
    							' This section adjusts the Pickup Time to match the new later Delivery Time
    						elseif unsure > convert_type(tc.datasubmitted.wilog01,"T") .and. tc.datasubmitted.ptchoice = "D" then
    							tc._set.wilog01.value = timez("MM/dd/yyyy 0h:0m",unsure)
    							tc._set.wilog02.value = timez("MM/dd/yyyy 0h:0m",unsure - val(tc.datasubmitted.scheduled_drivetime))
    							
    							'			tc._set.wilog01.value = convert_type(unsure,"C")
    							'			tc._set.wilog02.value = convert_type(unsure - val(tc.datasubmitted.scheduled_drivetime),"C")
    							tc._set.pickup_time.value = time("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog02.value,val(tc.datasubmitted.pickup_offset),tc.datasubmitted.pickup_dst))
    							tc._set.showpzone.value = if(isutcdaylight(convert_type(tc._set.wilog02.value,"T"),val(tc.datasubmitted.pickup_offset)).and. tc.datasubmitted.pickup_dst="Y",left(tc.datasubmitted.pickup_tz,1)+"DT",tc.datasubmitted.pickup_tz)
    							tc._setElement.PUFRAME.value = "Pickup"
    							tc._setElement.DELFRAME.value = "Delivery"
    							if isutcdaylight(convert_type(tc._set.wilog02.value,"T"),-6) .and. tc.datasubmitted.pickup_tz+tc.datasubmitted.pickup_dst <> "CSTY" then
    								tc._setElement.PUFRAME.value = "Pickup : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog02.value,-6,"Y"))+" CDT"
    							elseif .not. isutcdaylight(convert_type(tc._set.wilog02.value,"T"),-6) .and. tc.datasubmitted.pickup_tz <> "CST" then
    								tc._setElement.PUFRAME.value = "Pickup : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog02.value,-6,"Y"))+" CST"
    							end if
    							
    							if isutcdaylight(convert_type(tc._set.wilog01.value,"T"),-6) .and. tc.datasubmitted.delivery_tz+tc.datasubmitted.delivery_dst <> "CSTY" then
    								tc._setElement.DELFRAME.value = "Delivery : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog01.value,-6,"Y"))+" CDT"
    							elseif .not. isutcdaylight(convert_type(tc._set.wilog01.value,"T"),-6) .and. tc.datasubmitted.delivery_tz <> "CST" then
    								tc._setElement.DELFRAME.value = "Delivery : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog01.value,-6,"Y"))+" CST"
    							end if
    							
    							
    							' This section authorizes changes to delivery time where Pickup Time is primary
    						elseif unsure < convert_type(tc.datasubmitted.wilog01,"T") .and. tc.datasubmitted.ptchoice = "P" then
    							
    							if unsure - convert_type(tc.datasubmitted.wilog02,"T") < val(tc.datasubmitted.scheduled_drivetime) then
    								tc._setElement.tattle.value = "That delivery time would violate minimum time values.<br>"
    								tc._set.delivery_time.value = time("MM/dd/yyyy 0h:0m",utcreverse(tc.datasubmitted.wilog01,val(tc.datasubmitted.delivery_offset),tc.datasubmitted.delivery_dst))
    								tc._setElement.tattle.value = tc._setElement.tattle.value + "Delivery time has been reset to "+tc._set.delivery_time.value
    								if isutcdaylight(convert_type(tc.datasubmitted.wilog01,"T"),-6) .and. tc.datasubmitted.delivery_tz+tc.datasubmitted.delivery_dst <> "CSTY" then
    									tc._setElement.DELFRAME.value = "Delivery : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc.datasubmitted.wilog01,-6,"Y"))+" CDT"
    								elseif .not. isutcdaylight(convert_type(tc.datasubmitted.wilog01,"T"),-6) .and. tc.datasubmitted.delivery_tz <> "CST" then
    									tc._setElement.DELFRAME.value = "Delivery : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc.datasubmitted.wilog01,-6,"Y"))+" CST"
    								end if
    								
    							
    							
    							
    						else
    							tc._set.wilog01.value = time("MM/dd/yyyy 0h:0m",utccreate(tc.datasubmitted.delivery_time,val(tc.datasubmitted.delivery_offset),tc.datasubmitted.delivery_dst))
    							tc._set.showdzone.value = if(isutcdaylight(convert_type(tc._set.wilog01.value,"T"),val(tc.datasubmitted.delivery_offset)).and. tc.datasubmitted.delivery_dst="Y",left(tc.datasubmitted.delivery_tz,1)+"DT",tc.datasubmitted.delivery_tz)
    							
    							if isutcdaylight(convert_type(tc._set.wilog01.value,"T"),-6) .and. tc.datasubmitted.delivery_tz+tc.datasubmitted.delivery_dst <> "CSTY" then
    								tc._setElement.DELFRAME.value = "Delivery : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog01.value,-6,"Y"))+" CDT"
    							elseif .not. isutcdaylight(convert_type(tc._set.wilog01.value,"T"),-6) .and. tc.datasubmitted.delivery_tz <> "CST" then
    								tc._setElement.DELFRAME.value = "Delivery : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog01.value,-6,"Y"))+" CST"
    							end if
    						end if
    					
    				end if
    		
    		end
    	end if
    	
    END FUNCTION
    Gregg
    https://paiza.io is a great site to test and share sql code

    #2
    Re: else doesn't fire

    I'm trying to simplify this, but don't know what/how to fill the value for tc.datasubmitted.delivery_dst


    Code:
    wilog01 = {11/05/2012 02:31}
    delivery_time = {11/04/2012 21:33}
    ptchoice = "P"
    
    unsure = utccreate(delivery_time, 1, tc.datasubmitted.delivery_dst)
    if unsure < convert_type(wilog01,"T") .and. ptchoice = "D" then
    	msgbox("case1")
    elseif unsure > convert_type(wilog01,"T") .and. ptchoice = "D" then
    	msgbox("case2")
    elseif unsure < convert_type(wilog01,"T") .and. ptchoice = "P" then
    	msgbox("case3")
    else
    	msgbox("case4")
    end if
    -Steve
    sigpic

    Comment


      #3
      Re: else doesn't fire

      I missed that one.
      delivery_dst = "Y"
      Gregg
      https://paiza.io is a great site to test and share sql code

      Comment


        #4
        Re: else doesn't fire

        I thought UTCCreate() was just a function I didn't know, but looks like it's a UDF.

        Can you supply the value of Unsure that you want to use in your test so I don't have to try to create it?
        -Steve
        sigpic

        Comment


          #5
          Re: else doesn't fire

          My fault.
          Simple answer is {11/05/2012 02:33}.
          Gregg
          https://paiza.io is a great site to test and share sql code

          Comment


            #6
            Re: else doesn't fire

            This picture shows a bit more, but nothing has changed.

            Gregg
            https://paiza.io is a great site to test and share sql code

            Comment


              #7
              Re: else doesn't fire

              For what its worth.
              These functions make my work with North American timezones so much easier.

              Code:
              FUNCTION utccreate AS T (basetime AS C, offset AS N, observed AS C )
              'debug(1)	
              dim offset as n
              dim dstv as n= 1
              dim dstbeg as t
              dim dstend as t
              dim dttmcheck2 as t
              
              
              dstbeg = convert_type(nth_dow("sunday" ,3,year(convert_type(basetime,"d")) ,2),"T")-((offset)*3600)+7200
              dstend = convert_type(nth_dow("sunday" ,11,year(convert_type(basetime,"d")) ,1),"T")-((offset+dstv)*3600)+7200	
              
              if convert_type(basetime,"T")-((offset+dstv)*3600) >= dstbeg .and. convert_type(basetime,"T")-((offset+dstv)*3600) < dstend then
              	dstv = 1
              	else
              	dstv = 0
              end if	
              	
              if observed <> "y" then
              	dstv = 0
              end if
              
              dttmcheck2 = convert_type(basetime,"T")-(offset*3600)-(dstv*3600)
              
              
              utccreate = dttmcheck2
              	
              	
              END FUNCTION

              Code:
              FUNCTION utcreverse AS T (basetime AS C, offset AS N, observed AS C )
              'debug(1)
              	
              dim offset as n
              dim dstv as n= 1
              dim dstbeg as t
              dim dstend as t
              dim dttmcheck2 as t
              
              if observed <> "y" then
              	dstv = 0
              end if
              
              dstbeg = convert_type(nth_dow("sunday" ,3,year(convert_type(basetime,"T")) ,2),"T")-((offset)*3600)+7200
              dstend = convert_type(nth_dow("sunday" ,11,year(convert_type(basetime,"T")) ,1),"T")-((offset+dstv)*3600)+7200	
              
              if convert_type(basetime,"T") >= dstbeg .and. convert_type(basetime,"T") < dstend then
              	dttmcheck2 = convert_type(basetime,"T")+((offset+dstv)*3600)
              	
              'if observed <> "y" then
              '	dttmcheck2 = dttmcheck2 - 3600
              'end if	
              	
              else
              	dttmcheck2 = convert_type(basetime,"T")+(offset*3600)	
              end if
              
              
              
              utcreverse = dttmcheck2
              	
              	
              END FUNCTION
              Gregg
              https://paiza.io is a great site to test and share sql code

              Comment


                #8
                Re: else doesn't fire

                When I run the code below, it correctly produces Case 4.

                Code:
                wilog01 = {11/05/2012 02:31}
                delivery_time = {11/04/2012 21:33}
                ptchoice = "P"
                delivery_dst = "Y" 
                unsure = {11/05/2012 02:33}
                
                if unsure < convert_type(wilog01,"T") .and. ptchoice = "D" then
                	msgbox("case 1")
                elseif unsure > convert_type(wilog01,"T") .and. ptchoice = "D" then
                	msgbox("case 2")
                elseif unsure < convert_type(wilog01,"T") .and. ptchoice = "P" then
                	msgbox("case 3")
                else
                	msgbox("case 4")
                end if
                -Steve
                sigpic

                Comment


                  #9
                  Re: else doesn't fire

                  Hi Steve,
                  It has me baffled.
                  The video below shows me stepping through the debugger, expecting the statements after else to fire, yet for some reason they don't.

                  http://www.youshould-seethis.com/a5/elsefails.html
                  Gregg
                  https://paiza.io is a great site to test and share sql code

                  Comment


                    #10
                    Re: else doesn't fire

                    Gregg - been real busy all day. Your video doesn't show in Chrome, and is very messy in IE.
                    -Steve
                    sigpic

                    Comment


                      #11
                      Re: else doesn't fire

                      Hi Steve,

                      I understand the busy thing. Just after I fixed the issue, I started getting calls about emails not coming in on time.
                      Meant to update this sooner, but I guess now is better than never.

                      I keep forgetting that lots of people are using IE 9. I really wish M$ would just make it work.

                      The error was an "end if" that was in the wrong location.

                      My artwork is horrible, but the arrow shows the one I moved to the corrrect location.

                      I appreciated the help. It definitely shows me to be careful with nested if-thens



                      Gregg
                      https://paiza.io is a great site to test and share sql code

                      Comment


                        #12
                        Re: else doesn't fire

                        Ah yes. Sometimes I take a different approach, and just set each group of code off into it's own IF/END IF block. Do away with the ElseIF and other complicators completely.

                        The SELECT function is also very useful to help block this stuff off. To each his own - many ways to do this.
                        -Steve
                        sigpic

                        Comment


                          #13
                          Re: else doesn't fire

                          Us crotchety old people that were writing programs when the commodore vic20 was an upgrade are comfy with if-then statements.
                          I'll gladly checkout the select function.
                          Gregg
                          https://paiza.io is a great site to test and share sql code

                          Comment


                            #14
                            Re: else doesn't fire

                            Originally posted by madtowng View Post
                            Hi Steve,

                            I understand the busy thing. Just after I fixed the issue, I started getting calls about emails not coming in on time.
                            Meant to update this sooner, but I guess now is better than never.

                            I keep forgetting that lots of people are using IE 9. I really wish M$ would just make it work.

                            The error was an "end if" that was in the wrong location.

                            My artwork is horrible, but the arrow shows the one I moved to the corrrect location.

                            I appreciated the help. It definitely shows me to be careful with nested if-thens



                            [ATTACH=CONFIG]33376[/ATTACH]
                            I like to invert my if statement and fill with early returns. So instead of doing something like...

                            Code:
                            if (tc.datasubmitted.wilog01 <>"" .or. tc.datasubmitted.wilog02 <> "") then
                            	unsure = utccreate(tc.datasubmitted.delivery_time,val(tc.datasubmitted.delivery_offset),tc.datasubmitted.delivery_dst)
                            	if unsure = convert_type(tc.datasubmitted.wilog01,"T") then
                            		end
                            	end if
                            	'more code
                            end if
                            ...becomes...

                            Code:
                            if (tc.datasubmitted.wilog01 = "" .AND. tc.datasubmitted.wilog02 = "") then
                            	end
                            end if
                            
                            unsure = utccreate(tc.datasubmitted.delivery_time,val(tc.datasubmitted.delivery_offset),tc.datasubmitted.delivery_dst)
                            if unsure = convert_type(tc.datasubmitted.wilog01,"T") then
                            	end
                            end if
                            
                            'more code
                            Your daylight savings time code is oft repeated. Probably a function so that you can reuse it for both pickup_tz and delivery_tz... Saves you lines of code to read when debugging and maintenance costs when/if you ever need to change it:

                            Code:
                            if isutcdaylight(convert_type(tc._set.wilog01.value,"T"),-6) .and. tc.datasubmitted.delivery_tz+tc.datasubmitted.delivery_dst <> "CSTY" then
                              tc._setElement.DELFRAME.value = "Delivery : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog01.value,-6,"Y"))+" CDT"
                            elseif .not. isutcdaylight(convert_type(tc._set.wilog01.value,"T"),-6) .and. tc.datasubmitted.delivery_tz <> "CST" then
                              tc._setElement.DELFRAME.value = "Delivery : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog01.value,-6,"Y"))+" CST"
                            end if
                            Also, did you intend to write "end" or "end if" in the third to last code line:

                            Code:
                            ...
                            						else
                            							tc._set.wilog01.value = time("MM/dd/yyyy 0h:0m",utccreate(tc.datasubmitted.delivery_time,val(tc.datasubmitted.delivery_offset),tc.datasubmitted.delivery_dst))
                            							tc._set.showdzone.value = if(isutcdaylight(convert_type(tc._set.wilog01.value,"T"),val(tc.datasubmitted.delivery_offset)).and. tc.datasubmitted.delivery_dst="Y",left(tc.datasubmitted.delivery_tz,1)+"DT",tc.datasubmitted.delivery_tz)
                            							
                            							if isutcdaylight(convert_type(tc._set.wilog01.value,"T"),-6) .and. tc.datasubmitted.delivery_tz+tc.datasubmitted.delivery_dst <> "CSTY" then
                            								tc._setElement.DELFRAME.value = "Delivery : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog01.value,-6,"Y"))+" CDT"
                            							elseif .not. isutcdaylight(convert_type(tc._set.wilog01.value,"T"),-6) .and. tc.datasubmitted.delivery_tz <> "CST" then
                            								tc._setElement.DELFRAME.value = "Delivery : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog01.value,-6,"Y"))+" CST"
                            							end if
                            						end if
                            					
                            				end if
                            		
                            		[B][COLOR="#FF0000"]end[/COLOR][/B]
                            	end if
                            	
                            END FUNCTION
                            ---
                            Sarah
                            Alpha Anywhere latest pre-release

                            Comment


                              #15
                              Re: else doesn't fire

                              Hi Sarah,

                              I'm going to start with the easy stuff and work my way to the harder stuff.

                              The errant end statement served a purpose at one time, not that I can remember what it was.
                              I realized it wasn't doing anything and commented it out.




                              TheSmitchell;622861]I like to invert my if statement and fill with early returns. So instead of doing something like...

                              Code:
                              if (tc.datasubmitted.wilog01 <>"" .or. tc.datasubmitted.wilog02 <> "") then
                              	unsure = utccreate(tc.datasubmitted.delivery_time,val(tc.datasubmitted.delivery_offset),tc.datasubmitted.delivery_dst)
                              	if unsure = convert_type(tc.datasubmitted.wilog01,"T") then
                              		end
                              	end if
                              	'more code
                              end if
                              ...becomes...

                              Code:
                              if (tc.datasubmitted.wilog01 = "" .AND. tc.datasubmitted.wilog02 = "") then
                              	end
                              end if
                              
                              unsure = utccreate(tc.datasubmitted.delivery_time,val(tc.datasubmitted.delivery_offset),tc.datasubmitted.delivery_dst)
                              if unsure = convert_type(tc.datasubmitted.wilog01,"T") then
                              	end
                              end if
                              
                              'more code
                              The logic changes with the changes you made.
                              The way I had it,
                              Code:
                              if unsure = convert_type(tc.datasubmitted.wilog01,"T") then
                              fires only if
                              Code:
                              if (tc.datasubmitted.wilog01 = "" .AND. tc.datasubmitted.wilog02 = "")
                              This function is attached to the onChange events for pickup_time and delivery_time.
                              An unplanned action is the event fires no matter how the value is changed, either intentional or programatically.
                              This check to see if the date and time actually changed, if they did not, it ends the function.


                              Your daylight savings time code is oft repeated. Probably a function so that you can reuse it for both pickup_tz and delivery_tz... Saves you lines of code to read when debugging and maintenance costs when/if you ever need to change it:

                              Code:
                              if isutcdaylight(convert_type(tc._set.wilog01.value,"T"),-6) .and. tc.datasubmitted.delivery_tz+tc.datasubmitted.delivery_dst <> "CSTY" then
                                tc._setElement.DELFRAME.value = "Delivery : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog01.value,-6,"Y"))+" CDT"
                              elseif .not. isutcdaylight(convert_type(tc._set.wilog01.value,"T"),-6) .and. tc.datasubmitted.delivery_tz <> "CST" then
                                tc._setElement.DELFRAME.value = "Delivery : "+ timez("MM/dd/yyyy 0h:0m",utcreverse(tc._set.wilog01.value,-6,"Y"))+" CST"
                              end if

                              This part gets trickier.
                              There is a pickup div that should only say pickup if the pickup time and milwaukee time are the same (date, time, timezone, and offset), otherwise the div should also have the equivelant Milwaukee time.

                              The same process applies to the delivery time div.
                              isutcdaylight(),utccreate(), and utcreverse() are all functions I wrote to make things easier to read as well as debug.

                              One thing I have learned about xbasic from this is that each If only requires one end if, regardless of how many elseif or else statements appear betwen them.
                              It's a fact that I did not realize when I started this function.

                              I do appreciated your input, as I am always looking for easier/better ways to make things work.
                              Gregg
                              https://paiza.io is a great site to test and share sql code

                              Comment

                              Working...
                              X