HP Forums

Full Version: Input form in CAS programs
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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.
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
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
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
(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.
Reference URL's