Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

If and or syntax


  • Please log in to reply
6 replies to this topic

#1 Docfxit

Docfxit

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 310 posts

Posted 19 July 2010 - 01:51 AM

I have an If statement that I am getting an error on. The error is on the Or statement

If $title = "Mozilla Firefox Setup " And $TextLine[8] = "C:\Program Files\Mozilla Firefox\" Or                  ;32bit     $title = "Mozilla Firefox Setup " And $TextLine[8] = "C:\Program Files(x86)\Mozilla Firefox\" Then      ;64bit ;Something I do when it's correct ElseIf $title = "Mozilla Firefox Setup " And $TextLine[8] = $ProgramFiles & "FireFox\" Then ;Something I do when it's not correct Else ;It didn't find what it's supposed to EndIf

Edited by docfxit, 19 July 2010 - 02:05 AM.








#2 seandisanti

seandisanti

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,927 posts

Posted 19 July 2010 - 02:29 AM

I have an If statement that I am getting an error on. The error is on the Or statement

If $title = "Mozilla Firefox Setup " And $TextLine[8] = "C:\Program Files\Mozilla Firefox\" Or                  ;32bit     $title = "Mozilla Firefox Setup " And $TextLine[8] = "C:\Program Files(x86)\Mozilla Firefox\" Then      ;64bit ;Something I do when it's correct ElseIf $title = "Mozilla Firefox Setup " And $TextLine[8] = $ProgramFiles & "FireFox\" Then ;Something I do when it's not correct Else ;It didn't find what it's supposed to EndIf

may want to use parentheses to group your conditions, what exactly is the error you're getting?
1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

#3 Docfxit

Docfxit

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 310 posts

Posted 19 July 2010 - 02:38 AM

may want to use parentheses to group your conditions, what exactly is the error you're getting?


Sorry I didn't include the exact wording. It says.

Error: "If" statements must have a Then Keyword.

It's stopping on the line with the Or at the end.

Thanks,

Docfxit

#4 Docfxit

Docfxit

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 310 posts

Posted 19 July 2010 - 02:53 AM

I fixed two errors.

If ($title = "Mozilla Firefox Setup " And $TextLine[8] = "C:\Program Files\Mozilla Firefox\" Or ($title = "Mozilla Firefox Setup " And $TextLine[8] = "C:\Program Files (x86)\Mozilla Firefox\") Then ;Something I do when it's correct ElseIf $title = "Mozilla Firefox Setup " And $TextLine[8] = $ProgramFiles & "FireFox\" Then ;Something I do when it's not correct Else ;It didn't find what it's supposed to EndIf  


One error I fixed is I put both lines onto one line. I guess I don't know how to continue a statement onto a second line.
Second I didn't have a space before (x86) "C:\Program Files (x86)"

It's fixed now.

Thanks,

Docfxit

Edited by docfxit, 19 July 2010 - 03:15 AM.


#5 somdcomputerguy

somdcomputerguy

  • Active Members
  • PipPipPipPipPipPip
  • 2,850 posts

Posted 19 July 2010 - 04:15 AM

..I guess I don't know how to continue a statement onto a second line.

Use & _ (ampersand, space, underscore)
$string = "This is text that's not really too long, and, " & _ "This is more text" ConsoleWrite($string & @LF) ; This may work.. If ($title = "Mozilla Firefox Setup " And $TextLine[8] = "C:\Program Files\Mozilla Firefox\" Or & _     ($title = "Mozilla Firefox Setup " And $TextLine[8] = "C:\Program Files (x86)\Mozilla Firefox\") Then

Edited by somdcomputerguy, 19 July 2010 - 04:22 AM.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.


#6 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 10,295 posts

Posted 19 July 2010 - 05:11 AM

You only use the & when you want to concatenate two strings. _ alone is how you continue lines. It just has to be the last non-comment character on the line.

#7 somdcomputerguy

somdcomputerguy

  • Active Members
  • PipPipPipPipPipPip
  • 2,850 posts

Posted 19 July 2010 - 06:18 AM

Thanks for clarifying.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users