Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Out of id numbers?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
PmEe




PostPosted: Tue Dec 14, 2004 3:30 pm   Post subject: Out of id numbers?

When i run my program for 1-2 minutes an error pops up Cannot allocate items: out of id numbers (max 1000)


how do i fix this
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Tue Dec 14, 2004 3:34 pm   Post subject: (No subject)

It would really help if you posted your code so that we could see why this is happening.

I have a feeling you're using Pic.New() functions in a loop without using Pic.Free(), but until i see the code I can't be sure.
PmEe




PostPosted: Tue Dec 14, 2004 3:36 pm   Post subject: (No subject)

Yeah I am I was just about to post the code but the problem i had using pic.free with loops was it would exit the run and say variable was freed


code:
process movement
    loop
        Pic.Draw (grass1, 0, 0, picCopy)
        Input.KeyDown (chars)
        if chars ('w') then
            y (1) := y (1) + 2
            view := 1
            Pics (1) := Pic.FileNew ("char1.bmp")
            if x (1) < x (2) + 27 and x (1) > x (2) - 27 and y (1) > y (2) - 27 and y (1) < y (2) + 27 then
                y (1) := y (1) - 5
            end if
        end if
        if chars ('d') then
            x (1) := x (1) + 2
            view := 2
            Pics (1) := Pic.FileNew ("charright1.bmp")
            if x (1) < x (2) + 27 and x (1) > x (2) - 27 and y (1) > y (2) - 27 and y (1) < y (2) + 27 then
                x (1) := x (1) - 5
            end if
        end if
        if chars ('a') then
            x (1) := x (1) - 2
            view := 3
            Pics (1) := Pic.FileNew ("charleft1.bmp")
            if x (1) < x (2) + 27 and x (1) > x (2) - 27 and y (1) > y (2) - 27 and y (1) < y (2) + 27 then
                x (1) := x (1) + 5
            end if
        end if
        if chars ('s') then
            y (1) := y (1) - 2
            view := 4
            Pics (1) := Pic.FileNew ("charfront1.bmp")
            if x (1) < x (2) + 27 and x (1) > x (2) - 27 and y (1) > y (2) - 27 and y (1) < y (2) + 27 then
                y (1) := y (1) + 5
            end if
        end if
        if chars ('.') and doo = 20 then
            fork attack
        end if
        doo += 1
        if doo > 20 then
            doo := 20
        end if
        if x (1) >= 640 then
            x (1) := x (1) - 40
        end if
        if x (1) <= 0 then
            x (1) := x (1) + 40
        end if
        if y (1) >= 480 then
            y (1) := y (1) - 40
        end if
        if y (1) <= 0 then
            y (1) := y (1) + 40
        end if
        Pic.Draw (Pics (1), x (1), y (1), picMerge)
        View.Update
        delay (10)
        cls
    end loop
end movement
Tony




PostPosted: Tue Dec 14, 2004 4:56 pm   Post subject: (No subject)

you're declearing too many pictures... I not quite sure how you possibly managed to do that, since you have a grand total of four Confused

how about trying to use 4 different variables to hold 4 different pictures?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
SuperGenius




PostPosted: Tue Dec 14, 2004 5:33 pm   Post subject: (No subject)

I got the same error when I was using a Font.Draw command inside a loop to increase the colour attribute each time the loop ran. It would work fine for a few seconds and then crash. I never got around to fixing that though.
Delos




PostPosted: Tue Dec 14, 2004 9:22 pm   Post subject: (No subject)

Hmm...try this:

Set up a seperate procedure that refreshes your pictures...
This will first of all Free the picture (given that a pic already exists w.r.t. that var)
Then it will recreate the pic.

Ensure that all your creation references (Pic.FileNew() etc) are out of the loop, then call them within the loop.
Also, don't use processes!!!!!. You've got the right idea, just set it up in a looping procedure instead, it will make your life easier.
pluckster




PostPosted: Wed Dec 15, 2004 1:53 pm   Post subject: (No subject)

i see your problem. i did it while making my antAI thing
Quote:
loop
Pic.Draw (grass1, 0, 0, picCopy)
Input.KeyDown (chars)
if chars ('w') then
y (1) := y (1) + 2
view := 1
Pics (1) := Pic.FileNew ("char1.bmp")


if you have Pic.FileNew in a loop then it will make a new picid for each time it makes that picture even iif youve already done it before. just put all of those before the loop and youll be fine.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: