Program Posted June 22, 2004 Share Posted June 22, 2004 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.") Exit EndIf FileWriteLine($x, $msg) FileClose($x) return 1 EndFunc 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? Link to comment Share on other sites More sharing options...
pekster Posted June 22, 2004 Share Posted June 22, 2004 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. Link to comment Share on other sites More sharing options...
emmanuel Posted June 22, 2004 Share Posted June 22, 2004 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 FunctionsUser 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: MyFunc Func1 _My_Func1 "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Program Posted June 22, 2004 Author Share Posted June 22, 2004 good blokes, thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now