Jump to content

Simple Variable Management


Recommended Posts

Hi, I love AutoIt3 and use it for simple tasks and just trying to learn more stuff.

To get right to it: I'd like to make a script that can display all assigned variables, but each only once. RRReal simple I'm sure. Here's a short example:

AutoItSetOption("SendKeyDelay", 75)

#include <Array.au3>;?

$a = 1

$b = 1

$c = 3

$d = 4

if (put script that works here) then

MsgBox(4096, "Here they are", "These values are present: "&$a&", "&$c&", "&$d&"")

endif

I want the message box to say "These values are present: 1,3,4"

In the case of:

$a = 1

$b = 1

$c = 1

$d = 4

I want the message box to say "These values are present: 1,4"

...and so forth. I've tried things like writing a script that results in telling me how many times each variable appears, but my thick skull isn't quite grasping what it should do: Just tell me which values are present, no matter how often or seldom it appears, only once.

Believe it or not, I'm trying to develop a script that can do color separations for a screen printing operation (color separation for 4-8 color artwork), and this is a very simplified part of it.

I had an accident, missed most of my DOS programming class (3 weeks!), but got a C anyway.

Edited by clicknpitch
Link to comment
Share on other sites

okay what is your question exactly? you mean the code should automatically detect what are the variables assigned and how many variables assigned?

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
Share on other sites

okay what is your question exactly? you mean the code should automatically detect what are the variables assigned and how many variables assigned?

For my purpose, I'll always know how many variables will be assigned. Some of them will be assigned the same value, some will be unique. Of that group (in this case 4 variables), I only need to know which values are in the group.

The master plan is to sample 4, 5, or 6-color artwork in a grid of 49 spots, using Photoshop (which I wish would just TELL me which colors are used). It finds which colors are there and separate each color for its own screen. Think cheesy T-shirt artwork. Just trying to automate the whole process.

Link to comment
Share on other sites

So basically, you want to know which values are there without it displaying the value more than once? If this is the case I'll start coding a sample script.

EDIT: Actually the number of variables won't matter now that I think about it.

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Link to comment
Share on other sites

So basically, you want to know which values are there without it displaying the value more than once? If this is the case I'll start coding a sample script, although I'll need a rough estimate of how many variables there's going to be.

Well neato! I'm planning on using variables $1 - $50 (49 variables), but if you could show me what step I'm missing with just 4 variables, I think I could slog the rest of the way through.

So far I've approached it like this:

If $a = $b or $a = $c or $a = $d then; ($a is represented more than once, so exclude the

matches further on)

else; ($a is unique, continue checking $b, $c and $d)

endif

...something like that so far

Link to comment
Share on other sites

  • Moderators

Several ways to accomplish the return of unique values.

If you have groups, use arrays instead of individual variables.

If you use arrays, you can use the function _ArrayUnique() to return only the unique values.

To understand arrays: http://www.autoitscript.com/wiki/Arrays

----

After understanding arrays, later on in your experience, you may move into quicker methods of unique value returns, such as using SQLite to do the heavy lifting.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

What SmOke_N said, although the wiki entry on Arrays could be modified for easier understanding of them. You could then use _ArraytoString

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...