Jump to content
Sign in to follow this  
rexehuk

Calling for an incremental array... Parsing is causing problems!

Recommended Posts

Ok so for simples sake I have an array named

marker1_data containing [12 variables]

In a script, I'm trying to parse MARKERNAME + _data to form the needed strings such as

Marker1_data

marker2_data

marker3_data

This will allow simple tracking of variables and their corresponding data handlers. The problem at the moment is CALLING those handlers to select data from.

Code I'm using to grab the DATA

_roPassMVAR = _this select 0;
_roMarkerDATA = format["%1_data",_roPassMVAR];
hint format["Your have selected %1 \n and value has index of %2",_roPassMVAR,_roMarkerDATA];

_line1 = format["%1",_roMarkerData] + (" select 1");

hint format["Line one is %1",_line1];

ctrlSetText [13201,_line1];

It seems to be parsing MARKERNAME + _DATA correctly, but is not selecting from within that parsed variable name, it's reading it as text.

Any ideas to get this working? The hint currently returns marker1_data select 1, rather than the array data in position 1.

Thanks in advance!

Rob

Edited by rexehuk

Share this post


Link to post
Share on other sites

Ah!

First: _line1 is text, you need to compile it if it should get a return value of that script.

Second: Why don't you use: _line1 = _roMarkerData select 1; to get the data?

Share this post


Link to post
Share on other sites
Ah!

First: _line1 is text, you need to compile it if it should get a return value of that script.

Second: Why don't you use: _line1 = _roMarkerData select 1; to get the data?

Didn't use _line1 = _roMarkerData select 1; because it does not work, again down to parsing and compiling... you say I need to compile it but I couldn't get it working?

Edited by rexehuk

Share this post


Link to post
Share on other sites

Replace

_roMarkerDATA = format["%1_data",_roPassMVAR];

with

_roMarkerDATA = call compile format["%1_data",_roPassMVAR];

so that _roMarkerDATA is an array instead of a string.

Share this post


Link to post
Share on other sites

Returns ANY. here is a list of what I've tried (not all of them)

//hint format["%1",_roMarkerData] + (" select 1");

//_line1 = call compile "[_roMarkerDATA] select 1";

//_line1 = format["%1",_roMarkerData] + (" select 1");

//_line1 = format["%1",_roMarkerData] + (" select 1");

//_line1 = compile _line1;

//_line1 = call _line1;

_line1 = _roMarkerData select 1;

hint format["Line one is %1",_line1];

marker1_data1 = marker1_data select 0;

ctrlSetText [13201,format["%1",_line1]];

As you can see I've been through a fair bit! For troubleshooting sake, marker1_data select 0 called works fine.

P.s. Thanks for the input, I love RTE :)

Edited by rexehuk

Share this post


Link to post
Share on other sites

Ok, stop:

Can you simple copy the content of _this to the clipboard, then parse it here and describe which things you want to get.

Because your way looks way to complicated for what you're describing.

Share this post


Link to post
Share on other sites

the _this that gets passed is simply a markername

marker1

marker2

If you really need the code, here it is:

	private["_markersDB","_markersIndex","_mapArray","_xHArray","_yHArray","_mHArray",
"_nmapArray","_mPosition","_roselMarker"];

_markersDB = markerArrayDB;
_markersIndex = count _markersDB;
_mapArray = _this select 0;

{ 
_xHArray = _mapArray select 0;
_yHArray = _mapArray select 1;
_mHArray = 0;
_nmapArray = [_xHArray,_yHArray,_mHArray];
_roSelectedMarker = format["%1",_x];
_mPosition = getMarkerPos (_x);
if((_mPosition distance _nmapArray) < 5) then
	{
		[_roSelectedMarker] call roFact_MarkerCall;
	};
} forEach markerArrayDB;

The marker array:

marker1_data = ["First","Second","Third","Fourth","Fifth","Sixth","Seventh"];

The script im having problems with

roFact_MarkerCall =
{
private["_roPassMVAR","_roMarkerData"];

_roPassMVAR = _this select 0;
//_roMarkerDATA = format["%1_data",_roPassMVAR];
_roMarkerDATA = call compile format["%1_data",_roPassMVAR];
hint format["Your have selected %1 \n and value has index of %2",_roPassMVAR,_roMarkerDATA];

_line1 = _roMarkerData select 1;

hint format["Line one is %1",_line1];
marker1_data1 = marker1_data select 0;
ctrlSetText [13201,format["%1",_line1]];


};

Edited by rexehuk

Share this post


Link to post
Share on other sites

_roPassMVAR = _this select 0;
{
_roMarkerDATA = call compile format["%1_data",_x]; //First_data
hint format["Your have selected %1 \n and value has index of %2",_x,_roMarkerDATA];

_line1 = _roMarkerDATA select 1;

hint format["Line one is %1",_line1];

ctrlSetText [13201, _line1];
} forEach _this;

Are you sure that First_data is set as a global variable?

Share this post


Link to post
Share on other sites

It is indeed, in the init.SQF

marker1_data = ["Jaynus Killed in Combat","Death","Location","26 1254 Oct 7th","Squad/Unit","Jaynus was shot in the head by a large

caliber round which tore his face off","Nou"];

publicVariable "marker1_data";

The markerArrayDB

markerArrayDB = ["Marker1","Marker2","Marker3","Marker4"];

publicVariable "markerArrayDB";

As previously mentioned calling marker1_data select 1 etc works fine, but I don't want to hard code it as it will be useless.

Edited by rexehuk

Share this post


Link to post
Share on other sites

Post your full changes here?

Still getting ANY returned on my end...

Share this post


Link to post
Share on other sites

I've tried this:

marker1_data = ["Jaynus Killed in Combat","Death","Location","26 1254 Oct 7th","Squad/Unit","Jaynus was shot in the head by a large caliber round which tore his face off","Nou"];

markerArrayDB = ["Marker1","Marker2"];

roFact_MarkerCall =
{
private["_roPassMVAR","_roMarkerData"];

_roPassMVAR = _this select 0;
_roMarkerDATA = call compile format["%1_data",_roPassMVAR];
Player sideChat str _roPassMVAR;
Player groupChat str _roMarkerDATA;

line1 = _roMarkerData select 1;
Player sideChat format["Line one is %1", line1];
marker1_data1 = marker1_data select 0;
};  

{ 
   _roSelectedMarker = format["%1",_x];
   [_roSelectedMarker] call roFact_MarkerCall;
} forEach markerArrayDB; 

Share this post


Link to post
Share on other sites

Sorry that won't work as the coding will break my project. Cheers for trying though, I suppose it's because you don't have the project.

P.s. Your above code returns any.

---------- Post added at 03:06 AM ---------- Previous post was at 01:44 AM ----------

Resolved

Edited by rexehuk

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  

×