Jump to content
Sign in to follow this  

send a string to a func

Recommended Posts

This is my code:

Func log(ByRef $msg) ;print to a test log

Local $x

;Write to a log file with computer name

$x = FileOpen("\\sydney\applications\scripts\asttestlog.txt", 1)

; Check if file opened for writing OK

If $x = -1 Then

MsgBox(0, "Error", "Unable to open file.")



FileWriteLine($x, $msg)


return 1


All i want to do is create a function that writes a specific string to a log file, when i try to use this function it gives me an error: Badly formatted Func statement

Is this because im trying to pass a string to a function? how do i get around this?

Share this post

Link to post
Share on other sites

Don't call your function log. You can't use that as your function name because it is the name of a built-in function. You can pass paramaters to your function all you want. Also, you wouldn't need to make it a ByRef variable unless you needed to change the variable that was pass, and have the change affect the variable from the scope of whatever called that function.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post

Link to post
Share on other sites

first off, why re-invent the wheel? check out _FileWriteLog in includes\file.au3..

second off, you can't use existing function names for your own functions.

User Functions

User functions are declared using the Func...EndFunc statements.

Functions can accept parameters and return values as required.

Function names must start with either a letter or an underscore, and the remainder of the name can contain any combination of letters and numbers and underscores.  Some valid function names are:




"I'm not even supposed to be here today!" -Dante (Hicks)

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...