Jump to content
Sign in to follow this  
louis

Creating  functions

Recommended Posts

Show Posts

Pages: [1]

1 Armed Assault / Editing/Scripting Advanced / Problem with getting functions to work on: Today at 06:17:46 AM

Hi, I would appreciate a pointer to what might be wrong with implementing my function.

I wrote and tested a script but when I try to convert it for use as a function I get an error. I then wrote a simple test script to see if I could narrow it down but get the same error. Can anyone tell me what I'm doing wrong.

Here's the simple test and what I'm doing.

In init.sqs I've declared the following:

int = preprocessFile "int.sqf"

The function int.sqf contains:

private ["_h"];

_h = (_this) - (_this mod 1);

_h

I call this from a script like this:

_i = [9.33] call int

hint format ["Here is your integer sir: %1",_i]

The error I get with this and my original function is:

error call : [9.33] |#| call int, Type string, expected code

From what I've read on functions or looking at other examples I am doing it as others appear to be doing it but I just can't get past this error or figure out where the so called 'string' instead of code is being detected.

Any ideas would be appreciated.

regards

L

Share this post


Link to post
Share on other sites

In ArmA, you need to compile your code.

eg:

myFunction = compile preProccessFile "myFunction.sqf";

[123] call myfunction;

Share this post


Link to post
Share on other sites
Quote[/b] ]In ArmA, you need to compile your code.

eg:

myFunction = compile preProccessFile "myFunction.sqf";

[123] call myfunction;

Excellent! many thanks I was obviously looking at OFP stuff. The error makes sense now.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×