wanted execute 2 commands part of single-line if statement mentioned below.
though below snippet executing without error, variable $f_akr_completed not set 1 msgbox displayed properly(with "f 0")
$f_akr_completed =0 $pid_chi=run($command) if $f_akr_completed = 0 , not processexists($pid_chi) $f_akr_completed = 1 , msgbox(1,1,"[info] akron parser completed. f " & $f_akr_completed) any idea why there no syntax-error reported when not funtional?
there no error, because
if x = x x , x is valid statement, , x , x logical expression. there many ways can this, e.g.:
if not ($f_akr_completed , processexists($pid_chi)) $f_akr_completed = 1 + 0 * msgbox(1,1,"[info] akron parser completed. f " & 1) but bad style of coding. autoit verbose language , recommend seperate multiple statements.
you can assign values using ternary operator:
$f_akr_completed = (not ($f_akr_completed , processexists($pid_chi))) ? 1 : 0 which same as
$f_akr_completed = int(not ($f_akr_completed , processexists($pid_chi)))
Comments
Post a Comment