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

Username:   Password: 
 RegisterRegister   
 Cannot allocate item. Out of id numbers (max 1000)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
turing324




PostPosted: Sat May 16, 2015 7:36 am   Post subject: Cannot allocate item. Out of id numbers (max 1000)

What is the problem you are having?
<Im trying to use pictures in my program and I have them move with the arrow keys but when I try to rotate the picture I get the error Cannot allocate item. Out of id numbers (max 1000)>


Describe what you have tried to solve this problem
<I have already tried Pic.Free but when I do that it justs gives me the error "Pic was freed" and the program dosen't work >


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
>

Turing:


<%setscreen ("graphics, offscreenonly")
%var x,y,x1,y1,d : int
var key : string(1)
var pictureID : int
var picHeight, picWidth,x,y,pic,d,rotatex,rotatey, angle,newpic : int
x := 0
y := 0
procedure formatPicture
    pictureID := Pic.FileNew("CarUp.jpg")
    picHeight := Pic.Height(pictureID)
    picWidth := Pic.Width(pictureID)
    pic := Pic.Scale(pictureID,picWidth,picHeight)
end formatPicture
formatPicture
setscreen("offscreenonly")
setscreen ("noecho")
setscreen ("nocursor")
% x := 0
% y := 0
% x1 := 50
% y1 := 50
key := ""
d := 10
%drawfillbox(x,y,x1,y1,blue)
Pic.Draw(pic,x,y,picMerge)
process k
getch (key)
end k
fork k
loop
    if key = chr(200) then
        loop
            fork k
            if key = chr(10) then
                d := 5
            elsif key = chr(208) then
                d := 10
            end if
            y := y + 1
            %y1 := y1 + 1
            exit when key not = chr(200) and key not = chr(10) and key not = chr(208)
            %drawfillbox(x-1,y-1,x1+1,y1+1,white)
            drawfillbox(x-2,y-2,(x + picWidth) +2,(y + picHeight) + 2, white)
            %drawfillbox(x,y,x1,y1,blue)
            Pic.Draw(pic,x,y,picMerge)
            View.Update
            delay(d)
       end loop
    elsif key = chr(205) then
        rotatex := (x + x + picWidth) div 2
        rotatey := (y + y + picHeight) div 2
        angle := 270
        newpic := Pic.Rotate(pictureID,angle,rotatex,rotatey)
        Pic.Draw(newpic,x,y,picMerge)
    end if

end loop>



Please specify what version of Turing you are using
<Turing 4.1.1>
Sponsor
Sponsor
Sponsor
sponsor
Dreadnought




PostPosted: Sat May 16, 2015 10:32 am   Post subject: Re: Cannot allocate item. Out of id numbers (max 1000)

Every time you use Pic.Rotate you are creating a new picture that Turing has to save in memory. Turing can only save up to 1000 pictures in memory, so once you hit that limit it crashes.

It seems you only have 4 different possible rotations, try to create all possible rotations first, and then use the appropriate one when you need it.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: