Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / empty array doesn't actually delete anything?

Author
Message
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Jan 2011 05:55
I'm loading data from two different files. Whenever a file is loaded, I call empty array before adding the new file's elements. The first file contains 10 elements, the second contains 19. I also print out a log and get the following:

Load file 1
Size after empty array: -1
Size after loading file 1: 10

Load file 2
Size before loading: 10
Size after empty array: -1
size after loading file 2: 29

Now if file 2 only contains 19 elements, and the array size reports -1 after emptying it, why then do I still have the original 10 elements in the array?

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 6th Jan 2011 08:22 Edited at: 6th Jan 2011 08:23
We need a little for info:
1)How are you adding to the array?
2)How are you getting the size of the array?
3) How are you emptying the array?
Try this
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Jan 2011 14:10
Ok, so apparently it missed a little "feature" in my xml library. When reading XML files and extracting the tag elements into an array, the array will hold all previous tags when reading multiple xml files unless I call xmlClear() before xmlReadFile(). I forgot that I made xmlReadFile() work in this manner, so it's my own dumb mistake.

So nevermind!

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 6th Jan 2011 23:01
Hey, don't worry, your little mistake gave me a chance to write some test code...cool!

Login to post a reply

Server time is: 2026-07-18 02:08:48
Your offset time is: 2026-07-18 02:08:48