randd Posted June 4, 2004 Share Posted June 4, 2004 (edited) I've writen some test code that is supposed to: Ask user to run, if cancel exit. If run ask user for starting date. If no date entered let user know and offer to run with current date or cancel to halt. If a startdate is given, or the default of current date is used ask user enddate. If no enddate entered let user nkow and offer to run with current date or cancel to halt. If an enddate is given, or the default of the current date is used print the enddate. I can only get my code to print out the startdate (first if statement is OK then i think). If I give an enddate the code appears to simlpy end. If I cancel when asked for an end date the code runs as expected. Somewhere i think I've messed up my If statements. Can someone take a quick glance and let me know where I've screwed up? expandcollapse popup;Note: If "classname=", "handle=", "active", "last" or "" are not used as the title ;then the window matching takes place as in Mode 1 making this a good mode for general use. Opt("WinTitleMatchMode", 4) ;Alters the length of the brief pause in between mouse clicks. ;Time in milliseconds to pause (default=10). Opt("MouseClickDelay", 20) ;Prompt the user to run the script - use a Yes/No prompt $answer = MsgBox(4, "Question", "Run the script?") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(4096, "Error", "Execution halted.") Exit EndIf ;send popup asking for last date mm/dd/yyyy hh:mm $startdate = InputBox("Question", "Start Date? (format: mm/dd/yyyy)", "", "") ; Run Notepad Run("notepad.exe") ; Wait for the Notepad become active WinWaitActive("Untitled - Notepad") ; make sure to set startdate to be a string $startdate = String($startdate) If $startdate = "" then; if startdate blank go through and use today's date $startdateanswer = MsgBox(4, "Question", "No Value Entered. Use today's date?") If $startdateanswer = 7 Then MsgBox(4096, "Error", "Execution halted.") EXIT Else $startdate = @MON & @MDAY & @YEAR; set start date to today (set up formatting later) EndIf EndIf ; testign startdate value Send($startdate) $enddate = InputBox("Question", "Ending Date? (format: mm/dd/yyyy)", "", "") $enddate = String($enddate) If $enddate = "" then $enddateanswer = MsgBox(4, "Question", "No Value Entered. Use today's date?") If $enddateanswer = 7 Then MsgBox(4096, "Error", "Execution halted.") EXIT Else $enddate = @MON & @MDAY & @YEAR EndIf Send($enddate) EndIf Send("end of first If statement") Thanks! PS My indents don't appear to have been properly copied... I'm sure someone is going to let me know what I should do to fix that next time I post some code. Edited June 4, 2004 by Larry Raoul S. Duke: Few people understand the psychology of dealing with a highway traffic cop. Your normal speeder will panic and immediately pull over to the side. This is wrong. It arouses contempt in the cop-heart. Make the bastard chase you. He will follow. Link to comment Share on other sites More sharing options...
pekster Posted June 4, 2004 Share Posted June 4, 2004 (edited) Sure, the problem is in your 2nd to the last If statement. You'll notice that the Send($enddate) command is only run if $enddate = "". It will never display anything since it has two options: exit without sending the text, or sending a blank string.Side note: when I ran your code, I had to include a WinActivate("Untitled - Notepad") command before the final send (after I moved it outside of your If statement.) You might consider using ControlSend so that this isn't an issue in the future.Edited to correct a command I typed when I should have typed a different command Edited June 4, 2004 by pekster [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
randd Posted June 4, 2004 Author Share Posted June 4, 2004 Dumb mistake on my part. Also, thanks for the reference. I hadn't used any of those controls before. I started reviewing them. Looks to be a good way for me to go with some other parts of the code as well. Thanks! Raoul S. Duke: Few people understand the psychology of dealing with a highway traffic cop. Your normal speeder will panic and immediately pull over to the side. This is wrong. It arouses contempt in the cop-heart. Make the bastard chase you. He will follow. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now