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

Username:   Password: 
 RegisterRegister   
 command prompt mock off
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
uberwalla




PostPosted: Sun Dec 03, 2006 8:28 pm   Post subject: command prompt mock off

ok so im making a prompt with GUI
and this is what i got...

what im trying to do is input the unnamed123.t into the program but i dont want to have to use the get command because im using GUI Smile and i wanna implement it into the gui so it works properly (if this makes sense Sad)
anyways help would be awsome



Console.zip
 Description:
prompt

Download
 Filename:  Console.zip
 Filesize:  2.55 KB
 Downloaded:  94 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Sun Dec 03, 2006 8:36 pm   Post subject: (No subject)

from what I get from you on the IRC Channel, you should make each "command" an executable, then, when you get the "command" from your GUI textbox, input that into a Sys.Exec command, ie:

code:

fcn run (command : string) : boolean
    result Sys.Exec (command)
end run
Clayton




PostPosted: Sun Dec 03, 2006 8:48 pm   Post subject: (No subject)

okay, fooled around with it, and this is what I got, you cant call filenames with spaces in it, otherwise it screws up, you will obviously need to modify this to make this work with your code, but this is the basic template:

Turing:

fcn chomp (s : string) : string
    var a := ""
    for i : 1 .. length (s)
        if s (i) ~= " " then
            a += s (i)
        end if
    end for
    result a
end chomp

fcn call_command (command : string) : boolean
    var filename : string := ""
    if index (command, "run") = 1 then
        filename := chomp (command (4 .. *))
    else
        result false
    end if
    if filename = "hello.txt" then
        result true
    else
        result true
    end if
end call_command

var command : string := ""
put "Enter a command"
get command : *

if call_command (command) then
    put "It works!"
else
    put "Try again"
end if
Clayton




PostPosted: Sun Dec 03, 2006 9:13 pm   Post subject: (No subject)

okay, one last try, here is an example, with text boxes, of how this can be done. It may not look pretty, but I haven't used text boxes forever, so I could care less, just type "run hello.txt" exactly when it runs, and you should get a message saying "success" in the run window, as well as a text file popping up.


it can be done.zip
 Description:
yes, it can be done

Download
 Filename:  it can be done.zip
 Filesize:  671 Bytes
 Downloaded:  93 Time(s)

ericfourfour




PostPosted: Sun Dec 03, 2006 10:19 pm   Post subject: (No subject)

code:
fcn chomp (s : string) : string
    var a := ""
    for i : 1 .. length (s)
        if s (i) ~= " " then
            a += s (i)
        end if
    end for
    result a
end chomp

Is already in the Str module. No need to remake it.

code:
Str.Trim (str : string) : string
Clayton




PostPosted: Mon Dec 04, 2006 3:51 pm   Post subject: (No subject)

How interesting, just goes to show you that you learn something new every day Smile
uberwalla




PostPosted: Mon Dec 04, 2006 3:53 pm   Post subject: (No subject)

haha i was gonna read this then i read someting else then freakman posts Razz i know ur online!!! now lets brg turing back in the IRC Razz



...



jk Smile
uberwalla




PostPosted: Mon Dec 04, 2006 4:06 pm   Post subject: (No subject)

new version:
1) why does a new window open when i run a file?
2) is there a way to only quit the GUI for the calculator i made and still keep the prompt open?

thx in advance Smile



Console.zip
 Description:
v2

Download
 Filename:  Console.zip
 Filesize:  2.48 KB
 Downloaded:  87 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Mon Dec 04, 2006 4:12 pm   Post subject: (No subject)

Uh... I don't get a second run window opening when i use your "run" command. I only get a notepad window opening (I'm using my test file hello.txt)

As for the Calculator, Using GUI.Quit quits the entire program, not just the active window, so, just close that window, and switch the active window to the command window.
uberwalla




PostPosted: Mon Dec 04, 2006 4:24 pm   Post subject: (No subject)

i have no idea whats wrong but every time i run program wether it be folder or file it opens a window Sad

also is there a way to open files with spaces? like for an example. "hello freakman.txt" is that possible cuz it isnt working Sad

o and how do i close the calculators window because id have to use a procedure to close it with the button and i cant call procedures in procedures so i have to call it else where which is impossible because itd have to be before i even call the window as a variable wouldnt it?
Clayton




PostPosted: Mon Dec 04, 2006 4:32 pm   Post subject: (No subject)

certainly you can call procedures within another procedure, where do you get the idea you can't?

as for you other question, you will have to do a little playing around with the code to get that working right, but I know it's possible because I have a program that does it (I'm not going to give it to you).
uberwalla




PostPosted: Mon Dec 04, 2006 4:48 pm   Post subject: (No subject)

a while ago when i wrote a procedure inside a procedure it said procedures must be called at top of code or something like that. ill try it thought Razz ( we'll see Laughing )
Clayton




PostPosted: Mon Dec 04, 2006 4:49 pm   Post subject: (No subject)

you can't write another procedure from within a procedure, but you can call another procedure from within a procedure, so thats all you have to do.
uberwalla




PostPosted: Mon Dec 04, 2006 4:51 pm   Post subject: (No subject)

ok as i expected...

when i put the procedure to close the window in the other procedure i got the error:
Quote:

'procedure's may only be declared at the program, module, or monitor level


is there another way to do this? Sad its not workin for me
Clayton




PostPosted: Mon Dec 04, 2006 4:54 pm   Post subject: (No subject)

Like I said, procedures cannot be written within other procedures, instead, you have to call other procedures from within that procedure. So when your exit button is pressed, go to a procedure within your program that closes the calculator window, and switches the active window to the command window.
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 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: