Computer Science Canada

do you know how to make an open file box?

Author:  noitcnuflam [ Fri Sep 27, 2013 10:23 pm ]
Post subject:  do you know how to make an open file box?

What is it you are trying to achieve?
im making an alarm clock program that opens any file and it works perfectly im just trying to make it look pretty


What is the problem you are having?
i havent used turing in a while and i was just wondering if its possible to make a open file box

like when you open turing and then go to FILE - OPEN... and a box pops up and you pick which turing file you want

also since turing uses a 24 hour clock id also need to put in a drop down list for the hours, minutes and seconds

so ya 2 things
1 open file box
2 drop down list

Describe what you have tried to solve this problem
i drink lots of coffee

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

Turing:


setscreen ("graphics:1000;40,nobuttonbar")
var count : int := 0
var wakeuptime : string
var file :string

%i want to replace the next 2 lines with the open file box and the drop down menu
put "what time do you want to wake up?" get wakeuptime
put "what do you want to wake up to" get file

%this loop gets the time of day puts it on the screen then clears the screen puts a new time of day on the screen and so on
%until it reaches the wake up time then it opens the file you want to run
loop
    var timeOfDay : string
    var font : int
    font := Font.New ("Small Fonts:40")

    time (timeOfDay)
    Draw.Text (timeOfDay, 0, 0, font, black)
    if timeOfDay = wakeuptime

            then
        cls
        font := Font.New ("Small Fonts:26")
        Draw.Text ("WAKE UP", 5, 10, font, black)

        if not Sys.Exec (file) then

        end if

    end if
    delay (1000)
    cls
end loop



Please specify what version of Turing you are using
4.1

Author:  Raknarg [ Sat Sep 28, 2013 12:08 am ]
Post subject:  RE:do you know how to make an open file box?

what, you want to open files from turing?

You might want to restate what you're asking, because this doesn't make much sense

Author:  noitcnuflam [ Sat Sep 28, 2013 12:52 am ]
Post subject:  RE:do you know how to make an open file box?

have you ever opened a program like ms paint and then you go to FILE >OPEN... and then a box pops up and lets you pick which file you want to open

im trying to do that in turing

so that you can select the file you want to run when the alarm goes off

so i dont have to type in the whole C:\windows\folder\blah\song.mp3

im just trying to make a thing that lets you select a file

so if you know how to do that let me know

i dont even know if its possible i was just wondering if it was

Author:  btiffin [ Sat Sep 28, 2013 2:08 am ]
Post subject:  RE:do you know how to make an open file box?

malfunction;

Just for a little terminology. They are called Dialog Boxes, and usually File Dialog for the particular one you are looking for.

As to the Turing, can't say if it comes as stock library, but from what little I know, yes you could code a graphical dialog box with Turing. As complex a dialog as you'd like.

Cheers

Author:  tiedye1 [ Sat Sep 28, 2013 8:51 am ]
Post subject:  Re: do you know how to make an open file box?

There was actually an open file dialog planned to be implemented
in the GUI module in stock Turing but the company died before
they got around to it. There's even documentation for it (GUI.OpenFile).

Author:  noitcnuflam [ Sat Sep 28, 2013 12:51 pm ]
Post subject:  RE:do you know how to make an open file box?

maybe i should learn another programming language

do you think java would be able to do that?

i havent programmed in years

Author:  Raknarg [ Sat Sep 28, 2013 12:57 pm ]
Post subject:  RE:do you know how to make an open file box?

Do you want to learn how to make them, or do you just need to implement them? If you arent looking to learn how to make them, you could use Visual Basic, which is perfect for making applications

Author:  DemonWasp [ Sat Sep 28, 2013 1:17 pm ]
Post subject:  RE:do you know how to make an open file box?

Turing can already do this: use http://compsci.ca/holtsoft/doc/gui_openfile.html or http://compsci.ca/holtsoft/doc/gui_openfilefull.html if you want more control over the dialog opened.

Unfortunately "drop downs" (called "combo boxes" for some reason) are one of a few controls not covered by Turing's GUI module.

You should definitely learn another programming language, and yes nearly all of them can build a GUI.

Author:  noitcnuflam [ Sat Oct 12, 2013 6:59 pm ]
Post subject:  RE:do you know how to make an open file box?

well i sort of got it working

i have turing open a directory and then list all the files in that directory and then you can select which file you want to run when the alarm goes off

heres the code for that!

_______________________________________

setscreen ("graphics:600;900,nobuttonbar")
var count : int := 0
var filecount : int := 0
var streamNumber : int
var number : int
var fileName : string
streamNumber := Dir.Open (Dir.Current)
assert streamNumber > 0

%this loop creates a list of all the files in the current directory
loop
filecount += 1
fileName := Dir.Get (streamNumber)
exit when fileName = ""
put filecount, " ", fileName

end loop

%this lets you choose which file you would like to run based on that list
%it does the same thing as the previous loop only it doesnt display the
%file names along with a number it just counts to the file you want to open
%that file is the then specified as fileName and is opened during the next part
put "which file would you like to open?"
get number
cls
filecount := 0
streamNumber := Dir.Open (Dir.Current)
loop

filecount += 1
fileName := Dir.Get (streamNumber)
exit when filecount = number
end loop

%this is the same alarm clock program as before except where noted
loop
loop
var timeOfDay : string
var font : int
font := Font.New ("Small Fonts:40")

time (timeOfDay)
Draw.Text (timeOfDay, 0, 0, font, black)

exit when timeOfDay = "19:48:10"
delay (1000)
cls
end loop
var font : int := Font.New ("Small Fonts:26")
Draw.Text ("WAKE UP", 5, 10, font, black)
%the Sys.Exec is changed to the file you picked in the previous part
if not Sys.Exec (fileName) then
end if


end loop
Dir.Close (streamNumber)

_______________________________________

so i guess all i got to do now is just fix the clock so you can pick the time you want to wake up

Author:  noitcnuflam [ Sat Oct 12, 2013 7:07 pm ]
Post subject:  RE:do you know how to make an open file box?

FUN NOTE!

if you just run this code

________________________________________
var streamNumber : int
var fileName : string
streamNumber := Dir.Open (Dir.Current)
assert streamNumber > 0

loop

fileName := Dir.Get (streamNumber)
exit when fileName = ""
if not Sys.Exec (fileName) then
end if

end loop
____________________________________

it opens all the files in the directory at once!
with a little work you could make it open all files in every directory on your computer!! (which would be really annoying to whoever owned the computer you ran it on!)


: