|
|
Re: Weird problem with strings...
[Re: Matt_UK]
#334548
07/23/10 21:02
07/23/10 21:02
|
Joined: Jul 2009
Posts: 80 Area 51
fangedscorpion
Junior Member
|
Junior Member
Joined: Jul 2009
Posts: 80
Area 51
|
You cannot equate strings the same way that you can with variables.
Instead to make 2 strings equal you must use:
str_cpy(STRING* name, characters) //the characters are a set of numbers etc enclosed in the "" marks or the name of another string.
for your code you could write:
function loadLevel(STRING* name) { STRING* fullpath; str_cpy(fullpath, name); //this sets fullpath = to the name string str_cat(fullpath, "\\config.cfg"); }
//rest of your code here
See if that helps
Last edited by fangedscorpion; 07/23/10 21:02.
"Pow! You are dead! Not big suprise!" -Heavy
|
|
|
Re: Weird problem with strings...
[Re: DJBMASTER]
#334554
07/23/10 21:50
07/23/10 21:50
|
Joined: Dec 2005
Posts: 116
tD_Datura_v
Member
|
Member
Joined: Dec 2005
Posts: 116
|
function loadLevel(STRING* name);
{
STRING* fullpath = name;
str_cat(fullpath, "\\config.cfg"); // At this line I recieve a "Invalid Arguments in loadLevel" error?
}
function main()
{
loadLevel("map1");
}
Erroneous semicolon after function loadLevel. "map1" might be an immutable char* const(ant), which might not be passed as a STRING* argument to function loadLevel.
|
|
|
Re: Weird problem with strings...
[Re: fangedscorpion]
#334558
07/23/10 22:26
07/23/10 22:26
|
Joined: Jul 2009
Posts: 80 Area 51
fangedscorpion
Junior Member
|
Junior Member
Joined: Jul 2009
Posts: 80
Area 51
|
Try this code then:
function loadLevel(STRING* name) { STRING* fullpath = "";//this creates an empty string str_cpy(fullpath, name); //this sets fullpath = to the name string str_cat(fullpath, "\\config.cfg"); }
Then add in the main
function main() { levelLoad("map_name"); }
I have tried this and it should work
fangedscorpion
"Pow! You are dead! Not big suprise!" -Heavy
|
|
|
Re: Weird problem with strings...
[Re: fangedscorpion]
#334559
07/23/10 22:38
07/23/10 22:38
|
Joined: May 2010
Posts: 22
Matt_UK
OP
Newbie
|
OP
Newbie
Joined: May 2010
Posts: 22
|
Thanks for the replies guys! Got it working now thanks to your solutions  . I'll have to remember to try and initialize things if they don't work in the future XD. Thanks again, Matt.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|
|
|