Jump to content
Sign in to follow this  
apache

if then statement

Recommended Posts

apache

hi there,

i wana use

if then, else if statement. i put this

If ProcessExists (help.Exe) Then

MsgBox(4096,"", "Value might be hexadecimal!")

Else

ShellExecute ("help.exe")

EndIf

simply i want my application to do nothing if the help.exe in alredy opened, but it uses condition MsgBox(4096,"", "Value might be hexadecimal!"). please tell me how i can fix it.

Share this post


Link to post
Share on other sites
Skruge

If you don't want it to do anything under one condition, then you don't need an else.

If Not ProcessExists("help.exe") then ShellExecute("help.exe")

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites
apache

actually if the help file is already opened, it should not do anything. and if not opened then it should open help.exe through shell execute.

If you don't want it to do anything under one condition, then you don't need an else.

If Not ProcessExists("help.exe") then ShellExecute("help.exe")

Share this post


Link to post
Share on other sites
SpookMeister

skruge's solution does what you are asking.

Alternatively you could also simply comment out (or delete) the MsgBox line:

If ProcessExists(help.Exe) Then
    ;MsgBox(4096, "", "Value might be hexadecimal!")
Else
    ShellExecute("help.exe")
EndIf

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
youknowwho4eva

I wanna try

If ProcessExists("help.exe") = 0 then ShellExecute("help.exe")

Giggity

Share this post


Link to post
Share on other sites
apache

leaving blank msg box do not show any msg. :D wen i del the complete msg box line, it show the error for then condition

is there any command to pause script?

no way without box?

:o

skruge's solution does what you are asking.

Alternatively you could also simply comment out (or delete) the MsgBox line:

If ProcessExists(help.Exe) Then
    ;MsgBox(4096, "", "Value might be hexadecimal!")
Else
    ShellExecute("help.exe")
EndIf

Share this post


Link to post
Share on other sites
youknowwho4eva

If you just want to pause it for a set period of time use sleep()

If you want to pause it till a certain condition

while $condition = false

sleep(100)

wend

or

do

sleep(100)

untill $condition = true


Giggity

Share this post


Link to post
Share on other sites
apache

@ youknowwho

i wana use shell execute as a "else" statement

this (If ProcessExists("help.exe") = 0 then ShellExecute("help.exe)

shows this

C:\Documents and Settings\vindos\Desktop\new.au3(1,52) : ERROR: syntax error (illegal character)

If ProcessExists("help.exe") = 0 then ShellExecute("

:D

Share this post


Link to post
Share on other sites
youknowwho4eva

Your missing a "

this (If ProcessExists("help.exe") = 0 then ShellExecute("help.exe")

Edited by youknowwho4eva

Giggity

Share this post


Link to post
Share on other sites
apache

i've been using "" :D

sleep(100)

untill $condition = true

it will just make sleep for some moments

what if i use

sleep(2147483647) for 24 day?????

lol

Share this post


Link to post
Share on other sites
youknowwho4eva

no a do until loop will sleep until the set condition is true. What ever you want to set that condition to.

Same with the while loop except inverse. It will repeat the sleep until the condition is no longer not true (so I guess not inverse)


Giggity

Share this post


Link to post
Share on other sites
apache

can u paste my complete script with your idea

actually i cant understand

$condition=true

here

If ProcessExists("help.Exe") Then

sleep(100)

untill $condition=true

Else

ShellExecute("help.exe")

EndIf

is it correct?

Share this post


Link to post
Share on other sites
Jos

can u paste my complete script with your idea

actually i cant understand

$condition=true

here

If ProcessExists("help.Exe") Then

sleep(100)

untill $condition=true

Else

ShellExecute("help.exe")

EndIf

is it correct?

Try learning some programming/scrip basics before starting to script.

Open the helpfile and look at the commands used in your little piece of code and sort out what is wrong.

Learn....

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
apache

i've been learning for a long time to solve it. now im fedup thats why im asking here.

Share this post


Link to post
Share on other sites
Jos

i've been learning for a long time to solve it. now im fedup thats why im asking here.

Don't make your impatience our problem.

*click*

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×