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

Username:   Password: 
 RegisterRegister   
 What Am I Doing Wrong!!!!!!!!!!!!!!!! Help!!!!!!!!!!! Urgent
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Krocker




PostPosted: Wed Nov 03, 2010 4:52 pm   Post subject: What Am I Doing Wrong!!!!!!!!!!!!!!!! Help!!!!!!!!!!! Urgent

Can some one help me, what am i doing wrong. i keep getting an error and i dont understand http://compsci.ca/v3/images/smiles/icon_question.gif . the following is my coding/program:


import GUI

setscreen ("graphics:550;150")

% Tells what the button has to do
procedure Simplepressed
Sys.Exec ("Simple.exe")
end Simplepressed

procedure Compoundpressed
Sys.Exec ("Compound.exe")
end Compoundpressed

% Gives the buttons a variable and creates the button
var button1 : int := GUI.CreateButton (140, 60, 2, "SIMPLE", Simplepressed)
var button2 : int := GUI.CreateButton (20, 60, 2, "COMPOUND", Compoundpressed)

% Intro Statement to the program
put "WELCOME TO KB INTEREST CALCULATOR"
colour (3)
put "PLEASE CHOOSE ONE OF THE FOLLOWING TYPES OF INTERESTS"

loop
exit when GUI.ProcessEvent
end loop




Question Question Question
Sponsor
Sponsor
Sponsor
sponsor
TerranceN




PostPosted: Wed Nov 03, 2010 6:03 pm   Post subject: RE:What Am I Doing Wrong!!!!!!!!!!!!!!!! Help!!!!!!!!!!! Urgent

Next time say what error you are getting, but I'm guessing you get the error:

"Expression is not a procedure and hence cannot be called"

I don't understand why, but from reading the documentation, they always use Sys.Exec in a if statement, which works properly. So instead of

Turing:

Sys.Exec("\\.\\Windows\\System32\\notepad.exe")


use

Turing:

if Sys.Exec("\\.\\Windows\\System32\\notepad.exe") then
end if


which you can even use for error handling

Turing:

if ~Sys.Exec("\\.\\Windows\\System32\\notepad.exe") then
    put "Error: "..
    put Error.LastMsg()
end if


Does anyone know specifically why you get that cryptic error? Why wouldn't Holtsoft just make it a procedure instead of having that error?
TheGuardian001




PostPosted: Wed Nov 03, 2010 8:09 pm   Post subject: Re: RE:What Am I Doing Wrong!!!!!!!!!!!!!!!! Help!!!!!!!!!!! Urgent

TerranceN @ Wed Nov 03, 2010 6:03 pm wrote:

"Expression is not a procedure and hence cannot be called"

I don't understand why, but from reading the documentation, they always use Sys.Exec in a if statement, which works properly

Turing enforces the difference between Functions and Procedures. If the method is stated to return a value, you MUST use that value, whether it is by assigning it to a variable, using it in a conditional, etc. It's the same reason turing uses "exit when GUI.ProcessEvent()" instead of just "GUI.ProcessEvent"

This specific method is a function because it returns a value indicating success/failure. I suppose they chose to do that because you're launching something outside of your own program, and will probably want to know if that program was successfully launched or not.
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 1  [ 3 Posts ]
Jump to:   


Style:  
Search: