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

Username:   Password: 
 RegisterRegister   
 Sys.Exec problems
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
ProgrammingFun




PostPosted: Sun Apr 18, 2010 8:12 am   Post subject: Sys.Exec problems

What is it you are trying to achieve?
I am trying to create an autorun type program.


What is the problem you are having?
Sys.Exec commands runs the error: "Expression is not a procedure and hence cannot be called."
I also want to know if I am using the getch function properly.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


setscreen ("graphics,position:center;center, nobuttonbar")
var font1 : int
font1 := Font.New ("calibri:16:bold")
Font.Draw ("Copyright 2010", 0, 5, font1, blue)

var inputwait:string (1)

put "Welcome to the Geo Website Developer!"
put "To run the website manually, run Main Page.html"
put "If the website is not compatable with your browser, use one of the pre-installed browsers in the Alternative Browsers folder."
put "To start the website now, press enter."
getch (inputwait)

Sys.Exec ("Main Page.html")


Sponsor
Sponsor
Sponsor
sponsor
corriep




PostPosted: Sun Apr 18, 2010 8:22 am   Post subject: Re: Sys.Exec problems

Sys.Exec is a function and it returns a boolean, you cant call it on its own. For example:
Turing:
if Sys.Exec ("Main Page.html") = true then
    put "Everything went smoothly!"
else
    put "Uh oh: ", Error.LastMsg
end if
ProgrammingFun




PostPosted: Sun Apr 18, 2010 8:45 am   Post subject: RE:Sys.Exec problems

Thanks, I tried the above but now I always get an error message for file not found although the file is in the same folder.

I also tried it on a RAR file with no success. Sad
chrisbrown




PostPosted: Sun Apr 18, 2010 10:05 am   Post subject: RE:Sys.Exec problems

From this post:

Try:
if Sys.Exec ("\"Main Page.html\"") then ....
ProgrammingFun




PostPosted: Sun Apr 18, 2010 2:01 pm   Post subject: RE:Sys.Exec problems

Thanks for the help!!!

Edit: Here's my final code (for anyone interested):

Turing:

setscreen ("graphics,position:center;center, nobuttonbar")

var winID : int
winID := Window.Open ("position:center;center")

var font1 : int
font1 := Font.New ("calibri:16:bold")
Font.Draw ("Copyright 2010", 0, 5, font1, blue)

var inputwait : string (1)

put "Welcome to the Geo Website Developer!"
put "To run the website manually, run Main Page.html"
put "If the website is not compatable with your browser, use one of the pre-installed browsers in the Alternative Browsers folder."
put "To start the website now, press enter."
getch (inputwait)

put " "
if Sys.Exec (("\"Main Page.html\"")) = true then
    put "Executing now..."
    delay (1000)
    Window.Close (winID)
else
    put "Uh oh: ", Error.LastMsg, " You may have to run the file manually."
end if



I plan to use this as the autorun program in a CD which I have to give for my geo project.
The reason I didn't just use notepad was that I wanted a readme type of file that also executed the program...

I guess a batch file could also have worked...will post that if I make it.
But I guess Turing's run window looks better... Cool
ProgrammingFun




PostPosted: Sun Apr 18, 2010 3:12 pm   Post subject: CMD Program

I created a batch file for the program above but decided that it looked ugly, was more disorganised, and was hard to run.

However, here is the file (paste in notepad and save as a bat file):

[syntax]
echo Welcome to the GEO website developer!
echo To run the website manually, run Main Page.html
echo If the website is not compatible with your computer, use one of the preinstalled browsers in the Alternative Browsers window.
echo To start the website now, press enter.

PAUSE

start Main Page.html
TYPE NUL | CHOICE.COM /N /CY /TY,5 >NUL
exit
[/syntax]
ProgrammingFun




PostPosted: Mon Apr 19, 2010 8:40 pm   Post subject: RE:Sys.Exec problems

I now have a new problem...at the beginning, my Main Page.html file was in the same directory as the Turing program but I now moved it into a subfolder with the name of "Geography Project". How would I create a Sys.Exec path to that file instead of the one given before?

Thanks for the help!
BigBear




PostPosted: Mon Apr 19, 2010 8:43 pm   Post subject: RE:Sys.Exec problems

Sys.Exec ("\Main Page.html")
Sponsor
Sponsor
Sponsor
sponsor
ProgrammingFun




PostPosted: Mon Apr 19, 2010 8:53 pm   Post subject: Re: RE:Sys.Exec problems

BigBear @ Mon Apr 19, 2010 8:43 pm wrote:
Sys.Exec ("\Main Page.html")


The file is now under \Geography Project\Main Page.html
And the following does not work:

Turing:

if Sys.Exec (("\"Geography Project\Main Page.html\"")) = true then


Please help...
Thanks
TheGuardian001




PostPosted: Mon Apr 19, 2010 9:05 pm   Post subject: Re: Sys.Exec problems

Backslashes are escape characters. If you want to use them in a directory path, you need two of them.

IE:
Turing:

put Sys.Exec("subFolder\\File.ext")
andrew.




PostPosted: Mon Apr 19, 2010 9:07 pm   Post subject: Re: RE:Sys.Exec problems

Try this:
Turing:

if Sys.Exec ("\"Geography Project\\Main Page.html\"") then
ProgrammingFun




PostPosted: Mon Apr 19, 2010 9:12 pm   Post subject: Re: RE:Sys.Exec problems

andrew. @ Mon Apr 19, 2010 9:07 pm wrote:
Try this:
Turing:

if Sys.Exec ("\"Geography Project\\Main Page.html\"") then


Thank you so much!
+bits

Two more questions...how do you change the run window title when the program has been compiled as an EXE?
And...how can you change the icon of the standalone program?

Thanks for the help.
apomb




PostPosted: Mon Apr 19, 2010 9:57 pm   Post subject: RE:Sys.Exec problems

To change the icon, you'd need resource hacker
TheGuardian001




PostPosted: Mon Apr 19, 2010 10:08 pm   Post subject: Re: Sys.Exec problems

I believe

Turing:

View.Set("title:yourTitle")


Will change a window's title.
ProgrammingFun




PostPosted: Tue Apr 20, 2010 5:05 pm   Post subject: Re: Sys.Exec problems

TheGuardian001 @ Mon Apr 19, 2010 10:08 pm wrote:
I believe

Turing:

View.Set("title:yourTitle")


Will change a window's title.


For some reason, this does not have any affect on the title of the program. It still says Autorun - Run Window or something similar...
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  [ 19 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: