Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 4 New Array Functions #131

Merged
merged 14 commits into from
Sep 6, 2015
Merged

Added 4 New Array Functions #131

merged 14 commits into from
Sep 6, 2015

Conversation

jokoho48
Copy link
Member

Add 4 New Array Functions to Find First Entry of TypeOf, TypeName, Null or Nil in Array

@ViperMaul ViperMaul added this to the 2.1 milestone Aug 25, 2015
@Killswitch00
Copy link
Contributor

Since the "find" script command finds the first array element or string-within-string, these function names could perhaps be shortened somewhat. Also, "empty" in BIS scripting parlance is "nil". How about calling them

  • CBA_fnc_findNil finds the first nil entry
  • CBA_fnc_findNull finds the first null entry
  • CBA_fnc_findType finds the first entry of a certain type.

I love the included unit tests!

@MikeMatrix
Copy link
Contributor

I like @Killswitch00's names a lot more. They're very similar, to the point and short to type.

@jokoho48
Copy link
Member Author

is everything fine?

@Killswitch00
Copy link
Contributor

The unit tests are missing and the added unit test file could be renamed to, say, "test_find.sqf".

add some error handling
add Test Script
@jokoho48 jokoho48 changed the title Add 3 New Array Functions Add 4 New Array Functions Aug 30, 2015
@jokoho48
Copy link
Member Author

my question is did i need a test function? or not

_fn = "CBA_fnc_findTypOf";
LOG("Testing " + _fn);

TEST_DEFINED("CBA_fnc_findTypOf","");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that this unit test file hasn't been tested at all. Run it using

[] call compile preprocessFileLineNumbers "\x\cba\addons\arrays\test_find.sqf";


TEST_DEFINED("CBA_fnc_findNil","");

// Use of embeded nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"embedded"


Parameters:
0: Array
1: TypeName, if parameter is a string, that contains a case insensitive typename, it will be used. Otherwies typename of the variable will be used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Otherwise"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

God dammit :D


if (isNil "_typeName" || {_array isEqualTo []}) exitWith {-1};

// If a string is given, tansform to uppercase for type matching
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"transform"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better word for "transform" in this context is to use "convert"

Killswitch00 added a commit that referenced this pull request Sep 6, 2015
@Killswitch00 Killswitch00 merged commit 01ae894 into CBATeam:master Sep 6, 2015
@jokoho48 jokoho48 deleted the NewArrayFunctions branch September 6, 2015 11:56
@ViperMaul ViperMaul changed the title Add 4 New Array Functions Added 6 New Array Functions Oct 9, 2015
@ViperMaul ViperMaul changed the title Added 6 New Array Functions Added 4 New Array Functions Oct 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants