**ACS.NET**

Created by: Visual Vincent

**What is this?**

ACS.NET is an ACS library for Zandronum where I've implemented some functions that are similar to those in the .NET Framework.

Of course there is more than just .NET Framework functions, this is a library with a bunch of useful functions for ACS.

Well, I guess the above explains it pretty much...

So here are the functions currently available:

Spoiler: Available functions(Open)Spoiler: From v1.0.0 and up(Open)Spoiler: StringReplace(Open)-- StringReplace --

Replace a specified substring in a string with another substring x amount of times.

Note that this is case sensitive.

InputString: The string containing the substring to replace.

FindString: The substring to search for.

ReplaceString: The substring that will replace the found substring.

Start: The position in the InputString to begin the search for the substring. (Zero-based)

Count: The amount of replacements that will be done (0 = Replace all found substrings).

Example usage: StringReplace("Shopping List", "o", "i", 0, 0);

Example will return: "Shipping List"Spoiler: StringSplit(Open)-- StringSplit --

Split string into array. The substrings will be put in the StringArray[] array.

Use the StringOccurences variable to get how many strings were put in the array.

InputString: The string to split up into an array.

Delimiter: A single char used to identify substring limits.

Limit: Maximal number of substrings the string should be splitted into. (-1 = Split until it reaches the max limit)

Example usage: StringSplit("Hello+There+Friend!", "+", -1);

Example will put in array: "Hello","There","Friend!"Spoiler: SplitArrayToString(Open)-- SplitArrayToString --

Writes the StringArray[] array of substrings down to a string. (One substring per line)Spoiler: ClearSplitArray(Open)-- ClearSplitArray --

Clears the StringArray[] array that holds all the strings gathered from the StringSplit() function.Spoiler: StringFind(Open)-- StringFind --

Retrieve the index of a substring in the specified string.

InputString: The string to search for the substring in.

LookFor: The substring to look for.

Start: The position in the string to begin the search for the substring. (Zero-based)

Example usage: StringFind("Hello mate!", "o", 0);

Example will return: 4Spoiler: StringFindLast(Open)-- StringFindLast --

Retrieve the last index of a substring in the specified string.

InputString: The string to search for the substring in.

LookFor: The substring to look for.

Example usage: StringFindLast("Donald Duck", "D");

Example will return: 7Spoiler: StringSubstring(Open)-- StringSubstring --

Retrieve a part of the specified string.

InputString: The string to substring.

Start: The startposition of the substring. (Zero-based)

Length: The amount of characters to get from the InputString. (-1 = Get the rest of the string)

Example usage: StringSubstring("Well, Hello There Friend!", 6, 11);

Example will return: "Hello There"Spoiler: ConcatenateStrings(Open)-- ConcatenateStrings --

Join two or more strings together.

Count: The amount of strings to join. (Allowed range: 2-4)

String 1: The first string to join with the second string.

String 2: The second string to join with the first string. (And also with the third string if Count is set to more than 2)

String 3: The third string to join with the first and second string. (And also with the fourth string if Count is set to more than 3)

String 4: The fourth string to join with the first, second and third string.

Example usage: ConcatenateStrings(3, "Hello ", "There!", " Who are you?", "");

Example will return: "Hello There! Who are you?"Spoiler: StringJoin(Open)-- StringJoin --

Concatenates String1 and String2 with the specified Separator in-between.

Separator: The separator string to put between String1 and String2.

String1: The first string to concatenate with the second one.

String2: The second string to concatenate with the first one.

Example usage: StringJoin(" += ", "150", "5");

Example returns: "150 += 5"Spoiler: StringToCharArray(Open)-- StringToCharArray --

Convert a string into an array of chars.

The chars will be put in the CharArray[] array.

Use the CharArrayLength variable to check how many chars there is in the array.

InputString: The string to convert to a char array.

Example usage: StringToCharArray("Hello");

Example will put in array: "H","e","l","l","o"Spoiler: ClearCharArray(Open)-- ClearCharArray --

Clears the CharArray[] array from all chars.Spoiler: CharArrayToString(Open)-- CharArrayToString --

Converts the CharArray[] array to a string.

Example usage: CharArrayToString();

If CharArray[] is like following: "H","e","l","l","o"

Example will return: "Hello"Spoiler: CharArrayIndexToString(Open)-- CharArrayIndexToString --

Converts a part of the CharArray[] array to a string.

Start: The position from where to get the first character from the char array to put in the string. (Zero-based)

End: The position from where to get the last character from char array to put in the string. (Zero-based)

Example usage: CharArrayIndexToString(1, 3);

If CharArray[] is like following: "H","e","l","l","o"

Example will return: "ell"Spoiler: From v1.2.0 and up(Open)Spoiler: StringCompare(Open)-- StringCompare --

Compare two strings with each other.

Str1: The first string to compare with the second one.

Str2: The second string to compare with the first one.Spoiler: StringRemove(Open)-- StringRemove --

Deletes a specified amount of characters from the specified start position of the string.

InputString: The string to manipulate.

Start: The position where to begin deleting characters. (Zero-based)

Count: The number of characters to delete.

Example usage: StringRemove("Hello There!", 2, 2);

Example returns: "Heo There!"Spoiler: StringContains(Open)-- StringContains --

Returns a boolean value indicating wether the specified string

is present in InputString.

InputString: The string to check.

LookFor: The string to look for in InputString.

Example usage: StringContains("ABCDEFG", "D");

Example returns: TrueSpoiler: StringStartsWith(Open)-- StringStartsWith --

Returns a boolean value indicating wether InputString starts with

the specified string.

InputString: The string to check.

LookFor: The string to look for in the start of InputString.

Example usage: StringStartsWith("ABCDEFG", "ABC");

Example returns: True

..

2nd Example usage: StringStartsWith("ABCDEFG", "FG");

2nd Example returns: FalseSpoiler: StringEndsWith(Open)-- StringEndsWith --

Returns a boolean value indicating wether InputString ends with

the specified string.

InputString: The string to check.

LookFor: The string to look for in the end of InputString.

Example usage: StringEndsWith("ABCDEFG", "FG");

Example returns: True

..

2nd Example usage: StringEndsWith("ABCDEFG", "ABC");

2nd Example returns: FalseSpoiler: StringInsert(Open)-- StringInsert --

Inserts a specified substring in the specified string.

InputString: The string to manipulate.

Start: Where the substring will be inserted. (Zero-based)

InsertStr: The substring to insert.

Example usage: StringInsert("Hello my friend!", 5, " There");

Example returns: "Hello There my friend!"Spoiler: StringSpace(Open)-- StringSpace --

Returns a string consisting of the specified amount of spaces.

Count: The amount of spaces you want in the string.

Example usage: Str HelloWorld = StrParam(s:"Hello", StringSpace(5), s:"World!");

Example returns:Code: Select all

`"Hello World!"`

Spoiler: StringReverse(Open)-- StringReverse --

Reverses the character order in a string.

String: The string to reverse.

Example usage: StringReverse("Hello There!");

Example returns: "!erehT olleH"Spoiler: StringSelect(Open)-- StringSelect --

Mark parts of the specified string with a specified color.

InputString: The string to manipulate.

Select: What to select.

Color: The color to use when selecting: CR_... (I.e CR_YELLOW).

Start: Where to in InputString to start looking. (Zero-based)

SelectAll: True: Select all occurences.

Example usage: StringSelect("I like cookies!", "like", CR_RED, 0, False);

Example returns: "I like cookies" - Where "like" is drawn in red color.Spoiler: IIf_Int(Open)-- IIf_Int --

Returns one of two integers, depending on the evaluation of an expression.

Expression: The expression you want to evaluate.

TruePart: The integer returned if Expression equals to True.

FalsePart: The integer returned if Expression equals to False.

Example usage: IIf_Int(5 > 3, 65536, 32768);

Example returns: 65536

..

Why?:

5 is greater than 3. That's why the function returns the TruePart, which is 65536.Spoiler: IIf_Str(Open)-- IIf_Str --

Returns one of two strings, depending on the evaluation of an expression.

Expression: The expression you want to evaluate.

TruePart: The string returned if Expression equals to True.

FalsePart: The string returned if Expression equals to False.

Example usage: IIf_Str(5 > 3, "This is correct", "This is incorrect");

Example returns: "This is correct"

2nd Example usage: IIf_Str("Hello" == "There", "This is correct", "This is incorrect");

2nd Example returns: "This is incorrect"

..

Why?:

1st: 5 is greater than 3. That's why the function returns the TruePart, which is "This is correct".

2nd: The string "Hello" is not equal to "There".

That's why the function returns the FalsePart, which is "This is incorrect".Spoiler: IIf_Bool(Open)-- IIf_Bool --

Returns one of two booleans, depending on the evaluation of an expression.

Expression: The expression you want to evaluate.

TruePart: The boolean returned if Expression equals to True.

FalsePart: The boolean returned if Expression equals to False.

Example usage: IIf_Bool(5 > 3, True, False);

Example returns: True

2nd Example usage: IIf_Bool(5 > 3, False, True);

2nd Example returns: FalseSpoiler: IsTrue(Open)-- IsTrue --

Checks wether an expression equals to False.

Expression: The expression to check.

Example usage: IsTrue(5 < 3);

Example returns: False

..

Why?:

The function returns False because 5 is not less than 3.Spoiler: IsFalse(Open)-- IsFalse --

Checks wether an expression equals to False.

Expression: The expression to check.

Example usage: IsFalse(5 < 3);

Example returns: True

..

Why?:

The function returns True because it's correct that 5 is not less than 3.Spoiler: IsNot_Int(Open)-- IsNot_Int --

Checks if two integers ARE NOT the same.

Returns True if they aren't.

Int1: The first integer to check with the other.

Int2: The second integer to check with the first.

Example usage: IsNot_Int(5, 3);

Example returns: True

..

Why?:

The function returns True because 5 does not equal to 3.Spoiler: IsNot_Str(Open)-- IsNot_Str --

Checks if two strings ARE NOT the same.

Returns True if they aren't.

Str1: The first string to check with the other.

Str2: The second string to check with the first.

Example usage: IsNot_Str("Hello", "Hello");

Example returns: False

..

Why?:

The function returns False because Str1 IS ACTUALLY equal to Str2.Spoiler: Math_Factorial(Open)-- Math_Factorial --

Calculate the factorial of a number.

number: The number to use for the calculation.

Example usage: Math_Factorial(6);

Example returns: 720

..

Why?:

Math_Factorial(6) = 720 because 6! = 6*5*4*3*2*1 = 720.Spoiler: Math_Hypotenuse(Open)-- Math_Hypotenuse --

Calculate the hypotenuse of a triangle.

side1: The first side of the triangle.

side2: The second side of the triangle.

Example usage: Math_Hypotenuse(5, 8);

Example returns: 9

..

Why?:

The square root of 5^2 + 8^2 equals the

sqaure root of 25 + 64 which equals to 9,433981132056604.

And because Doom rounds the number down, it's rounded to 9.Spoiler: Math_TriangleSide(Open)-- Math_TriangleSide --

Calculate one side of a triangle using it's hypotenuse

and the other side.

Hypotenuse: The triangle's hypotenuse.

side1: One side of the triangle.

Example usage: Math_TriangleSide(9, 8);

Example returns: 5Spoiler: Math_AreaOfCircle(Open)-- Math_AreaOfCircle --

Calculate the area of a circle.

Originally, this function gets overloaded when

using a radius greater than 102.

In order to prevent this, the function will

automatically use PI as 3 instead for numbers

greater than 102.

Radius: The radius of the circle.

Example usage: Math_AreaOfCircle(5);

Example returns: 78

..

Why?:

The area of a circle is calculated (r^2) * PI.

And because Doom rounds it's numbers down,

3,14159265358979323846 * 25 = 78,5398163397448309615 (rounded to: 78)Spoiler: Math_VolumeOfSphere(Open)-- Math_VolumeOfSphere --

Calculate the volume of a sphere.

Originally, this function easily got overloaded.

To prevent this from happening, it automatically calculates

the volume using PI as 3, instead of

the fixed point 3.14159265358979323846, for numbers over 13.

Radius: The radius of the sphere.

Example usage: Math_VolumeOfSphere(5);

Example returns: 523

..

Why?:

The volume of a sphere is calculated ((r^3) * (4*PI)) / 3.

And because Doom rounds it's numbers down,

(12,56637061435917295384 * 125) / 3 = 523,59877559829887307666666666667 (rounded to: 523)Spoiler: PlayerName(Open)-- PlayerName --

Returns the name of the specified player.

number: The number of the player which's name to get.

--- Constants/macros (#Define, #LibDefine) ---Spoiler: Math_PI(Open)-- Math_PI --

Math's PI as fixed point.Spoiler: Math_e(Open)-- Math_e --

Math's e as fixed point.Spoiler: IntegerMaxValue(Open)-- IntegerMaxValue --

The maximum possible value of an Integer.Spoiler: IntegerMinValue(Open)-- IntegerMinValue --

The minimum possible value of an Integer.Spoiler: From v1.2.2 and up(Open)Spoiler: ParseInt(Open)-- ParseInt --

Parse (convert) an integer out of a string.

WARNING:

The input MUST be of type String (Str).

If the input is of type Integer (Int) and the

integer is too big, it will cause the game to crash!

InputString: The string to parse to integer.

Example usage: ParseInt("32767");

Example returns: 32767 (as Int)Spoiler: From v1.2.3 and up(Open)Spoiler: ParseFloat(Open)-- ParseFloat --

Parse (convert) a string to fixed point.

WARNING:

The input MUST be of type String (Str).

If the input is of type Integer/Fixed point (Int) and

it's too big, it will cause the game to crash!

InputString: The string to parse to fixed point.

Example usage: ParseFloat("1.375");

Example returns: 1.375 (or 90112 as a normal Int)

INTEGRAL MAX INPUT: 32767

FRACTIONAL MAX INPUT: .32767

-> This means that the largest parsable

fixed point is 32767.32767, or else it

will overflow.

Ex:32800.0will overflow,3.45849will overflow.Spoiler: From v1.2.4 and up(Open)Spoiler: Math_Abs(Open)-- Math_Abs --

Return the absolute value of a negative integer.

Example usage: Math_Abs(-32);

Example returns: 32

2nd Example usage: Math_Abs(135);

2nd Example returns: 135

**Case sensitivity**

Sadly all find/replace functions are case sensitive, which means that when for example searching for the string "wood" in "woodchuck", "wood" must have the same casing as the "wood" in "woodchuck". So for example "Wood" or "WOOD" or "WooD" won't match.

Also note that most of the search/replace functions are capable of finding whole strings and not just characters (letters)!

**Changelog**

**v1.2.4**

* Fixed so that ParseInt and ParseFloat supports parsing of negative numbers.

* Included Math_Abs with the library (required for ParseFloat to work).

**v1.2.3**

* Added a ParseFloat function to parse strings to fixed point!

**v1.2.2**

* Fixed bugs with StringReplace and StringSubstring. (I.e StringReplace won't replace text if it's in the very end of the string)

* Added a ParseInt function to parse/convert strings to integers!

**v1.2.1:**

* Removed the Math_PI, Math_e, IntegerMinValue, IntegerMaxValue functions and replaced them with macros. (#LibDefine)

Note that the macros still have the same name as the functions. :)

**v1.2.0:**

* Added tons of new functions!

(Check the function list above, under "v1.2.0 and up")

* Updated the example WAD.

* Bug fixes.

**Example WAD in action!**

Spoiler: Video(Open)phpBB [video]The [video] tag is deprecated, please use the [media] tag

**Problems or suggestions?**

If you are experiencing any problems with this library, OR if you just have got any suggestions regarding it (i.e implementation suggestions, fixes etc.):

Contact me on this forum or on support@mydoomsite.com

The above applies for questions and help too. :)

Have fun!