Question about strings

Posted By: Frits

Question about strings - 03/22/07 12:02

I create an entity with
Code:

string sign;
string str00;
string str01="m_number_0";
string str02;
string str03=".bmp";

funtion show_sign_event()
{
..............
str_for_asc(str02,sprite_number+48); //change 1 to 9 into a string "1" to "9"
str_cat(str00,str01); //append str00 with str01
str_cat(str00,str02); //append str00 with str02
str_cat(str00,str03); //append str00 with str03
..............
..............
str_cpy(sign,str00); //copy str00 into sign
str_cpy(str00," "); //empty str00 for nex filename

sign_number=ent_create(sign,sgn05.x,modify_sprite_event); //load the sprite
}


the first file loads perfectly, but with the second file I get an error;
Mailfunction W1301
<M_NUMBER_02.BMP>: can't open file

Now this is strange because all these files are in the same directory (images) and in the script where to find these files; 'path "..\\images";'.
Has anyone an idea how this is possible?
Posted By: Anonymous

Re: Question about strings - 03/22/07 13:09

replace str_cat(str00,str01); with str_cpy(str00,str01); and remove line str_cpy(str00," ");.

With the second call your name is like this: " M_NUMBER_02.BMP" (watch the space in the first pos!)

mercuryus


PS: why not use str_for_num(str02,sprite_number); instead of str_for_asc(str02,sprite_number+48);?
Posted By: xXxGuitar511

Re: Question about strings - 03/22/07 13:15

Deleted...
Posted By: xXxGuitar511

Re: Question about strings - 03/22/07 13:16

Ha, Mercuryus got to it before me, and caught the error as well...

Thanks... lol.
Posted By: Frits

Re: Question about strings - 03/22/07 15:01

Thanks Mercuryus, I did not notice the space in front of the name and I did not know that I could use 'str_for_num', thanks for that also.

xXxGuitar511, sorry you were just too late
© 2023 lite-C Forums