
-----------------------------------
Srlancelot39
Fri Dec 02, 2011 5:18 pm

Displaying filenames in folders
-----------------------------------
What is it you are trying to achieve?
Is there a way to get the names of all files in a folder and display them?  I have an RPG (Grail Quest) that allows the user to save their game and load it later and I would like to build on this by letting them create multiple save files and then select it from a list later so they can load it.

(Also, is there a way to write/read files from different folders without knowing the full pathname?  Not every user is going to have the game's files under the same pathname so unless the setting 'Display full pathnames' is off, this will cause problems.)


What is the problem you are having?
Not sure what command to use for this.


Describe what you have tried to solve this problem
The closest I've gotten is using the 'system' function to search/open specific files.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
I don't think there's any code I could put here that would help


Please specify what version of Turing you are using
4.1  0
var font1 : int
font1 := Font.New ("Courier:12")
var xmouse, ymouse, button : int
var filenumberhighlight : int
var success : int

loop
    fileName (filenumber) := Dir.Get (streamNumber)
    if fileName (filenumber) not= "." and fileName (filenumber) not= ".." then
        Font.Draw (fileName (filenumber), 0, 525 - filenumber * 50, font1, black)
        filenumber := filenumber + 1
    end if
    exit when filenumber = 6
end loop
Dir.Close (streamNumber)

loop
    mousewhere (xmouse, ymouse, button)
    if ymouse < 501 and ymouse > 450 then
        filenumberhighlight := 1
        if button = 1 then
            system ("D:\\Desktop\\Test\\" + fileName (filenumberhighlight), success)
            exit
        end if
    elsif ymouse < 451 and ymouse > 400 then
        filenumberhighlight := 2
        if button = 1 then
            system ("D:\\Desktop\\Test\\" + fileName (filenumberhighlight), success)
            exit
        end if
    elsif ymouse < 401 and ymouse > 350 then
        filenumberhighlight := 3
        if button = 1 then
            system ("D:\\Desktop\\Test\\" + fileName (filenumberhighlight), success)
            exit
        end if
    elsif ymouse < 351 and ymouse > 300 then
        filenumberhighlight := 4
        if button = 1 then
            system ("D:\\Desktop\\Test\\" + fileName (filenumberhighlight), success)
            exit
        end if
    elsif ymouse < 301 and ymouse > 250 then
        filenumberhighlight := 5
        if button = 1 then
            system ("D:\\Desktop\\Test\\" + fileName (filenumberhighlight), success)
            exit
        end if
    else
        filenumberhighlight := 0
    end if
    for f : 1 .. 5
        Font.Draw (fileName (f), 0, 525 - f * 50, font1, black)
    end for
    if filenumberhighlight > 0 and filenumberhighlight < 6 then
        drawfillbox (0, 500 - filenumberhighlight * 50, 500, 550 - filenumberhighlight * 50, black)
        Font.Draw (fileName (filenumberhighlight), 0, 525 - filenumberhighlight * 50, font1, brightred)
    end if
    View.Update
    cls
end loop



Coincidentally, the part of my problem that you replied to is the only part I hadn't solved yet!
Thanks again!
