OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Lacota on 20 Jan 2008, 05:26:07

Title: PRIVATE = [] or PRIVATE []
Post by: Lacota on 20 Jan 2008, 05:26:07
Hi, I am confused as to which is the correct way to declare private variables in scripts. I have seen many examples with PRIVATE ["_somevar","_someothervar"]; but I get an "Unknown Operator" error whn I try to run them. PRIVATE = [] works for me in that I don't get an error but not sure if the scope is being set correctly.

I am running OFP Res 1.96

Thanks
Title: Re: PRIVATE = [] or PRIVATE []
Post by: Mandoble on 20 Jan 2008, 09:37:12
Use private for functions (sqf code) you will execute with call command.
Code: [Select]
private["_var1", "_unit", "_whatever"];

To declare local variables in sqs code, just initialize them assigning a value.
Code: [Select]
_inrange = false
Title: Re: PRIVATE = [] or PRIVATE []
Post by: Lacota on 20 Jan 2008, 16:25:20
Thanks Mondoble but if I enter "private[];" without "=" I get the Unknown Operator error I mentioned. It even indicates that the error is between the private keyword and the square brackets.
Title: Re: PRIVATE = [] or PRIVATE []
Post by: Mandoble on 20 Jan 2008, 17:43:53
Are trying that in SQS or SQF?
If SQS, you dont need private at all.
private = [whatever here] will define a global variable named private.

private command (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=p#254)