Jump to content

Do..Until


Recommended Posts

Does the Do command not work with functions? because when i put a function in i get an error that says the Do statement does not have an Until statement.

My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]
Link to comment
Share on other sites

For example

HotKeySet("!t", "time")
$i = 0
Do
   Func time()
      $hour=@hour
      If $hour > 12 Then
         $hour = $hour - 12
      EndIf
      $sec=@sec
      $min=@min
      MsgBox(0, "Time", "The time is: "& $hour&":"&$min&":"& $sec)
   EndFunc
Until $i = 1

[Edit]

Well for that i dont need the do until but it still give the same error

Edited by the_lord_mephy
My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]
Link to comment
Share on other sites

Functions are nothing but coding structures... they are there so you can pull code that you repeat in your scripts and only type it once... well maybe I can show you better with your code. I don't understand what you are trying to accomplish with your code but I will do my best to assist you.

If you want the application to sit and wait until the "Alt + T" ket combination is pressed, then you would want to do something like this:

HotKeySet("!t", "time")

; Loop inifinitly
While 1
   Sleep(10)
WEnd

Func time()
   $hour=@hour
   If $hour > 12 Then
      $hour = $hour - 12
   EndIf
   $sec=@sec
   $min=@min
   MsgBox(0, "Time", "The time is: "& $hour&":"&$min&":"& $sec)
EndFunc

You may also consider adding an exit key combination, such as, 'ALT + Q', so there is a way to kill the script. That would look something like this:

HotKeySet("!t", "time")
HotKeySet("!q", "ExitNow" )

; Loop inifinitly
While 1
   Sleep(10)
WEnd

Func time()
   $hour=@hour
   If $hour > 12 Then
      $hour = $hour - 12
   EndIf
   $sec=@sec
   $min=@min
   MsgBox(0, "Time", "The time is: "& $hour&":"&$min&":"& $sec)
EndFunc

Func ExitNow()
   Exit
EndFunct

I hope that helps! Happy Posting!

*** Matt @ MPCS

EDIT: Changed the while loop per Jon's comment.

Edited by Matt @ MPCS
Link to comment
Share on other sites

Thanks for telling me how to do the tid bit on launching a script but making it wait till I pressed a button. I was just browsing while contemplating how to put my problem when I ran across this. Thanks.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...