Jump to content
Sign in to follow this  
mdcotter30

array

Recommended Posts

mdcotter30

what is the best way to write a script to populate an array?

thanks,

Share this post


Link to post
Share on other sites
someone

Can you be more descriptive about what you want to populate the array from? Or what you are trying to do?

If you are trying to create an array out of a body of text look up StringSplit.


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites
PsaltyDS

what is the best way to write a script to populate an array?

thanks,

You get male and female elements together, then just sit back and watch that array populate itself!

:D

All seriousness aside, could you give us a little more to work with...?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
mdcotter30

You get male and female elements together, then just sit back and watch that array populate itself!

:D

All seriousness aside, could you give us a little more to work with...?

:)

Hello,

Basically I am trying to take two test files and do a myriad of things with these files. First I want to do a file compare to make sure that the data copied then I want to read all the test files in a specific directory and display each file name in a separate dialog box then break up the file names and display the file name and the extensions separately and finally request the user to specify what directory to read in.

Share this post


Link to post
Share on other sites
November

I recently read a post with this needs ...

let me check...

(10 min later) ... nope :) i couldnt find

Hints:

_filelisttoarray

string manipulation

guictrlcreatelistview

FileOpenDialog

and imagination

cheers

Edited by november

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites
November

I hope that my last post helps!

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites
PsaltyDS

Hello,

Basically I am trying to take two test files and do a myriad of things with these files. First I want to do a file compare to make sure that the data copied then I want to read all the test files in a specific directory and display each file name in a separate dialog box then break up the file names and display the file name and the extensions separately and finally request the user to specify what directory to read in.

Very doable. And as usual, there are more than one ways to skin that cat. You should start by letting the existing function do as much of the work as possible. Like _FileListToArray() in the help file.

Now this is the point where we let you know we are not going to write it for you.

1. "First I want to do a file compare to make sure that the data copied"

2. "then I want to read all the test files in a specific directory"

3. "and display each file name in a separate dialog box"

4. "then break up the file names"

5. "display the file name and the extensions separately"

6. "and finally request the user to specify what directory to read in."

Code up the first part (or more, if you're ready) and tell us how it went. Post anything that doesn't work and we'll help you through it.

Happy learning, and welcome to AutoIt!

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
mdcotter30

Very doable. And as usual, there are more than one ways to skin that cat. You should start by letting the existing function do as much of the work as possible. Like _FileListToArray() in the help file.

Now this is the point where we let you know we are not going to write it for you.

1. "First I want to do a file compare to make sure that the data copied"

2. "then I want to read all the test files in a specific directory"

3. "and display each file name in a separate dialog box"

4. "then break up the file names"

5. "display the file name and the extensions separately"

6. "and finally request the user to specify what directory to read in."

Code up the first part (or more, if you're ready) and tell us how it went. Post anything that doesn't work and we'll help you through it.

Happy learning, and welcome to AutoIt!

:)

Ok im trying to do a file compare but it doesnt seem to work. here is what i have so far"

;File Comparison

Dim $RET

$File1 = ("C:\Documents and Settings\dcotter\Desktop\Source\Source.txt")

$File2 = ("C:\Documents and Settings\dcotter\Desktop\Source\Dest.txt")

$File3 = ("C:\Documents and Settings\dcotter\Desktop\Dest\Source.txt")

$File4 = ("C:\Documents and Settings\dcotter\Desktop\Dest\Dest.txt")

;If $File1 = $File3 And $File2 = $File4

If Not $RET Then

MsgBox(64, "Match", "File compare matched")

Else

MsgBox(16, "Error", "File compare did not match")

EndIf

ive tried it two different ways one with the $ret and the other $file compare.

Share this post


Link to post
Share on other sites
Skruge

;If $File1 = $File3 And $File2 = $File4

You're comparing the file names, not their contents...

Look at the FileRead() and _FileReadToArray() functions.


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites
PsaltyDS

Ok im trying to do a file compare but it doesnt seem to work. here is what i have so far"

; ...

ive tried it two different ways one with the $ret and the other $file compare.

Check out the _FileCompare() UDF posted by a very distinguished looking flightless waterfowl in another topic...

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Golbez

dim $x
dim $y
dim $z
do
    x=x+1
    $z[$x] = $x
until $y = 1

there it will go forever :)

Edited by Golbez

Share this post


Link to post
Share on other sites
PsaltyDS

dim $x
dim $y
dim $z
do
    x=x+1
    $z[$x] = $x
until $y = 1

there it will go forever :D

No it won't. It will fail immediately because $z is not declared as an array, the increment of $x is missing the dollar signs, and $y never changes so it would eventually overflow the AutoIt limits for total array size.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Golbez

No it won't. It will fail immediately because $z is not declared as an array, the increment of $x is missing the dollar signs, and $y never changes so it would eventually overflow the AutoIt limits for total array size.

:)

dim $x
dim $y
$x = 0
do
    dim $z[$x] = $x
    $x = x+1
    $z[$x] = $x
until $y = 1

happy?

Share this post


Link to post
Share on other sites
PsaltyDS

dim $x
dim $y
$x = 0
do
    dim $z[$x] = $x
    $x = x+1
    $z[$x] = $x
until $y = 1

happy?

Weeeelllll... I wasn't UN-happy before... so... YES! :)

But just for the exercise...

Your script still fails immediately. You are declaring with a Dim inside a loop, which is almost always a bad thing, and is in this case. The first time through $x = 0 so you are declaring "Dim $z[0]" which is invalid. Also, your initialization string is invalid because $x has to be in square brackets, like "Dim $z[$x] = [$x]".

You're not typing this up in SciTE, are you? Tidy or syntax checker would snag those errors in a heart beat.

The real point though was that the original posted wanted to populate the array with some specific data.

Pinging on your code was meant to be mildly humorous, not snarky. So have a great weekend!

:D:ph34r::D:lmao::D:P:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Golbez

Weeeelllll... I wasn't UN-happy before... so... YES! :)

But just for the exercise...

Your script still fails immediately. You are declaring with a Dim inside a loop, which is almost always a bad thing, and is in this case. The first time through $x = 0 so you are declaring "Dim $z[0]" which is invalid. Also, your initialization string is invalid because $x has to be in square brackets, like "Dim $z[$x] = [$x]".

You're not typing this up in SciTE, are you? Tidy or syntax checker would snag those errors in a heart beat.

The real point though was that the original posted wanted to populate the array with some specific data.

Pinging on your code was meant to be mildly humorous, not snarky. So have a great weekend!

:D:ph34r::D:lmao::D:P:D

nah.. i was typing it online.. i posted it as a joke because someone doesnt know how to use the help file. (yeah i didnt use it either but i wasnt the one who posted how to do it. if you know q-basic it woulda worked :huh: {yeah im old school} :D)

ive never really used an array in autoit. and he asked how to make it work forever.. in theory if someone had enough ram it would last forever :huh:

Edited by Golbez

Share this post


Link to post
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
Sign in to follow this  

×