| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Mon Mar 08, 2010 5:56 am Post subject: omitting ( ) in expression if statements? & scite annoy |
|
|
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
instead of
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
|
Posted: Mon Mar 08, 2010 6:25 am Post subject: |
|
|
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 |
|
 |
Guest
|
Posted: Mon Mar 08, 2010 6:26 am Post subject: |
|
|
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
|
Posted: Mon Mar 08, 2010 7:01 am Post subject: |
|
|
| 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)
|
Posted: Mon Mar 08, 2010 10:14 am Post subject: |
|
|
#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 |
|
 |
Guest
|
Posted: Tue Mar 09, 2010 12:55 pm Post subject: |
|
|
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 |
|
 |
|