Jump to content

Recommended Posts

Use a split string function.

; this format  10:20:30
while 1
$answer = InputBox("Question", "What time."&@crlf&"10:20:30 format please", "10:20:30", "", -1, -1, 0, 0)
$answer1=Stringsplit($answer,":")
if IsArray ($answer1) then if $answer1[0]=3 then exitloop
wend

msgbox(1,$answer,$answer1[1]&" "&$answer1[2]&" "&$answer1[3])

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to post
Share on other sites

Thanks Scriptkitty that work great

I just spent 30 min trying to understand what you did. I think i understand now

Your spliting the string by : and storing the results into a array. Then your using the last ":" to create the exit from the loop

Is that right it is important that i understand because I need to learn

Edited by vickerps
Link to post
Share on other sites

You got it pretty much.

Code explained.

; this format  10:20:30
while 1  
;this is an endless loop, the Exit loop command jumps out of it.
$answer = InputBox("Question", "What time."&@crlf&"10:20:30 format please", "10:20:30", "", -1, -1, 0, 0)
; this asks the user for the proper input
$answer1=Stringsplit($answer,":")
;This creates an array automatically delimited by the : and assigns the number of
; elements besides itself to  $answer1[0]
if IsArray ($answer1) then if $answer1[0]=3 then exitloop
; if it became an array, and then if the array has 4 elements (3 + $answer1[0]) it jumps out of the loop and continues past wend
wend
; if no exitloop is found, it repeats again.
msgbox(1,$answer,$answer1[1]&" "&$answer1[2]&" "&$answer1[3])
; displays data for you, you could do anything you want from this point.

AutoIt3, the MACGYVER Pocket Knife for computers.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...