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

Username:   Password: 
 RegisterRegister   
 CMD dir and file commands
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
andrew.




PostPosted: Sat Nov 08, 2008 6:36 pm   Post subject: CMD dir and file commands

Is it possible to use CMD commands in Turing like:

code:
Dir.Change ("%SystemRoot%")


I've tried this and it didn't work. Is there a way that I can detect the drive letter of the root drive? I would normally put C, but some dual-booting computers have their roots on D or even E.

EDIT: I also want to know how to make text white on a black background for the whole window (kind of like a terminal or command window). I think you guys can kind of guess what I'm up to.
Sponsor
Sponsor
Sponsor
sponsor
OneOffDriveByPoster




PostPosted: Sat Nov 08, 2008 7:58 pm   Post subject: Re: CMD dir and file commands

CMD /C "ECHO %SystemRoot%" might work.
andrew.




PostPosted: Sat Nov 08, 2008 8:08 pm   Post subject: RE:CMD dir and file commands

Yeah, I know that, but SystemRoot does not work when you enter it in Turing for changing the directory to. Whatever, I will just use C for now. Also, I figured out how to make it have a black background.
Nova




PostPosted: Sat Nov 08, 2008 8:31 pm   Post subject: Re: CMD dir and file commands

For the black background and white writing you can use color and colorback
Turing:

setscreen ("graphics")
colorback(black)
color(white)
drawfill (0,0,black,black)
put "hello"
var ch : string
loop
    ch := getchar()
    put ch..
end loop
Clayton




PostPosted: Sat Nov 08, 2008 8:56 pm   Post subject: RE:CMD dir and file commands

If you make everything work (on whatever you're doing =/) by using Sys.Exec(), using OneOffByDrivePoster's solution may likely work. Unless of course you're not doing anything with the command line, in which case you're most likely borked.
TheGuardian001




PostPosted: Sat Nov 08, 2008 11:00 pm   Post subject: Re: CMD dir and file commands

Well, this may not work if the program is running from a different drive, but something like this should switch the current directory to their default drive(generally the C:/ drive)
Turing:

var myDir : string := Dir.Current
myDir := myDir(1 .. index(myDir,"/"))
Dir.Change(myDir)

essentially just setting it from the first letter to the first /, giving you the default drive. that way you wouldnt have to access the command prompt(which is probably impossible in turing anyway.)
andrew.




PostPosted: Sun Nov 09, 2008 8:09 am   Post subject: RE:CMD dir and file commands

@TheGuardian001: Thanks a lot TheGuardian! I never thought of that.

@Clayton: I can't use Sys.Exec for a lot of the commands because I don't want a CMD window to pop up and perform the command. I really want my Turing program to perform the command. I think you guys can guess what I'm doing now.

@Nova: I already figured that out but thanks! Smile
andrew.




PostPosted: Sun Nov 09, 2008 1:33 pm   Post subject: RE:CMD dir and file commands

Another problem. How could I open a file with a certain program? I remember seeing someone do it in Turing before. It was something like Sys.Exec ("blah.txt -wordpad.exe").
Sponsor
Sponsor
Sponsor
sponsor
TheGuardian001




PostPosted: Sun Nov 09, 2008 7:43 pm   Post subject: Re: CMD dir and file commands

Sys.Exec will open a file using the current default program for that file type. so
Turing:

put Sys.Exec("myfile.txt")

if you want to choose the program it opens with, the syntax changes to
Turing:

put Sys.Exec("notepad.exe myfile.txt")

which should open it in the program you defined, provided it can find both the program and the file.
andrew.




PostPosted: Mon Nov 10, 2008 7:25 pm   Post subject: RE:CMD dir and file commands

So if I use
Turing:
put Sys.Exec ("notepad.exe file.txt")

will the current DIR have to be the one that Notepad is in or does it use the command line (typing in notepad.exe in cmd or Run)?
deathscith




PostPosted: Tue Nov 11, 2008 12:24 pm   Post subject: Re: CMD dir and file commands

a better form of the background and white text would be simplly put this at the start of your program

code:

setscreen ("graphics:<size here>,<size here>")
colourback (black)
colour (white)
cls
Nova




PostPosted: Tue Nov 11, 2008 12:41 pm   Post subject: RE:CMD dir and file commands

The only difference was that instead of using the drawfill to blacken the screen you cleared it
deathscith




PostPosted: Wed Nov 12, 2008 10:41 am   Post subject: Re: RE:CMD dir and file commands

Nova @ Tue Nov 11, 2008 12:41 pm wrote:
The only difference was that instead of using the drawfill to blacken the screen you cleared it


yea, i know but it just looks simpler to me, and seeing as how i'm a turing novice, i'd say it would look simpler to others aswell.
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  [ 13 Posts ]
Jump to:   


Style:  
Search: