Author Topic: String work  (Read 877 times)

Working with strings a bit. Gonna update this if I need any help.
1: Is there any kind of strContains function? Basically to see if a string contains some kind of word?
%str = "Hello there";
if(strContains(%str,"Hello"))
echo("contains");

if(striPos(%str, "string") != -1)

strStr(%str, "asdf") would return the position inside %str "asdf" is located at and returns -1 if it doesn't exist. You could use that to make a strContains function.

Code: [Select]
function strContains(%strA, %strB)
return strStr(%strA, %strB) != -1;
« Last Edit: July 03, 2012, 12:37:14 AM by Scars75 »

strStr(%str, "asdf") would return the position inside %str "asdf" is located at and returns -1 if it doesn't exist. You could use that to make a strContains function.

Code: [Select]
function strContains(%strA, %strB)
return strStr(%strA, %strB) != -1´;
What



reward for most confusing coding help topic this month

congratulations

ANOTHER QUESTION completely unrelated! Is there a limit to the number of args you can send to a client?

ANOTHER QUESTION completely unrelated! Is there a limit to the number of args you can send to a client?

I know for sure that the maximum number of arguments in a function is 19. It might be less for networking stuff.

I am trying to use 8 and it seems slayer has a clientCmd that uses 8 so it must work. The problem is I keep trying but the 8th argument doesn't seem to be received (or sent?). Is there a data limit?

I am trying to use 8 and it seems slayer has a clientCmd that uses 8 so it must work. The problem is I keep trying but the 8th argument doesn't seem to be received (or sent?). Is there a data limit?
Did you test appropriately? Like, echos and manual data passed to the function?

yes i did test all of that DUH. i guess i did that all more nothing because it turns out i overwrote the function somewhere else without including that extra arg!

Functions used through networking have the same argument limit as normal functions, however the maximum amount of data you can receive from one packet is ~256 bytes.

How do you calculate the amount of bytes something is?

How do you calculate the amount of bytes something is?

strLen(string), assuming Torque doesn't use some forgeted up character system.