Post Reply 
Input form in CAS programs
10-12-2016, 10:11 AM
Post: #1
Input form in CAS programs
When I introduce a simple program like:

#cas
PPP2():=
BEGIN

LOCAL a;

INPUT(a);
PRINT(a):

return 0;
END;
#end

It gives me an error: "Error: Invalid input"
This simple program works in NON CAS program, so why does not work in CAS?

Thanks in advance to anyone who answers me
Find all posts by this user
Quote this message in a reply
10-12-2016, 01:40 PM
Post: #2
RE: Input form in CAS programs
It seems to be a problem with the INPUT command in CAS, not in the program itself. I would recommend to avoid programs with inputs in the CAS anyway, it's far better to write functions with arguments and return a result.
Find all posts by this user
Quote this message in a reply
10-12-2016, 02:39 PM
Post: #3
RE: Input form in CAS programs
This works:

Code:
export blinput()
BEGIN
 local a;
 INPUT(a);
 return a;
END;

#cas
PPP2():=
BEGIN
 LOCAL a;
 a:=blinput();
 PRINT(a):
 return 0;
END;
#end

It's not pretty, but it works.

-road
Find all posts by this user
Quote this message in a reply
10-12-2016, 03:00 PM
Post: #4
RE: Input form in CAS programs
Thanks very much to all:

Parisse: If I understood it may be better to write a program in NON CAS mode and prepare functions when needed in CAS and pass the parameters. I will try.

roadrunner: Good solution, it works. I try this way too and chose the easiest for the problems.

Thanks very much to all. Very helpful


Toni
Find all posts by this user
Quote this message in a reply
10-12-2016, 03:30 PM (This post was last modified: 11-03-2016 01:06 AM by compsystems.)
Post: #5
RE: Input form in CAS programs
The solution is to create again the input functions (HOME PRG) =(

the CAS should support DIALOG BOXES COMMANDS.

PHP Code:
#cas
cas_program():=
begin
  local var0
;
  print( 
"***Started execution***" ); freeze// Print on terminal Window
  // wait;
  
var0:=cas_input("Title","a=","Help Line",8,3);
  print( 
var0 );
  
freeze;
  
var0:=(var0+x/y); // no pretty print on terminal Window 
  
print( var0 );
  
freeze;
  print( 
"***End execution***" ); freeze;
  return 
"Done";
end;
#end

// Rewriting again INPUT CMD
export cas_input(title_str,var_str,help_str,reset_val,init_val)
begin
  local input_var
;
  
inputinput_var,title_str,var_str,help_str);
  return 
input_var;
end
Find all posts by this user
Quote this message in a reply
10-12-2016, 06:50 PM
Post: #6
RE: Input form in CAS programs
(10-12-2016 03:00 PM)Tonig00 Wrote:  Parisse: If I understood it may be better to write a program in NON CAS mode and prepare functions when needed in CAS and pass the parameters. I will try.

Yes, you should write CAS functions that do not require any interactive input from the user. User input should be passed as arguments to the function from the commandline. And from my experience, if you need the CAS, then it's easier to call the function directly from the CAS commandline than to write a specific UI.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)