Jump to content

Recommended Posts

Posted

I haven't been doing any au3 coding in a very very long time. But circumstances have returned to a place which I need to use windows again. I've got a few quick questions about the language:

When using loops, can you still use brackets close the circumstance?

for ($i = 0 to 50)

instead of:

for $i = 0 to 50

Also, is there a way to prototype your functions?

-I am the giver of life and the bringer of death.

Posted

  Quote

When using loops, can you still use brackets close the circumstance?

for ($i = 0 to 50)

instead of:

for $i = 0 to 50

Your first example throws a syntax error, so I guess the answer is no.

Posted

It shouldn't be new news... Prototyping functions is common in C and C++ which are the base of this scripting language along with pretty much everything =/

And I have one more question to add to the list, is there a way to get the amount of elements in an array? Not a dynamic array, just a normal array, like:

$names[5] ;<--- return 5

$names[6] ;<--- return 6

etc

Thanks again.

-I am the giver of life and the bringer of death.

Posted

  b14ck said:

It shouldn't be new news... Prototyping functions is common in C and C++ which are the base of this scripting language along with pretty much everything =/

Uhhh... well that certainly didn't further my understanding of 'function prototyping'. ;) Do keep in mind that most of the people on these forums have no idea of some feature that might be common to C and C++.

After some Googling on what this secretive principle is, my guess is no.

  b14ck said:

And I have one more question to add to the list, is there a way to get the amount of elements in an array? Not a dynamic array, just a normal array, like:

$names[5] ;<--- return 5

$names[6] ;<--- return 6

etc

I think you're after UBound().
Posted

  b14ck said:

It shouldn't be new news... Prototyping functions is common in C and C++ which are the base of this scripting language along with pretty much everything =/

And I have one more question to add to the list, is there a way to get the amount of elements in an array? Not a dynamic array, just a normal array, like:

$names[5] ;<--- return 5

$names[6] ;<--- return 6

etc

Thanks again.

$name[5] = 5 ?

and you can do *If ($var == 'Hello') Then* but i dont know why you would want to do that when you can just leave out the paren's.

  LxP said:

Do keep in mind that most of the people on these forums have no idea of some feature that might be common to C and C++.

HEY! I know C++ ive just never heard 'funtion prototyping' ..is this some sort of beta type testing? me no comprehendo

[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Posted
  B3TA_SCR1PT3R said:

HEY! I know C++ ive just never heard 'funtion prototyping' ..is this some sort of beta type testing? me no comprehendo

Meh, well I know neither as yet.
Posted

Maybe I'm not being clear... I need to do this to determine how long an array will be. Such as this quick example in Java...

char hk[] = {'a', 'b', 'c', 'd'};

System.out.println("Number of elements in array hk: " + hk.length + ".");

Or... In C...

char *hk = "hello world";

(void)fprintf(stdout, "Amount of elements in array hk: %d\n", sizeof(char) * (strlen(hk) + 1));

This way I can traverse through an array of any length without hard-coding in the size.

LxP, thanks, I just read your post after posting mine ;)

Just thought of another question actually. I don't see anything in the help file about instantiating arrays upon declaration.

ex:

Global $array[] = {"element 0", "element 1", "etc"}

Any substitute for that? Or do you have to specify each element?

ex:

Dim $array[3]

$array[0] = "el0"

$array[1] = "el1"

$array[2] = "el2"

-I am the giver of life and the bringer of death.

Posted

You may want to take a look at the _ArrayCreate() UDF offered by Array.au3:

  _ArrayCreate() said:

Create a small array and quickly assign values.

#include <Array.au3>
$Array = _ArrayCreate ( $v_Val1, [$v_Val2, [..., $v_Val21]] )
Posted

You can initialize an array in the beta. The help file explains that.

Function prototyping is necessary in languages like C/C++, otherwise, you can't use a function until after the compiler sees it. A prototype is just a declaration that says, "Hey compiler, I will define this function which looks like this later on."

Example:

#include <iostream>

 // Prototype for function foo which takes an int and char
void foo(int i, char c);

int main()
{
    foo(1, 'a');
    return 0;
}

void foo(int i, char c)
{
    std::cout<<"i="<<i<<", c="<<c<<std::endl;
}

Without the prototype (aka declaration), the compiler would error out on the call to foo() in main() because the compiler had never encountered such a function. This is not necessary in AutoIt because AutoIt pre-processes the file and looks up all functions and stores them so that when it is actually executed the functions are known, regardless of the order they appear in the file. C/C++ on the other hand process in a top-down manner and must see either the function definition or a declaration so it knows about a function.

Posted

I was curious because I personally like to have a listing of all functions included in the file at the top (not in comments). And thanks LxP, I saw that function in the help but I thought it was only for dynamic arrays, (I saw the add function).

-I am the giver of life and the bringer of death.

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
  • Recently Browsing   0 members

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