MrKris1224 Posted October 8, 2015 Share Posted October 8, 2015 Hi, i have a small problem with Execute()... I don't know how to use it completly.For example i want evaluate two strings with Execute("string=string"). Why Execute() returns 0?Next: Execute("3>=0") returns 1 but Execute("3=>0") returns 0. Why? How to correct it?Next: Execute("1!=0") returns 0 but expression is true...And... Can I use And / Or / Not operators in Execute()? If yes then how?Why i can't evaluate strings? How to do this?Plz, help me and sorry for english if somethink is bad. Link to comment Share on other sites More sharing options...
kylomas Posted October 8, 2015 Share Posted October 8, 2015 MrKris1224,Works for me...local $aComp = [1,2,3,4,5,5,6,7,8,8,9] for $i = 1 to ubound($aComp) - 1 ConsoleWrite(execute("$aComp[$i] = $aComp[$i-1]") & @CRLF) nextPost runnable code for more help.kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
BrewManNH Posted October 9, 2015 Share Posted October 9, 2015 Maybe you shouldn't be using Execute for whatever it is you're trying to do?Execute("3>=0") will return True because the comparison evaluates that 3 greater than or equal to 0. (Boolean True = 1)Execute("3=>0") is just written wrong, so it returns an error of 1, and a return value of "" (empty string).Execute("1!=0") is also written wrong because AutoIt doesn't use != as an operator and returns an error of 1 and a return value of "".Not knowing what you're strings contain, it's impossible to say why it returns zero. Although, Execute("string=string") WILL return True if that were your actual comparison strings. MrKris1224 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Malkey Posted October 9, 2015 Share Posted October 9, 2015 @BrewManNHNote:' Execute("string=string")' is not just string comparison. The string has to be a function name to return True. This is the case on my system. The following 10 ConsoleWrites all return True.ConsoleWrite(Execute("string = string") & @LF) ConsoleWrite(Execute("3 >= 0") & @LF) ConsoleWrite(Execute("0 <= 3") & @LF) ConsoleWrite(Execute("1 <> 0") & @LF) ConsoleWrite("(string = string): " & (string = string) & @LF) ConsoleWrite("(Default = Default): " & (Default = Default) & @LF) ConsoleWrite("(FileExists = FileExists): " & (FileExists = FileExists) & @LF) ConsoleWrite((3 >= 0) & @LF) ConsoleWrite((0 <= 3) & @LF) ConsoleWrite((1 <> 0) & @LF) MrKris1224 1 Link to comment Share on other sites More sharing options...
BrewManNH Posted October 9, 2015 Share Posted October 9, 2015 @BrewManNHNote:' Execute("string=string")' is not just string comparison. The string has to be a function name to return True. This is the case on my system. The following 10 ConsoleWrites all return True. Aren't you contradicting yourself with the first Execute in your code? If Execute("string = string") returns true, where's the function name? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
iamtheky Posted October 9, 2015 Share Posted October 9, 2015 (edited) isnt 'string' the function name? (whereas random other strings do not return true)ConsoleWrite(Execute("string = string") & @LF) ConsoleWrite(Execute("SomeOtherString = SomeOtherString") & @LF) Edited October 9, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
BrewManNH Posted October 9, 2015 Share Posted October 9, 2015 Ahhh, you're right, I hadn't thought about the word being a keyword. DOH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
MrKris1224 Posted October 9, 2015 Author Share Posted October 9, 2015 Ok, thanks but can I use AND / NOT / OR operators in expressions? Link to comment Share on other sites More sharing options...
BrewManNH Posted October 9, 2015 Share Posted October 9, 2015 Don't use Execute at all if you don't need it, and none of your examples shown need to use Execute unless there's something in your script that you haven't posted. Execute has only limited times that it is necessary, and these don't fit. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
MrKris1224 Posted October 10, 2015 Author Share Posted October 10, 2015 Yes but I need it to my "programming language" writen in autoit Link to comment Share on other sites More sharing options...
kylomas Posted October 10, 2015 Share Posted October 10, 2015 MrKris1224,Can you give an example (in code) of where you need "execute"?kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
MrKris1224 Posted October 10, 2015 Author Share Posted October 10, 2015 (edited) I use it in parsing "if" command in my "programming language" for example:if "expression"*commands*endifAnd parser looks like:If Execute($expression) Then...Endif Maybe there's another way to make it? @UpdateIn parser $expression is variable. So if $expression = "string = string" then Execute() return 0 but if $expression = ' "string" = "string" ' then return 1 Edited October 10, 2015 by MrKris1224 Link to comment Share on other sites More sharing options...
BrewManNH Posted October 10, 2015 Share Posted October 10, 2015 Post a runnable script in which you're using Execute to do something, we can probably suggest a better way to do it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
MrKris1224 Posted October 10, 2015 Author Share Posted October 10, 2015 I posted...If Execute($expression) Then ... Endif Link to comment Share on other sites More sharing options...
BrewManNH Posted October 10, 2015 Share Posted October 10, 2015 Can you run that snippet?I can't, I don't have the surrounding code you're using, I don't know what $expression holds, or where you got it from.Runnable code = a script that can be run without having to write anything around it to get it to work.Reproducer script = Runnable code that demonstrates what you're doing in your script, even if it's not the same script as you're using as long as the code posted does exactly the same thing as your real script.Once you post the reproducer script that demonstrates what you're doing in exactly the same way as you're doing it in your script, then we have something to work with.BTW, click the link in my signature, the big blue one that says "How to ask questions the smart way!" if what I am posting doesn't make sense. It's been translated into over a dozen languages if you're not strong with English. That link explains what I'm asking for in a much better way than I can explain. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
MrKris1224 Posted October 10, 2015 Author Share Posted October 10, 2015 Topic to close. I see you don't know how to help me. Link to comment Share on other sites More sharing options...
BrewManNH Posted October 10, 2015 Share Posted October 10, 2015 Oh I'm sure I know how to help you, I'm just not sure if you're able to post a script that demonstrates what you're trying to do.In my humble opinion, whatever you're using Execute for, can probably be done without it, you should try it and see. MrKris1224 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Malkey Posted October 10, 2015 Share Posted October 10, 2015 The following 9 ConsoleWrites all return True.Local $a = True Local $b = True Local $c = False ConsoleWrite(($a And $b And (Not $c)) & @LF) ConsoleWrite(Execute("$a And $b And (Not $c)") & @LF) ConsoleWrite(($a Or $c) & @LF) ConsoleWrite(Execute("$a Or $c") & @LF) ConsoleWrite((BitAND(23, 12) = 4) & @LF) ConsoleWrite(Execute("BitAnd(23, 12) = 4") & @LF) ; Note quotation marks around the strings. ConsoleWrite(("abcd" = "abcd") & @LF) ConsoleWrite(Execute('"abcd" = "Abcd"') & @LF) ; Case insensitive ConsoleWrite(Execute('"abcd" == "abcd"') & @LF) ; Case sensitive MrKris1224 1 Link to comment Share on other sites More sharing options...
czardas Posted October 11, 2015 Share Posted October 11, 2015 I posted...If Execute($expression) Then ... Endif This construct looks fine to me. There may be alternatives - but I'm not aware of them.You need to clearly define the syntax of your language and also make sure you only pass expressions which the interpreter can actually execute. This will likely require some preprocessing of the expression depending on syntax. You need to know how to interpret the results of the executed expression: because AutoIt is a loosely typed language and can sometimes throw up some unexpected results. Ask yourself - What are the advantages (and disadvantages) of creating an alternative syntax (or language)? Start with some very simple expressions and test them against expected results. Be aware that Execute() is only intended for simple (single line) expressions passed as strings. Internal conversions can play havoc if you don't pay attention to certain limitations (not so easy to define). MrKris1224 1 operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
MrKris1224 Posted October 11, 2015 Author Share Posted October 11, 2015 (edited) OK . Syntax of my language is:if expressioncommandsendifAnd autoit script get line with if and split it for two variables. First = name of function (if), second = expression to execute. Now parser looks like: If Execute($expression) Then Return 0 ;it's for execute commands under if command Else Return _find_endif() ; it's for jump to endif linie if expression is false endif@MalkeyThanks for it code:ConsoleWrite(Execute('"abcd" = "Abcd"') & @LF) ; Case insensitive ConsoleWrite(Execute('"abcd" == "abcd"') & @LF) ; Case sensitive Now i know the expression must be in quotes if including strings. @czardasi writed lots of own languages but every time i have problem with parsing if command. Now my language isn't only if... It is more funcionaly Edited October 11, 2015 by MrKris1224 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now