# Comparing variables

## Recommended Posts

```\$1 = "Q"
\$2 = "W"
\$3 = "Y"
\$4 = "U"
\$5 = "S"
\$6 = "Y"

\$c = "Y"

\$i=0
\$string=\$1&\$2&\$3&\$4&\$5&\$6

Do
\$i+=1
\$ret=StringInStr(\$string,\$c,1,\$i)
MsgBox(0,"",StringReplace(\$ret,"0","that's all"))
Until \$ret=0

MsgBox(0,"",StringTrimRight("no (more)",6*(\$i=0))&" '"&\$c&"' found.")```

too many conclusive msgbox ...   one would be sufficient......

Edited by Pincopanco

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

##### Share on other sites

ah you make the rules .....

.

```\$1 = "Q"
\$2 = "W"
\$3 = "Y"
\$4 = "U"
\$5 = "S"
\$6 = "Y"

\$c = "Y"

\$i=0
\$string=\$1&\$2&\$3&\$4&\$5&\$6

Do
\$i+=1
\$ret=StringInStr(\$string,\$c,1,\$i)
MsgBox(0,"",StringReplace(\$ret,"0","that's all"))
Until \$ret=0

;MsgBox(0,"",StringTrimRight("no (more)",7*(\$i=0))&" '"&\$c&"' found.")```

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

##### Share on other sites

Wouldn't it just be easier to use the If/Endif statements instead of trying to find some stupid ways around it?

I mean stupid in the sense of this whole exercise, not the examples themselves, some of which are quite interesting.

Just do it the right way, the easiest way, and don't be anal about a few If statements in your code.

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 Gude
How 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

##### Share on other sites

```\$1 = "Q"
\$2 = "W"
\$3 = "Y"
\$4 = "U"
\$5 = "S"
\$6 = "Y"

\$c = "Y"

\$i=0
\$string=\$1&\$2&\$3&\$4&\$5&\$6
\$ret=""

Do
\$i+=1
\$ret&=StringInStr(\$string,\$c,1,\$i)&","
Until StringRight(\$ret,2)="0,"

.

anal ?

Edited by Edano

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

##### Share on other sites

in fact, i am a big really big fan of avoiding if's in a script. you can spare a lot of lines by doing it.

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

##### Share on other sites

Edano, you're smart,
however, not to be anal , but I was just curious as to a solution found by AutID On His code on post  >#9,

....but never mind.

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

##### Share on other sites

wow, is this still hot or a competition ???

.

```\$1 = "Q"
\$2 = "W"
\$3 = "Y"
\$4 = "U"
\$5 = "S"

\$c = "Y"

\$string=\$1&\$2&\$3&\$4&\$5

MsgBox(0,"",StringInStr(\$string,\$c))```

.

E.

Edit: of course, using includes is cheating. you could include every au3 script you want, even self written. this is cheating

I will not even comment this.

Wouldn't it just be easier to use the If/Endif statements instead of trying to find some stupid ways around it?

I mean stupid in the sense of this whole exercise, not the examples themselves, some of which are quite interesting.

Just do it the right way, the easiest way, and don't be anal about a few If statements in your code.

I prefer clean projects every time I do one. If statement is the easy way but if I use the easy way everywhere my project will get 3 times bigger without reason.

This is what I am using atm.

```Func _Indexreturn()
Local \$values[10] = [\$1, \$2, \$3, \$4, \$5, \$6, \$7, \$8, \$9, \$10]
Local \$index = _ArraySearch(\$values, \$aKeys[\$c])
Return \$index
EndFunc```

I find it better than an If statement but anyway.

##### Share on other sites

If you use the obfuscater and just use the /so option to strip unused functions, then open the obfuscated script, you'll see that there's a lot more in your script than you think there is, and a simple if/then/endif would probably make your script much smaller in the long run rather than using the Array UDF and _ArraySearch.

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 Gude
How 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

##### Share on other sites

If you use the obfuscater and just use the /so option to strip unused functions, then open the obfuscated script, you'll see that there's a lot more in your script than you think there is, and a simple if/then/endif would probably make your script

I already thought about it but array udf is already included in my script so i don't have a lot to loose. Not all array functions can be replaced with if statements.

Anyway thank you, you seem to be clever

Edited by AutID

##### Share on other sites

another passion of mine :.... avoid includes ...... really

I already thought about it but array udf is already included in my script so i don't have a lot to loose. Not all array functions can be replaced with if statements.
Anyway thank you, you seem to be clever

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

##### Share on other sites

The only way to do what you are saying is to copy the array functions on my own udfs included in my script but come to think of it. A lot of the array functions call each other so in the end i will have to include the udfs. And please stop telling things like these because there are people who will be looking for similar things and read what you are saying

##### Share on other sites

maybe it is YOUR way to copy and paste functions, which is really stupid and senseless. but i use them to learn the logic and apply the learned to my code.

and PLEASE never ever tell me again what i have to say and what not.

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

##### Share on other sites

Please calm down Edano. AutId wasn't teaching you but was rightfully thinking that such advice you gave wasn't for beginners and needed context to not be taken at face value.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

##### Share on other sites

you are right, not for beginners. and i am calm. i said what had to be said. now it's okay.

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

##### Share on other sites

Even so, advanced AutoIt programmers use Includes, I mean why have a dog and bark yourself!

##### Share on other sites

I was amusing myself with creating a few ways of achieving the original challenge that AutID and finding that an If Then structure (no need for any elseif) was the fastest method set, but then I found that the rules had changed.

As a bit of an aside I am puzzled by the number of Autoit users who seem to go to great effort using all sorts of convoluted methods to make their code span as few lines as possible, usually with the result of a slower script in which the logic is harder to follow and debug. Many of the applications that I write often involve manipulating data in huge text files. Many is the number of times that I have managed to make it run ten time faster by adding a few hundred extra lines of code. This is especially true if you have some knowledge of the frequency with which data will occur and branch your code so that the most likely cases are checked first. It's not the total number of lines in your source code that affects the speed of your application, but the number of instructions that need to be executed to complete the task. The rule is where there are many possible routes eliminated the least likely as quickly as possible.

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...