[solved][C-Script] Crash using str_stri with text object strings

Posted By: Xarthor

[solved][C-Script] Crash using str_stri with text object strings - 10/11/08 18:26

Greetings,
I'm currently trying to compare one string element of a text object with another one using str_stri as I just need to know if one is appearing in the other one.

So I have a text object named
mod_objects

and another one named
mod_FileFormats

they are both defined before the function and properly filled with content.
Now I'll post the bit of code that results in a E1513 crash:
Code:
function modSys_SortObjects()
{
	var i;
	
	// cycle through the whole Mod Objects string array
	i = 0;
	while(i < nro_ModObjects)
	{
		// is it a model (fleet) file?
		if(str_stri(mod_objects.string[i],mod_FileFormats.string[0]))
		{
			str_cpy(mod_fleets.string[counter_fleets],mod_objects.string[i]);
			counter_fleets += 1;
		}
 (...)

This is the begining of a function (obviously) and it crashes at the if(str_stri ...) line

I tried:
- starting with 1 as id for the string elements => still crashing
- using a character sequenz in the str_stri at second place, e.g. ".mdl" and "mdl", both => crash

any idea what I'm doing wrong here?

Thanks in advance!

edit:
counter_fleets is a previously defined variable starting with zero aswell.
Posted By: flits

Re: [C-Script] Crash using str_stri with text object strings - 10/11/08 18:32

what is mod_objects.string[i]
a struct,text,string
Posted By: Xarthor

Re: [C-Script] Crash using str_stri with text object strings - 10/11/08 18:36

Quote:

So I have a text object named
mod_objects


please notice that this is C-Script as this project runs in A6
Posted By: Michael_Schwarz

Re: [C-Script] Crash using str_stri with text object strings - 10/11/08 19:57

you need to copy(str_cpy) the string from your text object to a regular string before you can compare it.

Just a bug in A6...
Posted By: Xarthor

Re: [SOLVED] Crash using str_stri with text object strings - 10/12/08 10:34

Thanks michael!
Just tested it outside of the project by writing the modul from the bottom up.
It is indeed necessary to copy the content of the text object to a string.
But only the first one.

str_stri(string1,string2)

string1 needs to be a string, while string2 can be an element of a text object.

str_stri(object_tmp,format.string[i]) is thus a valid operation which I can use now.

Thanks again!
© 2024 lite-C Forums