
-----------------------------------
ProgrammingFun
Sun Apr 18, 2010 8:12 am

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)




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")




-----------------------------------
corriep
Sun Apr 18, 2010 8:22 am

Re: Sys.Exec problems
-----------------------------------
Sys.Exec is a function and it returns a boolean, you cant call it on its own. For example:
if Sys.Exec ("Main Page.html") = true then
    put "Everything went smoothly!"
else
    put "Uh oh: ", Error.LastMsg
end if

-----------------------------------
ProgrammingFun
Sun Apr 18, 2010 8:45 am

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. :(

-----------------------------------
chrisbrown
Sun Apr 18, 2010 10:05 am

RE:Sys.Exec problems
-----------------------------------
From this post:

Try:
if Sys.Exec ("\"Main Page.html\"") then ....

-----------------------------------
ProgrammingFun
Sun Apr 18, 2010 2:01 pm

RE:Sys.Exec problems
-----------------------------------
Thanks for the help!!!

Edit: Here's my final code (for anyone interested):


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... 8-)

-----------------------------------
ProgrammingFun
Sun Apr 18, 2010 3:12 pm

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
Mon Apr 19, 2010 8:40 pm

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
Mon Apr 19, 2010 8:43 pm

RE:Sys.Exec problems
-----------------------------------
Sys.Exec ("\Main Page.html")

-----------------------------------
ProgrammingFun
Mon Apr 19, 2010 8:53 pm

Re: RE:Sys.Exec problems
-----------------------------------
Sys.Exec ("\Main Page.html")

The file is now under \Geography Project\Main Page.html
And the following does not work:


if Sys.Exec (("\"Geography Project\Main Page.html\"")) = true then


Please help...
Thanks

-----------------------------------
TheGuardian001
Mon Apr 19, 2010 9:05 pm

Re: Sys.Exec problems
-----------------------------------
Backslashes are escape characters. If you want to use them in a directory path, you need two of them.

IE:

put Sys.Exec("subFolder\\File.ext")


-----------------------------------
andrew.
Mon Apr 19, 2010 9:07 pm

Re: RE:Sys.Exec problems
-----------------------------------
Try this:

if Sys.Exec ("\"Geography Project\\Main Page.html\"") then


-----------------------------------
ProgrammingFun
Mon Apr 19, 2010 9:12 pm

Re: RE:Sys.Exec problems
-----------------------------------
Try this:

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
Mon Apr 19, 2010 9:57 pm

RE:Sys.Exec problems
-----------------------------------
To change the icon, you'd need [url=http://www.angusj.com/resourcehacker/] resource hacker

-----------------------------------
TheGuardian001
Mon Apr 19, 2010 10:08 pm

Re: Sys.Exec problems
-----------------------------------
I believe


View.Set("title:yourTitle")


Will change a window's title.

-----------------------------------
ProgrammingFun
Tue Apr 20, 2010 5:05 pm

Re: Sys.Exec problems
-----------------------------------
I believe


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...

-----------------------------------
TheGuardian001
Tue Apr 20, 2010 5:33 pm

Re: Sys.Exec problems
-----------------------------------
Odd... It works fine for me... Dunno what to tell you.

-----------------------------------
ProgrammingFun
Tue Apr 20, 2010 5:37 pm

Re: Sys.Exec problems
-----------------------------------
Odd... It works fine for me... Dunno what to tell you.

Here is my code for reference:


setscreen ("graphics,position:center;center, title:Geography Project Launcher, nobuttonbar")

var winID : int
winID := Window.Open ("position:center;center")

var font1 : int
font1 := Font.New ("calibri:16:bold")
Font.Draw ("Copyright Muhammad Osama 2010", 0, 5, font1, blue)

var inputwait : string (1)
var exitinput : string (1)

put "Welcome to the Geo Website Developer!"
put "To run the website manually, run Main Page.html in the Geography Project folder."
put "If the website is not compatible with your browser, please use one of the \npre-installed browsers in the Alternative Browsers folder."
put "\nPress any key to start the website..."
getch (inputwait)

put " "
if Sys.Exec ("\"Geography Project\\Main Page.html\"") then 
    put "Executing now..."
    delay (1000)
    Window.Close (winID)
else
    put "Uh oh: ", Error.LastMsg, " You may have to run the file manually."
    put "\nPress any key to terminate this program..."
    getch (exitinput)
    Window.Close (winID)
end if


Perhaps it is a problem with my code...

-----------------------------------
TheGuardian001
Tue Apr 20, 2010 9:28 pm

Re: Sys.Exec problems
-----------------------------------
Ah, I see your problem. You have your View.Set at the very start of your program, but later on you have a Window.Open call. 

The first call made to Window.Open resets the default window and then gives it the parameters given to Window.Open, so all the stuff from your View.Set is overridden by your Window.Open. Either move your View.Set to after the Window.Open, or incorporate the View.Set parameters into the Window.Open call.

-----------------------------------
ProgrammingFun
Tue Apr 20, 2010 9:31 pm

Re: Sys.Exec problems
-----------------------------------
Ah, I see your problem. You have your View.Set at the very start of your program, but later on you have a Window.Open call. 

The first call made to Window.Open resets the default window and then gives it the parameters given to Window.Open, so all the stuff from your View.Set is overridden by your Window.Open. Either move your View.Set to after the Window.Open, or incorporate the View.Set parameters into the Window.Open call.

Thanks for the help!
Works perfectly now!
