Leaderboard
Popular Content
Showing content with the highest reputation on 02/16/2014 in all areas
-
IfExtend.au3 - include file for enabling shorter scripts
mesale0077 and one other reacted to this-is-me for a topic
Although my documentation of these functions is not very good, I feel that others may benefit from this include. I always enjoyed coding in Javascript because I could do single-line if-then-else statements. I also always wanted a way to compare a single variable with multiple values. Ternary operations have brought me closer to this goal, but there is yet a distance to go. These functions should help others to make shorter code. IfExtend.au3 #include-once ; IfThenElse - A one-line If Then Else EndIf statement for code shortening. It allows for one function with parameters if true, one function with parameters if false ; ; IfThenElse(expression to test, value to test against, Function 1, [Function 1 parameters wrapped with param(), [Function 2, [Function 2 parameters wrapped with param()]]]) ; ; Usage example: ; IfThenElse($sky = "falling", MsgBox, param(0, "", "Sky is falling"), MsgBox, param(0, "", "Sky is not falling")) ; ; param(..., ..., ...) is for a list of parameters to be passed to the functions. Func IfThenElse($test, $func1, $params1 = Null, $func2 = Null, $params2 = Null) If $test Then If $params1 = Null Then Return $func1() Else Return Call(FuncName($func1), $params1) EndIf Else If $func2 = Null Then Return -1 If $params2 = Null Then Return $func2() Else Return Call(FuncName($func2), $params2) EndIf EndIf EndFunc Func param($1=0, $2=0, $3=0, $4=0, $5=0, $6=0, $7=0, $8=0, $9=0, $10=0, $11=0, $12=0, $13=0, $14=0, $15=0, $16=0, $17=0, $18=0, $19=0, $20=0, $21=0, $22=0, $23=0, $24=0, $25=0, $26=0, $27=0, $28=0, $29=0, $30=0, $31=0, $32=0, $33=0, $34=0, $35=0, $36=0, $37=0, $38=0, $39=0, $40=0, $41=0, $42=0, $43=0, $44=0, $45=0, $46=0, $47=0, $48=0, $49=0, $50=0, $51=0, $52=0, $53=0, $54=0, $55=0, $56=0, $57=0, $58=0, $59=0, $60=0, $61=0, $62=0, $63=0, $64=0, $65=0, $66=0, $67=0, $68=0, $69=0, $70=0, $71=0, $72=0, $73=0, $74=0, $75=0, $76=0, $77=0, $78=0, $79=0, $80=0, $81=0, $82=0, $83=0, $84=0, $85=0, $86=0, $87=0, $88=0, $89=0, $90=0, $91=0, $92=0, $93=0, $94=0, $95=0, $96=0, $97=0, $98=0, $99=0, $100=0, $101=0, $102=0, $103=0, $104=0, $105=0, $106=0, $107=0, $108=0, $109=0, $110=0, $111=0, $112=0, $113=0, $114=0, $115=0, $116=0, $117=0, $118=0, $119=0, $120=0, $121=0, $122=0, $123=0, $124=0, $125=0, $126=0, $127=0, $128=0, $129=0, $130=0, $131=0, $132=0, $133=0, $134=0, $135=0, $136=0, $137=0, $138=0, $139=0, $140=0, $141=0, $142=0, $143=0, $144=0, $145=0, $146=0, $147=0, $148=0, $149=0, $150=0, $151=0, $152=0, $153=0, $154=0, $155=0, $156=0, $157=0, $158=0, $159=0, $160=0, $161=0, $162=0, $163=0, $164=0, $165=0, $166=0, $167=0, $168=0, $169=0, $170=0, $171=0, $172=0, $173=0, $174=0, $175=0, $176=0, $177=0, $178=0, $179=0, $180=0, $181=0, $182=0, $183=0, $184=0, $185=0, $186=0, $187=0, $188=0, $189=0, $190=0, $191=0, $192=0, $193=0, $194=0, $195=0, $196=0, $197=0, $198=0, $199=0, $200=0, $201=0, $202=0, $203=0, $204=0, $205=0, $206=0, $207=0, $208=0, $209=0, $210=0, $211=0, $212=0, $213=0, $214=0, $215=0, $216=0, $217=0, $218=0, $219=0, $220=0, $221=0, $222=0, $223=0, $224=0, $225=0, $226=0, $227=0, $228=0, $229=0, $230=0, $231=0, $232=0, $233=0, $234=0, $235=0, $236=0, $237=0, $238=0, $239=0, $240=0, $241=0, $242=0, $243=0, $244=0, $245=0, $246=0, $247=0, $248=0, $249=0, $250=0, $251=0, $252=0, $253=0, $254=0, $255=0) Local $arr[@NumParams + 1] = ["CallArgArray"] For $i = 1 To @NumParams $arr[$i] = Eval($i) Next Return $arr EndFunc Func MultiOr($value, $2=0, $3=0, $4=0, $5=0, $6=0, $7=0, $8=0, $9=0, $10=0, $11=0, $12=0, $13=0, $14=0, $15=0, $16=0, $17=0, $18=0, $19=0, $20=0, $21=0, $22=0, $23=0, $24=0, $25=0, $26=0, $27=0, $28=0, $29=0, $30=0, $31=0, $32=0, $33=0, $34=0, $35=0, $36=0, $37=0, $38=0, $39=0, $40=0, $41=0, $42=0, $43=0, $44=0, $45=0, $46=0, $47=0, $48=0, $49=0, $50=0, $51=0, $52=0, $53=0, $54=0, $55=0, $56=0, $57=0, $58=0, $59=0, $60=0, $61=0, $62=0, $63=0, $64=0, $65=0, $66=0, $67=0, $68=0, $69=0, $70=0, $71=0, $72=0, $73=0, $74=0, $75=0, $76=0, $77=0, $78=0, $79=0, $80=0, $81=0, $82=0, $83=0, $84=0, $85=0, $86=0, $87=0, $88=0, $89=0, $90=0, $91=0, $92=0, $93=0, $94=0, $95=0, $96=0, $97=0, $98=0, $99=0, $100=0, $101=0, $102=0, $103=0, $104=0, $105=0, $106=0, $107=0, $108=0, $109=0, $110=0, $111=0, $112=0, $113=0, $114=0, $115=0, $116=0, $117=0, $118=0, $119=0, $120=0, $121=0, $122=0, $123=0, $124=0, $125=0, $126=0, $127=0, $128=0, $129=0, $130=0, $131=0, $132=0, $133=0, $134=0, $135=0, $136=0, $137=0, $138=0, $139=0, $140=0, $141=0, $142=0, $143=0, $144=0, $145=0, $146=0, $147=0, $148=0, $149=0, $150=0, $151=0, $152=0, $153=0, $154=0, $155=0, $156=0, $157=0, $158=0, $159=0, $160=0, $161=0, $162=0, $163=0, $164=0, $165=0, $166=0, $167=0, $168=0, $169=0, $170=0, $171=0, $172=0, $173=0, $174=0, $175=0, $176=0, $177=0, $178=0, $179=0, $180=0, $181=0, $182=0, $183=0, $184=0, $185=0, $186=0, $187=0, $188=0, $189=0, $190=0, $191=0, $192=0, $193=0, $194=0, $195=0, $196=0, $197=0, $198=0, $199=0, $200=0, $201=0, $202=0, $203=0, $204=0, $205=0, $206=0, $207=0, $208=0, $209=0, $210=0, $211=0, $212=0, $213=0, $214=0, $215=0, $216=0, $217=0, $218=0, $219=0, $220=0, $221=0, $222=0, $223=0, $224=0, $225=0, $226=0, $227=0, $228=0, $229=0, $230=0, $231=0, $232=0, $233=0, $234=0, $235=0, $236=0, $237=0, $238=0, $239=0, $240=0, $241=0, $242=0, $243=0, $244=0, $245=0, $246=0, $247=0, $248=0, $249=0, $250=0, $251=0, $252=0, $253=0, $254=0, $255=0) For $i = 2 to @NumParams If $value = Eval($i) Then Return 1 Next Return 0 EndFunc Func MultiNot($value, $2=0, $3=0, $4=0, $5=0, $6=0, $7=0, $8=0, $9=0, $10=0, $11=0, $12=0, $13=0, $14=0, $15=0, $16=0, $17=0, $18=0, $19=0, $20=0, $21=0, $22=0, $23=0, $24=0, $25=0, $26=0, $27=0, $28=0, $29=0, $30=0, $31=0, $32=0, $33=0, $34=0, $35=0, $36=0, $37=0, $38=0, $39=0, $40=0, $41=0, $42=0, $43=0, $44=0, $45=0, $46=0, $47=0, $48=0, $49=0, $50=0, $51=0, $52=0, $53=0, $54=0, $55=0, $56=0, $57=0, $58=0, $59=0, $60=0, $61=0, $62=0, $63=0, $64=0, $65=0, $66=0, $67=0, $68=0, $69=0, $70=0, $71=0, $72=0, $73=0, $74=0, $75=0, $76=0, $77=0, $78=0, $79=0, $80=0, $81=0, $82=0, $83=0, $84=0, $85=0, $86=0, $87=0, $88=0, $89=0, $90=0, $91=0, $92=0, $93=0, $94=0, $95=0, $96=0, $97=0, $98=0, $99=0, $100=0, $101=0, $102=0, $103=0, $104=0, $105=0, $106=0, $107=0, $108=0, $109=0, $110=0, $111=0, $112=0, $113=0, $114=0, $115=0, $116=0, $117=0, $118=0, $119=0, $120=0, $121=0, $122=0, $123=0, $124=0, $125=0, $126=0, $127=0, $128=0, $129=0, $130=0, $131=0, $132=0, $133=0, $134=0, $135=0, $136=0, $137=0, $138=0, $139=0, $140=0, $141=0, $142=0, $143=0, $144=0, $145=0, $146=0, $147=0, $148=0, $149=0, $150=0, $151=0, $152=0, $153=0, $154=0, $155=0, $156=0, $157=0, $158=0, $159=0, $160=0, $161=0, $162=0, $163=0, $164=0, $165=0, $166=0, $167=0, $168=0, $169=0, $170=0, $171=0, $172=0, $173=0, $174=0, $175=0, $176=0, $177=0, $178=0, $179=0, $180=0, $181=0, $182=0, $183=0, $184=0, $185=0, $186=0, $187=0, $188=0, $189=0, $190=0, $191=0, $192=0, $193=0, $194=0, $195=0, $196=0, $197=0, $198=0, $199=0, $200=0, $201=0, $202=0, $203=0, $204=0, $205=0, $206=0, $207=0, $208=0, $209=0, $210=0, $211=0, $212=0, $213=0, $214=0, $215=0, $216=0, $217=0, $218=0, $219=0, $220=0, $221=0, $222=0, $223=0, $224=0, $225=0, $226=0, $227=0, $228=0, $229=0, $230=0, $231=0, $232=0, $233=0, $234=0, $235=0, $236=0, $237=0, $238=0, $239=0, $240=0, $241=0, $242=0, $243=0, $244=0, $245=0, $246=0, $247=0, $248=0, $249=0, $250=0, $251=0, $252=0, $253=0, $254=0, $255=0) For $i = 2 to @NumParams If $value = Eval($i) Then Return 0 Next Return 1 EndFunc IfExtend_example.au3 #include "IfExtend.au3" $sky = InputBox("Sky status", "Play around with values like blue, falling, green.", "falling") #cs ;The following code can now be expressed as one-liners: If $sky = "falling" Then MsgBox(0, "Test 1", "Sky is falling") Else MsgBox(0, "Test 1", "Sky is not falling") EndIf If $sky = "blue" Or $sky = "falling" Then MsgBox(0, "Test 2", "Sky is blue or falling") Else MsgBox(0, "Test 2", "Sky is not blue or falling") EndIf If $sky <> "blue" And $sky <> "falling" Then MsgBox(0, "Test 3", "Sky is not blue or falling") Else MsgBox(0, "Test 3", "Sky is blue or falling") EndIf #ce IfThenElse($sky = "falling", MsgBox, param(0, "Test 1", "Sky is falling"), MsgBox, param(0, "Test 1", "Sky is not falling")) IfThenElse(MultiOr($sky, "blue", "falling"), MsgBox, param(0, "Test 2", "Sky is blue or falling"), MsgBox, param(0, "Test 2", "Sky is not blue or falling")) IfThenElse(MultiNot($sky, "blue", "falling"), MsgBox, param(0, "Test 3", "Sky is not blue or falling"), MsgBox, param(0, "Test 3", "Sky is blue or falling")) ; MultiNot Example ; ; Old code: ; If $sky <> "blue" And $sky <> "falling" And $sky <> "red" And $sky <> "orange" And $sky <> "green" Then ; ; New code: ; If MultiNot($sky, "blue", "falling", "red", "orange", "green") Then The entire purpose of these functions is to make shorter code. I hope they will be useful to others as well.2 points -
SciTE4AutoIt - Highlighting expandable variables and macros inside strings
jaberwacky reacted to BrewManNH for a topic
You could just use the variables in the usual way without bothering with the ExpandVarStrings option at all, then it would be colored the way you want without having to change anything other than adding a couple of & and quotes around your strings and variables. ; this $string = "expand this $variable$ or @macro@" ; becomes this $string = "expand this " & $variable or @macro1 point -
wparam? INPUTLANGCHANGE_BACKWARD 0x0004 INPUTLANGCHANGE_FORWARD 0x00021 point
-
SciTE Caret Color Switch - Use Both Dark and Light Themes
jaberwacky reacted to Jos for a topic
A couple of suggestions: The current setup in the Full SciTE installer has an PersonalTools.lua file in the users directory which can be used for this type of scripts.This avoids having to update the SciteStartup.lua after each installation of the full installer. You could also retrieve the current lexername in stead of using the File Extension as some Lexers use multiple different file extensions. Using OnStartUp will run the function when changing FileTabs in SciTE in case you have multiple files open. Something like this: function PersonalTools:OnStartup() if props['caret.' .. editor.LexerLanguage .. '.line.back'] ~= '' then props['caret.line.back'] = props['caret.' .. editor.LexerLanguage .. '.line.back'] else props['caret.line.back'] = props['caret.default.line.back'] end if props['caret.' .. editor.LexerLanguage .. '.fore'] ~= '' then props['caret.fore'] = props['caret.' .. editor.LexerLanguage .. '.fore'] else props['caret.fore'] = props['caret.default.fore'] end end Cheers Jos1 point -
I just coul have read the search engine, problem solved ... thanks '?do=embed' frameborder='0' data-embedContent>>1 point
-
How do I delete a rectangle?
Xandy reacted to jaberwacky for a topic
Alritey, so there's no one shot set of functions which manage this then? I can't just say to draw a rectangle on the screen and then simply call a function which basically says, "Hey, you know that rectangle you just drew? Yeah, that one. Erase it, bud." Ok, just occurred to me, I could make a func which remembers the pixel colors of the area where the lines of the rectangle will reside. Draw the rectangle, and then call a function which will color those rectangle pixels back to the original colors. Good idea?1 point -
how to make a submenu to the system tray menu
Palestinian reacted to Melba23 for a topic
KamilZajaczkowski, You do it like this: Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. $mMenu_1 = TrayCreateMenu("Menu 1") $mMenu_1_1 = TrayCreateMenu("Menu 1 1", $mMenu_1) $mMenu_1_1_1 = TrayCreateItem("Menu 1 1 1", $mMenu_1_1) $mMenu_1_2 = TrayCreateItem("Menu 1 2", $mMenu_1) $mMenu_2 = TrayCreateMenu("Menu 2") $mMenu_2_1 = TrayCreateItem("Menu 2 1", $mMenu_2) While 1 Switch TrayGetMsg() Case $mMenu_1_1_1 Msgbox(0, "Menu", "1 1 1") Case $mMenu_1_2 Msgbox(0, "Menu", "1 2") Case $mMenu_2_1 Msgbox(0, "Menu", "2 1") EndSwitch WEnd All clear? M231 point