Jump to content
Sign in to follow this  
Michel Claveau

Syntax error with try a closure

Recommended Posts

Michel Claveau

Hi!

I try to do a closure.

Here, my code:

Func coef($c)
    Func valeur($v)
        Return $v*$c
    EndFunc
    Return valeur
EndFunc

$a=coef(1.25)
ConsoleWrite($a(1))
ConsoleWrite($a(2))
ConsoleWrite($a(100))

But, I have a syntax error on: Func valeur($v)

What is the problem?

Thank you for all answers.

Edited by Michel Claveau

Share this post


Link to post
Share on other sites
Xenobiologist

HI,

Func in a another Func is not possible.

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
Michel Claveau

Re!

Func in a another Func is not possible.

Want you said: "...is not possible ...with (pure) AutoIt"?

@+

MCI

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

what do you want to do? Calculating what?

ConsoleWrite(coef(1, 1.25) & @CRLF)
ConsoleWrite(coef(2, 1.25) & @CRLF)
ConsoleWrite(coef(100, 1.25) & @CRLF)

Func coef($valeur, $c)
    Return $valeur ^ $c
EndFunc   ;==>coef

Mega

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
Michel Claveau

Re!

A closure can emulate a global variable with a (func)local variable.

This tech give a better source-code.

See: wikipedia

Edited by Michel Claveau

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

which pro do you miss? A closure is only a code block which can be a parameter for a function/method.

Or what feature is it that makes them interesting for you?

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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  

×