PDA

View Full Version : serious error with file.delete


Solmos
01-12-2007, 03:05 PM
when using scrip to eliminate a file by means of file.delete leaves an error to me that puts:

Error

C stack overflow

some suggestion?

thx!

RizlaUK
01-12-2007, 03:55 PM
here, i googled it and got this

http://www.devx.com/tips/Tip/14276
Understanding Stack Overflow
The stack is a region of memory on which local automatic variables are created and function arguments are passed. The implementation allocates a default stack size per process. On modern operating systems, a typical stack has at least 1 megabyte, which is sufficient for most purposes. Under anomalous conditions, the program exceeds its stack limit. This causes a stack overflow. The two most common causes for a stack overflow is an infinite recursion, as in:


int f(){
g();
}
int g() {
f();
}

f() calls g(), which in turn calls f() and so on. Eventually, the stack overflows. Another common cause for stack overflow is an attempt to create a large array on the stack, for example:


int main()
{
int n[10000000]; // array is too large
int j =0; //j's address exceeds the stack's limits, error
}

If your program crashes due to a stack overflow, check for infinite recursion or too large local objects.

so i would take it that your code is doing to much for your machine or your code is causing a error that ams dosent pick up on and the loop is overloading your memory

TJS
01-13-2007, 08:58 AM
RizlaUK is right. Stack overflows are common if you create an infinite loop in your AMS script. Try posting the chunk of code in question if need help finding the problem.

Solmos
01-13-2007, 10:39 AM
ok

this is my code:

d = ListBox.GetCount("ListBox1");
if d == 0 then
Application.ExitScript();
end

aaa = ListBox.GetSelectedCount("ListBox1");
if aaa == 0 then
Dialog.Message("NONE", "none selected", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
Application.ExitScript();
end

sel = ListBox.GetSelected("ListBox1");
if sel then

LBData = ListBox.GetItemData("ListBox1", sel[1]);

File.Delete(LBData, false, false, false, nil);
error = Application.GetLastError();
if (error ~= 0) then

ListBox.DeselectItem("ListBox1", sel[1]);

gg = ListBox.GetSelectedCount("ListBox1");
if gg == 0 then
Dialog.Message("Error", "error deleting items", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
Application.ExitScript();
end

else

ListBox.DeleteItem("ListBox1", sel[1]);

end

result = ListBox.GetSelectedCount("ListBox1");
if result == 0 then
else
Page.ClickObject("Plugin7"); ------(this action returns to press plugin that has this scrip to eliminate the following selected item)
end

end

this I cosay this based on which put RizlaUK to me to eliminate all the archives selected of listbox, by means of the multiselection

some suggestion please?

thx!

RizlaUK
01-13-2007, 11:02 AM
here, try this

Solmos
01-13-2007, 03:13 PM
that example is equal for which I use, is no ningun change no?

some suggestion to avoid the error of C stack overflow?

thanks

RizlaUK
01-13-2007, 04:44 PM
well, the strange thing is that your code works on my system causeing no errors at all, i made that example with your code

i put 50 txt files in a folder and got them in the listbox, push the delete button and it all worked fine, i posted it for you to try so i could assess weather the problem was in this code or in another part of your project

as there is no error on my system i can not even begin to assess what bit of code is causeing it,

my frist question to you would be "how much ram do you have" and "whats the speed of your cpu (MHz)"

Solmos
01-15-2007, 05:02 AM
if, my code works well, but ami me aparecio that message of error and not because. my CPU pentium 4 3GH ram 1 GB

RizlaUK
01-15-2007, 11:42 AM
well, it was a stab in the dark,, have a go at rewriting the function a differant way and see if you still get any error,

or explain in detail what it is you want to do and ill try and make a example for you

Solmos
01-19-2007, 05:21 AM
this it is an example when it leaves this message:

digale to autorrun that _TemFolder looks for all the archives of the folder;

in which you previously to position a great amount of unsuitable archives (about 600 megas, divided in about 100 archives... for example, premium 7.7.5.1 unloaded Nero 7 and when going to install it all those archives they will be in _ TempFolder)

say to autorrun that it looks for in temp and shows all the archives to him in listbox, later check all and deletting all. when it takes about 200 eliminated megas will give that error:

error

C stack overflow

some suggestion?