Posted: Thu Jun 01, 2006 1:45 pm Post subject: FINAL PROGRAM
hi, i'm working on my final project and i'm almost finished but when i run it it crashes at some point and it says "cannot allocate item. Out of id numbers (max 1000)", what does this mean .
thank you for ur help
Sponsor Sponsor
TheOneTrueGod
Posted: Thu Jun 01, 2006 2:25 pm Post subject: (No subject)
Well, some code would be helpful, but I can take a stab at guessing what your talking about.
You are creating either A) Too many pictures, B) Too many 'Font's, or C) Too many of one of the other things that I havn't had as much experience with.
Turing only allows a maximum of 1000 pictures to be loaded at any given time (Which is more than enough, because you should be using pictures effectively anyways.) Use Pic.Free when you are finished with a picture to get rid of it.
Same applies with fonts, except you should use Font.Free to get rid of em.
As for other stuff, I'm not quite so sure. GUI may have a maximum number of objects that can be declared at any given time, and it may require you to limit this.
Next time, please post some code so we know exactly what the problem is
skyler
Posted: Thu Jun 01, 2006 2:46 pm Post subject: (No subject)
THank you TheOneTrueGod for your reply , here is the game i'm creating as my final project , and it is like "Who wants to be a millionair" , so if you could please run it and see how it crashes at some point .
here is the file
Posted: Thu Jun 01, 2006 3:10 pm Post subject: (No subject)
Wow, i'm impressed at how much you drew in turing. You know you can import graphics from paint, right? I am aware of the irony!
Anyways, like I predicted, its because you keep creating new 'font's.
Lets go in-depth!
code:
B3 := Font.New ("Times New Roman:15")
Draw.Text ("Leaf", 380, 55, B3, 0)
var C3 : int
C3 := Font.New ("Times New Roman:15")
See how both of those fonts are the exact same thing? Why not just declare one font for that size at the start of the program, and use it throughout?
You'll probably need 3 different fonsizes (And please, name them something intuitive... C3 is not intuitive... neither is font2333)
Another thing, your code is kinda badly done... Things like the program quitting when I enter an invalid choice is just annoying Also, when I try and type my answer in, I can't see what i've written.
Finally (For the things i'm going to suggest):
code:
if choice = "start" or choice = "START" or choice = "Start" then
That doesn't cover things like "StArt" (etc). You can use the function
code:
upper (stringVariable : string)
to get the entire uppercase of a word (string). This will reduce some of your redundant code.
I'm feeling kinda lazy right now, so I'm not gonna look too much further into your program, but other than that, its looking really sexy
Clayton
Posted: Thu Jun 01, 2006 4:58 pm Post subject: (No subject)
it should be noted the command to transform your string into uppercase letters isnt upper its Str.Upper, all upper does is return an int, where the integer returned is the upper bounds of an array
TheOneTrueGod
Posted: Thu Jun 01, 2006 5:23 pm Post subject: (No subject)
oops, my bad, never actually used Str.Upper myself (Never had to, I prefer getch / getting integers for menus and such)
skyler
Posted: Thu Jun 01, 2006 8:37 pm Post subject: (No subject)
THANK YOU GUYS FOR YOUR HELP , AND I'LL TRY TO MAKE IT BETTER
skyler
Posted: Thu Jun 01, 2006 9:29 pm Post subject: (No subject)
Hi again , i didn't understand how to use one font for all the text , i tried many ways to do that but the program showed error sign, so can you explain more please . THANK YOU
Sponsor Sponsor
TheOneTrueGod
Posted: Thu Jun 01, 2006 9:51 pm Post subject: (No subject)
Allright, I'll just show you an example of one section of code.
Original:
[code]var font77 : int
font77 := Font.New ("Times New Roman:15")
Draw.Text ("A.", 80, 55, font77, 8)
var font6 : int
font6 := Font.New ("Times New Roman:15")
Draw.Text ("B.", 360, 55, font6, 8)
var font7 : int
font7 := Font.New ("Times New Roman:15")
Draw.Text ("C.", 80, 15, font7, 8)
var font8 : int
font8 := Font.New ("Times New Roman:15")
Draw.Text ("D.", 360, 15, font8, 8)code]
As you can see, since all of these texts share one thing in common (The Times New Roman size 15 font), they can all share the single variable. Now, just declare this variable at the start, name it something intuitive, and go through your code and make it so ANY displaying font that uses (Times New Roman size 15) will use that variable.
Of course, if you want a different section to be (TNR size 30) then you need a separate font variable to keep track of that.
Be sure to remember to Font.Free the created fonts at the end.
skyler
Posted: Thu Jun 01, 2006 10:18 pm Post subject: (No subject)
Thank you TheOneTrueGod for your explanation, one more thing i forgot to tell you is that the program i attached works fine on my pc , but when i run it on the school's computer it crashes and shows the same error i mentioned before, is there an explanation for this ?????
thank you
NikG
Posted: Thu Jun 01, 2006 10:47 pm Post subject: (No subject)
skyler wrote:
the program i attached works fine on my pc , but when i run it on the school's computer it crashes and shows the same error i mentioned before, is there an explanation for this ?????
That shouldn't be happening, even if you have a different version of turing at school than at home. (that's what i think, anyone wanna correct me?)
Try again, make sure you did run an updated copy and not the old copy of your code.
About your game: those are some great Turing graphics.
Here's a suggestion, why don't you load the questions from a text file instead of directly hardcoding them?
That way you can have many questions in your file under different difficulty levels and you can use a procedure to pick a random question at every run.
Clayton
Posted: Thu Jun 01, 2006 10:59 pm Post subject: (No subject)
i realized whats going on in ur program, during one of your for loops you are declaring 8 different fonts each iteration of ur loop which adds up quickly to over 1000, so either declare the font you are going to use outside the for loop, or use Font.Free each iteration of your loop to keep the amout of fonts used down
skyler
Posted: Thu Jun 01, 2006 11:32 pm Post subject: (No subject)
ok, NikG's idea to run the questions from a different file is kinda difficult for me because i'm still a beginner, and for SuperFreak82's idea to use Font.Free, i hope that you can give me more information about this please and if it will have some bad effects on my program or not.
THANK YOU
Clayton
Posted: Thu Jun 01, 2006 11:32 pm Post subject: (No subject)
(srry for double post)
notice in your program how much repetition there is? not good, you need to proceduralize it a lot more, check the Turing Walkthrough on procedures and functions to learn the benefits of using them:D
Clayton
Posted: Thu Jun 01, 2006 11:35 pm Post subject: (No subject)
skyler wrote:
ok, NikG's idea to run the questions from a different file is kinda difficult for me because i'm still a beginner, and for SuperFreak82's idea to use Font.Free, i hope that you can give me more information about this please and if it will have some bad effects on my program or not.
THANK YOU
wow triple post (missed his post)
to use Font.Free simply put the font identifier in brackets after Font.Free ex.
code:
Font.Free(myFont)
as for file I/O check the Turing Walkthrough for the excellent tutorial on it, which gives you all that you need to do this:D