
-----------------------------------
kartikitrak
Wed Jan 12, 2011 2:48 pm

Folder Picture Output
-----------------------------------
How do you output all the pictures in a specific folder?

Basically I want to show a list of all my maps that are in a folder, however I don't know how. It's like Call of Duty when you are selecting a map. 

If possible, just a list of all the filenames are good,too.

Also the folder may be updated at anytime and I would like to keep the list updated.

-----------------------------------
Tony
Wed Jan 12, 2011 2:54 pm

RE:Folder Picture Output
-----------------------------------
I think familiarizing yourself with [tdoc]dirmodule[/tdoc] is a good starting point

-----------------------------------
kartikitrak
Wed Jan 12, 2011 3:35 pm

RE:Folder Picture Output
-----------------------------------
you have made me feel like an idea... THANK YOU! : )

-----------------------------------
kartikitrak
Wed Jan 12, 2011 3:42 pm

RE:Folder Picture Output
-----------------------------------
I have tried using the dirmodule however I am just wondering if it will allow you to output all the pictures in the folder.

-----------------------------------
Tony
Wed Jan 12, 2011 3:44 pm

RE:Folder Picture Output
-----------------------------------
It provides the tools for you to find out what all the files in the folder are. You can use file name endings to figure out if those files are pictures or not, and once you have the name of the pictures, you can do whatever you want with them.

-----------------------------------
kartikitrak
Wed Jan 12, 2011 3:51 pm

RE:Folder Picture Output
-----------------------------------
i still don't really get it.

So how to i get the pic.draw feature to use the filenames listed in the screen

-----------------------------------
Tony
Wed Jan 12, 2011 3:56 pm

RE:Folder Picture Output
-----------------------------------
before you use Pic.Draw you need to use [tdoc]Pic.FileNew[/tdoc], which requires a filename, which you just got ;)

-----------------------------------
kartikitrak
Wed Jan 12, 2011 3:57 pm

RE:Folder Picture Output
-----------------------------------
but does filename represent only one file or the whole list

if it represents one how would you pic.filenew the others
also if it represents the whole list would u just need

pic.filenew (filename)

-----------------------------------
Tony
Wed Jan 12, 2011 4:00 pm

RE:Folder Picture Output
-----------------------------------
No, Pic.FileNew take one name at a time. To go over all of the names, you'd need some sort of a loop.

-----------------------------------
kartikitrak
Wed Jan 12, 2011 4:01 pm

RE:Folder Picture Output
-----------------------------------
anyway..i tried with just one picture but i gives me a illegal picture id number 0

var streamNumber : int
var fileName : string
var dir : string
dir := Dir.Current + "/usermaps"
streamNumber := Dir.Open (dir)
assert streamNumber > 0
loop
    fileName := Dir.Get (streamNumber)
    var pic : int := Pic.FileNew (fileName)
    exit when fileName = ""
    put fileName
    Pic.Draw (pic, 0, 0, picCopy)
end loop
Dir.Close (streamNumber)

-----------------------------------
Tony
Wed Jan 12, 2011 4:03 pm

RE:Folder Picture Output
-----------------------------------
What is the fileName that it tries to open? Is there such a file in the _current_ directory?

-----------------------------------
kartikitrak
Wed Jan 12, 2011 4:05 pm

RE:Folder Picture Output
-----------------------------------
My current directory

/Game
listprogram.t(this is the program)
/usermaps/pic1,pic2

-----------------------------------
kartikitrak
Wed Jan 12, 2011 4:05 pm

RE:Folder Picture Output
-----------------------------------
Do you have an msn. So we can talk via msn.

-----------------------------------
Tony
Wed Jan 12, 2011 4:06 pm

RE:Folder Picture Output
-----------------------------------
Yes. When you get the illegal picture ID error, what value does fileName have at that time?

-----------------------------------
kartikitrak
Wed Jan 12, 2011 4:07 pm

RE:Folder Picture Output
-----------------------------------
if you didn't get the folder...

the directory that everything is in is: Gane

in that folder there is one folder named usermaps and the turing file.

the turing file is trying to read and output the pictures in the usermaps folder.

-----------------------------------
kartikitrak
Wed Jan 12, 2011 4:08 pm

RE:Folder Picture Output
-----------------------------------
idk...

when the pic.draw is not there it reads the files in the folder...couldn't use just give the full code to read and output the things.

-----------------------------------
Tony
Wed Jan 12, 2011 4:11 pm

RE:Folder Picture Output
-----------------------------------
"illegal picture id number 0" means that the file you asked for could not be loaded, likely because it was not found.

Alternatively, looking at the docs, it seems that

The fileNameparameter must give the format of the file


-----------------------------------
kartikitrak
Wed Jan 12, 2011 4:12 pm

RE:Folder Picture Output
-----------------------------------
Full Code: or example:

-----------------------------------
Insectoid
Wed Jan 12, 2011 8:53 pm

RE:Folder Picture Output
-----------------------------------
Nope.
