Author |
Message |
uberwalla

|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Clayton

|
Posted: 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

|
Posted: 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

|
Posted: 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.
Description: |
|
 Download |
Filename: |
it can be done.zip |
Filesize: |
671 Bytes |
Downloaded: |
93 Time(s) |
|
|
|
|
|
 |
ericfourfour
|
Posted: 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

|
Posted: 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
|
|
|
|
|
 |
uberwalla

|
Posted: 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 i know ur online!!! now lets brg turing back in the IRC
...
jk
|
|
|
|
|
 |
uberwalla

|
Posted: 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
Description: |
|
 Download |
Filename: |
Console.zip |
Filesize: |
2.48 KB |
Downloaded: |
87 Time(s) |
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Clayton

|
Posted: 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

|
Posted: 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
also is there a way to open files with spaces? like for an example. "hello freakman.txt" is that possible cuz it isnt working
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

|
Posted: 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

|
Posted: 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 ( we'll see )
|
|
|
|
|
 |
Clayton

|
Posted: 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

|
Posted: 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? its not workin for me
|
|
|
|
|
 |
Clayton

|
Posted: 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.
|
|
|
|
|
 |
|