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

Username:   Password: 
 RegisterRegister   
 Turing Shell
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
CentiZen




PostPosted: Tue May 12, 2009 10:39 am   Post subject: Turing Shell

I've been tinkering around with turing for quite a while now, and I decided that for my first major projects I would make a shell. So far its been going great. I've had a few issues with things like manually setting colours, and clearscreen. I just thought I'd post it so I could get some feedback on it, tips tricks, suggestions... please, no bad feedback or unconstructive critisism, I am just learning to code.

Turing:
%Var declarations
var changedir, menuchoice, delpathname, rmdirpath, copysourcefile, copydestfile, renamefilepath, newname : string
var colortype, newcolor : int

procedure pwdcommand %This command prints out the working directory of the program
put Dir.Current
end pwdcommand

procedure colorcommand %currently not working
get newcolor
colortype := newcolor
end colorcommand

procedure clscommand %again, currently not working
cls
end clscommand
 
procedure delcommand %deletes a file
get delpathname
File.Delete (delpathname)
if Error.Last = eNoError then
    put skip, delpathname, " deleted"
else
    put skip, "Did not delete ", delpathname
    put "Error: ", Error.LastMsg
end if

end delcommand

procedure helpcommand %displays a list of commands and how to use them
color (10)
put "Name       Description/instructions (if available)"
color (36)
put "CD         Changes the working directory [cd (newname)]"
put "COPY       Copies a file [copy (sourcefile) {destfile}]"
put "DEL        Delete the file specified [del (targetdile)]"
put "LS         Lists all of the files/folders in the working directory"
put "HELP       Displays this help page"
put "PWD        Prints the working directory"
put "RMDIR      Deletes the folder specified [rmdir (targerdir)]"
put "SCAR       Renames a file (scar [targetfile] {newname}]"
color (7)
end helpcommand

procedure renamecommand %renames a file
get renamefilepath, newname
File.Rename (renamefilepath, newname)
        if Error.Last = eNoError then
            put "File renamed"
        else
            put "Did not rename the file."
            put "Error: ", Error.LastMsg
        end if
end renamecommand

procedure copycommand %copies a file
get copysourcefile, copydestfile
File.Copy (copysourcefile, copydestfile)
if Error.Last = eNoError then
    put "File copied", skip
else
    put "Did not copy the file."
    put "Error: ", Error.LastMsg, skip
end if
end copycommand
procedure passme
put "passed through"
end passme

procedure lscommand %lists all files and directories
setscreen ("text")
var streamNumber : int
var fileName : string
streamNumber := Dir.Open (".")
assert streamNumber > 0
loop
    fileName := Dir.Get (streamNumber)
    exit when fileName = ""
    put fileName
end loop
Dir.Close (streamNumber)
passme
end lscommand

procedure rmdircommand
get rmdirpath
Dir.Delete (rmdirpath)
        if Error.Last = eNoError then
            put "Directory delete"
        else
            put "Did not delete the directory."
            put "Error: ", Error.LastMsg
        end if
end rmdircommand
procedure cdcommand %a procedure to change the working directory of a program
get changedir
Dir.Change (changedir)
end cdcommand

/* This is an if statment that takes a single command (no args, I don't know how to do
those yet), and then processes the string that was entered. If it is any of the commands
in the shell, it points the program to the correct procedure and then returns to the
start of the menu.
*/


procedure menu
put Dir.Current ,": "..
get menuchoice
if menuchoice = "help" then
    helpcommand
    menu
elsif menuchoice = "pwd" then
    pwdcommand
    menu
elsif menuchoice = "cd" then
    cdcommand
    menu
elsif menuchoice = "cls" then
    menu
elsif menuchoice = "color" then
    colorcommand
    menu
elsif menuchoice = "colors" then
    menu
elsif menuchoice = "ls" then
    lscommand
    menu
elsif menuchoice = "del" then
    delcommand
    menu
elsif menuchoice = "rmdir" then
    rmdircommand
    menu
elsif menuchoice = "copy" then
    copycommand
    menu
elsif menuchoice = "scar" then
    renamecommand
    menu
else
    put "command not understood, returning to menu"
    menu
end if
end menu

put "Welcome to Darwin"
colortype := 7
setscreen ("graphics")
menu


I have alot to add to this, I just thought I would post it up for some criticism.
Sponsor
Sponsor
Sponsor
sponsor
BigBear




PostPosted: Tue May 12, 2009 2:10 pm   Post subject: RE:Turing Shell

http://compsci.ca/v3/viewtopic.php?t=12068&highlight=shell

I think this might be helpful it seems to have a few problem like typing cd C:\ opens the C drive in explorer also dir doesn't work on either
WOIKeller




PostPosted: Thu Oct 22, 2009 10:01 am   Post subject: RE:Turing Shell

This program is probably the best program I could use. Thanks +2 bits...

Keep up the good work!
Insectoid




PostPosted: Thu Oct 22, 2009 1:23 pm   Post subject: RE:Turing Shell

This 'shell' is just a repackaging of the Windows shell in Turing. By all means, keep on this, but I suggest doing a lot of things manually. Keeping a tab on the actual directory and changing it within the code instead of referencing Window's chdir (or cd) command would be more challenging and more impressive when complete.
andrew.




PostPosted: Thu Oct 22, 2009 1:28 pm   Post subject: RE:Turing Shell

I made one a while ago like this. I made it so that when it doesn't understand the command, it will ask if you want to run it as a Windows command, and I used Sys.Exec to run it if they said yes.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: