AutoHotkey Community

It is currently May 27th, 2012, 4:40 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: March 8th, 2010, 6:56 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2010, 7:25 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2010, 7:26 am 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2010, 8:01 am 
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).


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2010, 11:14 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
#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$_@#

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 1:55 pm 
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)$_@#


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, Bing [Bot], rbrtryn, Yahoo [Bot] and 69 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group