Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[solved][C-Script] Crash using str_stri with text object strings #231049
10/11/08 18:26
10/11/08 18:26
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline OP
Expert
Xarthor  Offline OP
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
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.

Re: [C-Script] Crash using str_stri with text object strings [Re: Xarthor] #231051
10/11/08 18:32
10/11/08 18:32
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
what is mod_objects.string[i]
a struct,text,string


"empty"
Re: [C-Script] Crash using str_stri with text object strings [Re: flits] #231053
10/11/08 18:36
10/11/08 18:36
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline OP
Expert
Xarthor  Offline OP
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Quote:

So I have a text object named
mod_objects


please notice that this is C-Script as this project runs in A6

Re: [C-Script] Crash using str_stri with text object strings [Re: Xarthor] #231077
10/11/08 19:57
10/11/08 19:57
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
Red Dwarf
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...


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: [SOLVED] Crash using str_stri with text object strings [Re: Michael_Schwarz] #231143
10/12/08 10:34
10/12/08 10:34
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline OP
Expert
Xarthor  Offline OP
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
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!

Last edited by Xarthor; 10/12/08 11:07.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1