Jump to content
Sign in to follow this  
blitzkrg

noob question

Recommended Posts

I consider myself 'advanced' when it comes to using autoit2

and i put off autoit3 for a long time. but finally had to cave and try and learn it.

it's slow going, but i managed to write several small scripts to parse some data that i couldnt get done with v2.

now i'm trying to write a more complicated script just for learning purposes..

i keep running into issues and cant seem to figure them out.. the help file, while very full of information isnt very comprehensive.. it assumes you know how to "code" and learning from the ground up is difficult.

i'm trying to write a "countdown" script with a combo box dropdown.

i've got a bunch of issues, that i hope to work through on my own.. i would prefer to figure it out on my own, since i think this is the best way to learn.

but here is an example of a problem i have. that i cant solve by looking at the help file.

Do
   $msg = GUIGetMsg()
   If $msg = "Item1" Then 
   blah()
   else
 If $msg = "Item2" Then 
   blah2()
 EndIf
Until $msg = $GUI_EVENT_CLOSE

i constantly get this error

"Error: "Until" statement with no matching "Do" statement.

i cant understand why this happens..

i tried

While 1

Wend

but i get "Error: "Wend" statement with no matching "While" statement

why does this happen and how do i fix it?

thanks

Share this post


Link to post
Share on other sites

Larry's examples are how todo it correctly.

Your If blocks should be in one of these patterns.

If  Then

or

If  Then
EndIf

or

If  Then
Else
EndIf

or

If  Then
ElseIf
EndIf

or

If  Then
ElseIf
Else
Endif

but your code is

If  Then
Else
If  Then
EndIf
The Until error, was caused as to the If block, being an incorrect structure. Edited by MHz

Share this post


Link to post
Share on other sites

edit: funny i tested my "posted script" (below) and it didnt do that IF/DO error. must ge something wrong with my original.. but if you run my posted script, you'll see it runs away..

thanks

------------------------------------

thanks for the info guys..

but i think the error

"Error: "Until" statement with no matching "Do" statement.

is mis-informative?

the matching DO statement was there..

maybe it should say "error: invalid format or something..

I tried your second option MHz

IF Then

EndIF

now i get the IF has no matching EndIf statment..

maybe i should show you want i'm after and you can tell me the properway to go about doing it.

basially what i'm trying to accomplish is to create a countdown script, with multiple events.

so i want a drop down box to pick the event and when you pick the event, it calls a function to do the math

i can create the gui, i can create the function and get the math done..

and i even had this working with

the guigetmsg() thing.. but on my screen, each event was showed one after another and wouldnt stop..

also as the math was being done (i.e. the seconds were showing) my gui flickered..

and since you cant add a sleep command or else the script wont respond, i was ready to settle for just having a static display (as in you cant see the time going, just what it was when you clicked the event)

but now i cant get this stuff working since i keep getting "your do doesnt exist" errors

here is a sample of what i'm trying to do..

like i said this is pretty much my 1st time at this.. so i'm sure there are better ways to do it..

thanks for looking into it.

#include <Date.au3>
#include <GUIConstants.au3>
; Opt("GUIOnEventMode", 1)
GUICreate("2005 Season Countdown", 250, 200)
GUICtrlCreateCombo ("", 10,10); create first item
GUICtrlSetData(-1,"event 1|event 2|event 3","event 1")
; GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$lndow = _DateDayOfWeek(@WDAY)
$edate = _DateTimeFormat(_NowCalc(),1)
$lang1 = " At "
GUISetState ()

Do
   $msg = GUIGetMsg()

   If $msg = $GUI_EVENT_CLOSE Then 
   CLOSEClicked()
   Endif
   If $msg = "event 1" then
   ste()
   Endif
   If $msg = "event 2" then
   ste2()
   Endif
   If $msg = "event 3" then
   ste3()
   Endif

Until $msg = $GUI_EVENT_CLOSE


Func CLOSEClicked()
  Exit
EndFunc

Func ste()
$stdes = _DateDiff( 's',_NowCalc(),"2005/05/05 20:00:00")
$stdem = round ($stdes / 60, -1)
$stdeh = round ($stdem / 60, -1)
$stded = round ($stdeh / 24, 1)
$stdew = round ($stded / 7, -1)
$stdemn = _DateDiff( 'M',_NowCalc(),"2005/05/05 20:00:00")
; if $stdes <= 0 then steo()
GUICtrlCreateLabel("It is now " & $edate & $lang1 & _NowTime(), 10, 40)
GUICtrlCreateLabel("Scheduled to end at 12pm 05/05/2005", 10, 60)
GUICtrlCreateLabel($stdes & " seconds", 10, 180)
GUICtrlCreateLabel($stdem & " minutes or", 10, 160)
GUICtrlCreateLabel($stdeh & " hours or", 10, 140)
GUICtrlCreateLabel($stded & " days or", 10, 120)
GUICtrlCreateLabel($stdew & " weeks or", 10, 100)
GUICtrlCreateLabel($stdemn & " months or", 10, 80)
; sleep (1000)
EndFunc

Func ste2()
$stdes = _DateDiff( 's',_NowCalc(),"2005/06/06 20:00:00")
$stdem = round ($stdes / 60, -1)
$stdeh = round ($stdem / 60, -1)
$stded = round ($stdeh / 24, 1)
$stdew = round ($stded / 7, -1)
$stdemn = _DateDiff( 'M',_NowCalc(),"2005/06/06 20:00:00")
; if $stdes <= 0 then steo()
GUICtrlCreateLabel("It is now " & $edate & $lang1 & _NowTime(), 10, 40)
GUICtrlCreateLabel("Scheduled to end at 12pm 06/06/2005", 10, 60)
GUICtrlCreateLabel($stdes & " seconds", 10, 180)
GUICtrlCreateLabel($stdem & " minutes or", 10, 160)
GUICtrlCreateLabel($stdeh & " hours or", 10, 140)
GUICtrlCreateLabel($stded & " days or", 10, 120)
GUICtrlCreateLabel($stdew & " weeks or", 10, 100)
GUICtrlCreateLabel($stdemn & " months or", 10, 80)
; sleep (1000)
EndFunc

Func ste3()
$stdes = _DateDiff( 's',_NowCalc(),"2005/07/07 20:00:00")
$stdem = round ($stdes / 60, -1)
$stdeh = round ($stdem / 60, -1)
$stded = round ($stdeh / 24, 1)
$stdew = round ($stded / 7, -1)
$stdemn = _DateDiff( 'M',_NowCalc(),"2005/07/07 20:00:00")
; if $stdes <= 0 then steo()
GUICtrlCreateLabel("It is now " & $edate & $lang1 & _NowTime(), 10, 40)
GUICtrlCreateLabel("Scheduled to end at 12pm 07/07/2005", 10, 60)
GUICtrlCreateLabel($stdes & " seconds", 10, 180)
GUICtrlCreateLabel($stdem & " minutes or", 10, 160)
GUICtrlCreateLabel($stdeh & " hours or", 10, 140)
GUICtrlCreateLabel($stded & " days or", 10, 120)
GUICtrlCreateLabel($stdew & " weeks or", 10, 100)
GUICtrlCreateLabel($stdemn & " months or", 10, 80)
; sleep (1000)
EndFunc
Edited by blitzkrg

Share this post


Link to post
Share on other sites

thanks for the info guys..

but i think the error

"Error: "Until" statement with no matching "Do" statement.

is mis-informative?

the matching DO statement was there..

maybe it should say "error: invalid format or something..

<{POST_SNAPBACK}>

When you have these kind of issues and you have problems finding it, it often helps to run it throught Tidy....

This is the output generated by Tidy and shows the issue:

Do
    $msg = GUIGetMsg()
    If $msg = "Item1" Then
        blah ()
    Else
        If $msg = "Item2" Then
            blah2 ()
        EndIf
;### Tidy Error: Level error -> Until is closing previous If
    Until $msg = $GUI_EVENT_CLOSE
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

thanks for the info guys..

but i think the error

"Error: "Until" statement with no matching "Do" statement.

is mis-informative?

the matching DO statement was there..

maybe it should say "error: invalid format or something..

<{POST_SNAPBACK}>

I've noticed that too in the past - but I rarley see such an error now that the SciTE editor has so many checks built in.

I see no formating errors in your script - the Scite tools thought that it was okay also. You said, "now i get the IF has no matching EndIf statment..", but posted script runs for me just fine. Yes, I see the flicker and I see a few other problems, but I'm not into GUI yet so can't be of much help - other than to say - search the forum for flicker and you will get returns...


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

i posted an edit at the top of the post, to note that i didnt get the IF/DO error on the script i posted (i trimmed my original and made a few edit's to clean it up) so maybe i removed a line or something that fixed the IF/do error.. i was pleased that it didnt do that, but you saw the other problems sooooo..

i'm not familar with TIDY or SCiTE

but if they will help then i'll look into them.

although as herewasplato pointed out, it noted no errors, i'm not sure what use it will be...

Share this post


Link to post
Share on other sites

....you saw the other problems sooooo..

<{POST_SNAPBACK}>

My error - I thought that the dates rolling from 05/05 to 06/06 to 07/07 was a bug, but realized later that it was just the sample dates associated with the 3 events.

i'm not familar with TIDY or SCiTE

but if they will help then i'll  look into them.

although as herewasplato pointed out, it noted no errors, i'm not sure what use it will be...

<{POST_SNAPBACK}>

The tools in SciTE might point out the errors before running the script - in my case, it prevents me from having to set several conditions (windows and data) back to their starting states to retest a script - it seems that some errors only show when the AutoIt program goes to execute those lines of code. "SciTe and company" seems to find most (all?) before hand.

And I am very good at hiding errors in my code... it seems to be a game that I play with AutoIt3......................later


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...