AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

omitting ( ) in expression if statements? & scite annoy

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Mon Mar 08, 2010 5:56 am    Post subject: omitting ( ) in expression if statements? & scite annoy Reply with quote

Hello. Three questions, please.
The help file says "the open-parenthesis may be omitted entirely if the first item after the word "if" is...an operator such as "not" or "!". "

1. I'd like to know if I can also use || operator to omit the parenthesis?
eg
Code:
if || var=1 {
}

instead of
Code:
if (var=1) {
}


I know I can just type if var = 1, but I want to use the one true brace style. I did a few successful tests with this, but would like to know if it will always work?


2. In scite, when the caret is to the right of a closing brace, and you press enter, it will move the closing brace to the left. How do I stop this?

3. I was wondering what kind of programming language the scite setting files were written in. Is it LUA? Can I do a quick google search to figure out what the $ signs do?
The lines look like this:
autocomplete.ahk1.start.characters=$(chars.alpha)$(chars.numeric)$_@#


Thanks for your help.
Back to top
[VxE]



Joined: 07 Oct 2006
Posts: 3254
Location: Simi Valley, CA

PostPosted: Mon Mar 08, 2010 6:25 am    Post subject: Reply with quote

It may consistently work, but that doesn't make it 'correct'. If you absolutely must avoid parentheses in an if statement, you could just slap a unary-plus on the leading operand of the expression.
Code:
var = some text
If +var = var ; this is only true if it is an expression-if
   msgbox % +var ; this shows that the unary-plus leaves the operand unaltered.

For the record, I recommend that you just use the parentheses.

(I don't use scite, so I can't help with #2/#3)
_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!
Back to top
View user's profile Send private message
Guest






PostPosted: Mon Mar 08, 2010 6:26 am    Post subject: Reply with quote

I forgot about using % to force an expression.
for example
Code:
If % var=1 && var2 = 2

worked after a few tests. So is it okay to use % instead of ( ) when I want expressions in my if statement?
Back to top
lexikos*
Guest





PostPosted: Mon Mar 08, 2010 7:01 am    Post subject: Reply with quote

changelog wrote:
1.0.48.04 - September 25, 2009
...
Added full support for "if % expression". [thanks kenomby]

if expression works without parentheses as long as expression doesn't match the format of a traditional IF, like if var=1 || var=2 *(where "1 || var=2" is treated as literal text).
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Mon Mar 08, 2010 10:14 am    Post subject: Reply with quote

#2: Look at SciTE Documentation, particularly indent.opening option.

#3: No, that's not Lua (even less LUA as that's not an acronym).
Base of the format is inspired from Java's properties files.
The $(xxx) is actually substituted by the value of the xxx property.
Ie. if you have:
chars.alpha=abc
chars.numeric=123
autocomplete.ahk1.start.characters will be abc123$_@#
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Tue Mar 09, 2010 12:55 pm    Post subject: Reply with quote

For question 2., I actually had to comment out this line (put a # in front) in the ahk.properties file:
#extension.$(file.patterns.ahk)=$(SciteDefaultHome)\ahk.lua

The description above it says:
"# Lua extension definition - script for AutoIndent, Abbreviation support and Indentation checker"

Also, if you are tired of scite's autocomplete box popping up, here is one way I know of to stop it. Put a # in front of this line:
autocomplete.ahk1.start.characters=$(chars.alpha)$(chars.numeric)$_@#
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group