AutoHotkey Community

It is currently May 27th, 2012, 6:12 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Array Question
PostPosted: December 3rd, 2005, 12:49 am 
Offline

Joined: September 12th, 2005, 10:35 pm
Posts: 216
2 questions below:

1) What does it mean by "j" in the following following Array:

Array%j% = %A_LoopField%

OR

What does it mean by "j", "k" in the following array?

Array%j%_%k% := A_LoopReadLine

2) Why A_LoopField is in % sign , whereas A_LoopReadLine is not in % sign?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 3rd, 2005, 1:03 am 
Offline

Joined: December 1st, 2005, 7:04 pm
Posts: 37
Location: Los Angeles, CA
Both of these are well covered in the help and the tutorial. but here's the skinny:

1) basically, you are calling a variable based on another variable. For instance - if you set j to 1
Code:
j = 1
then by entering the code
Code:
array%j% = %a_loopfield%
you would essentially be putting the loopfield into array1
Code:
array1 = %a_loopfield%
this also applies for k in your situation.

2) if you are calling a variable or modifying it, you would not use the percent sign, ie:
Code:
if j = 1
however if you are referancing a variable for it's value, you would use the percent sign
Code:
msgbox, hello %j%
would display hello 1

Hope this helps...

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 3rd, 2005, 1:03 am 
Quote:
To assign the result of an expression to a variable, use the := operator as in this example:
NetPrice := Price * (1 - Discount/100)
Quote:
If a variable reference such as %Var% appears in an expression, whatever it contains is assumed to be the name or partial name of another variable (if there is no such variable, %Var% resolves to a blank string). This is most commonly used to reference array elements such as the following example:

Var := MyArray%A_Index% + 100

Such a reference should not resolve to an environment variable, the clipboard, or any reserved/read-only variable. If it does, it is treated as an empty string.
Quote:
By preceding any parameter with "% ", it becomes an expression. In the following example, math is performed, an array element is accessed, and a function is called. All of these items are concatenated via the "." operator to form a single string displayed by MsgBox: MsgBox % "New width for object #" . A_Index . " is: " . RestrictWidth(ObjectWidth%A_Index% * ScalingFactor)


Report this post
Top
  
Reply with quote  
 Post subject: Re: Array Question
PostPosted: December 3rd, 2005, 1:06 am 
Offline

Joined: November 29th, 2005, 7:07 am
Posts: 5
mighty-f wrote:
2) Why A_LoopField is in % sign , whereas A_LoopReadLine is not in % sign?


A_LoopField is a variable with a value ready to read
A_LoopReadLine is a function that performs reading from the file and RETURNS the value for use by your script


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google Feedfetcher, HotkeyStick, Wicked and 56 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group