2 registered members (VoroneTZ, TipmyPip),
1,333
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Problem with a (hidden) endless LOOP
#201662
04/10/08 14:06
04/10/08 14:06
|
Joined: Dec 2006
Posts: 434 UK,Terra, SolarSystem, Milky W...
pararealist
OP
Senior Member
|
OP
Senior Member
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
|
Hello all, I am having a problem with an endless loop that i only discovered when i inserted a printf into the loop. I have packed it into a function, all you have to do is create a little program and call fDoTest() from main. The function should remove the path leaving the filename then remove the .wmb extension from filename and add .gsx extension to the filename.
// filled for testing - usually comes from fileselect dialog
char* filePathName = "D:\\GSTUDIO PROJECTS\\A7_PROJECTS\\PROJECTTEST\\atestfile.wmb"; //
//
STRING* aCurrentPath = " ";
aCurrentPath = str_create("aCurrentPath");
STRING* camPosName_str = " ";
camPosName_str = str_create("camPosName_str");
///////////////////////////////////////////////////////////////
function fDoTest()
{
draw_text("in fDoTest()",500,200,_vec(0,255,0 ));
int i = 0, j=0;
int count=0, len=0;
int pcount = 0;
// THIS LOOP seems to never end ????????????
// is strange - only found out whilst debugging
// yet app works (at least up to now)
// but is definately not right
// if i insert a printf in the while loop then i notice it
while (str_stri(_str(filePathName),"*") == 0)
{
// search for "\" until no more
len = str_len(_str(filePathName));
count = str_stri(_str(filePathName),"\\");
pcount = len-count;
// clip name from begin to "\"
str_clip(_str(filePathName),count);
// trunc name from end by (pcount - to "\") dont work ????
str_trunc(_str(aCurrentPath),pcount );
// store levelname
str_cpy(camPosName_str,_str(filePathName));
// split levelname. from ext (wmb))
len = str_len(camPosName_str);
count = str_stri(camPosName_str,"."); // search for "."
count = (len - count);
str_trunc(camPosName_str,count);
//
// add file ext (gsx) )
str_cat(camPosName_str,"gsx");
//
//
// UN-COMMENT next line to see printf in endless loop
// and i have to end printf in task manager
// yet COMMENTED runs ok
//printf("camPosName_str= %s",_chr(camPosName_str));
//
wait(1);
}
// DOES NOT seem to get to here
printf("aCurrentPath= %s",_chr(aCurrentPath));
printf("camPosName_str= %s",_chr(camPosName_str));
return;
}
Thanks for any help. I just cant see (at this time) the reason.
A8.3x Commercial, AcknexWrapper and VS 2010 Express ○pararealist now.
|
|
|
Re: Problem with a (hidden) endless LOOP
[Re: Excessus]
#201681
04/10/08 15:45
04/10/08 15:45
|
Joined: Dec 2006
Posts: 434 UK,Terra, SolarSystem, Milky W...
pararealist
OP
Senior Member
|
OP
Senior Member
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
|
Hi,
while {
wait(1); } you need wait(1) in while loop i thought. // so i would need to use a do while loop with the condition at the end? or how else can seperate the filename from the full pathname and then remove the extension to add another (diferent) extension?
A8.3x Commercial, AcknexWrapper and VS 2010 Express ○pararealist now.
|
|
|
Re: Problem with a (hidden) endless LOOP
[Re: pararealist]
#201685
04/10/08 15:55
04/10/08 15:55
|
Joined: Dec 2006
Posts: 434 UK,Terra, SolarSystem, Milky W...
pararealist
OP
Senior Member
|
OP
Senior Member
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
|
forgot to say i add str_cpy(aCurrentPath,filePathName); before loop.
in loop i use the pcount var to get the length. but now i see that i should have used? // store levelname str_cpy(camPosName_str,_str(aCurrentPath)); instead of // store levelname str_cpy(camPosName_str,_str(aCurrentPath));
will try this again.
A8.3x Commercial, AcknexWrapper and VS 2010 Express ○pararealist now.
|
|
|
Re: Problem with a (hidden) endless LOOP
[Re: pararealist]
#201686
04/10/08 15:56
04/10/08 15:56
|
Joined: Dec 2006
Posts: 434 UK,Terra, SolarSystem, Milky W...
pararealist
OP
Senior Member
|
OP
Senior Member
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
|
IGNORE LAST
forgot to say i add str_cpy(aCurrentPath,filePathName); before loop.
in loop i use the pcount var to get the length. but now i see that i should have used? // store levelname str_cpy(camPosName_str,_str(aCurrentPath)); instead of // store levelname str_cpy(camPosName_str,_str(filePathName));
will try this again.
A8.3x Commercial, AcknexWrapper and VS 2010 Express ○pararealist now.
|
|
|
SOLVED: Problem with a (hidden) endless LOOP
[Re: pararealist]
#201742
04/10/08 20:56
04/10/08 20:56
|
Joined: Dec 2006
Posts: 434 UK,Terra, SolarSystem, Milky W...
pararealist
OP
Senior Member
|
OP
Senior Member
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
|
SOLVED Decided to use a for LOOP.
function fDoTest()
{
int i = 0;
int count=0, len=0;
int pcount = 0;
//
str_cpy(aCurrentPath,filePathName);
//
// get length of filePathName
len = str_len(_str(filePathName));
for (i = 0; i < len; i++)
{
// search for "\" until no more
count = str_stri(_str(filePathName),"\\");
pcount = len-count;
// clip name from begin to "\"
str_clip(_str(filePathName),count);
// store levelname
str_cpy(camPosName_str,_str(filePathName));
// split name. from ext (wmb))
len = str_len(camPosName_str);
// search for "."
count = str_stri(camPosName_str,".");
count = (len - count);
// truncate it
str_trunc(camPosName_str,count);
//
// add file ext (gsx) )to get campos filename for this level
str_cat(camPosName_str,"gsx");
}
//
printf("camPosName_str= %s",_chr(camPosName_str));
return;
}
A8.3x Commercial, AcknexWrapper and VS 2010 Express ○pararealist now.
|
|
|
|