Inputs cmds

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 603
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Inputs cmds

Message par compsystems » jeu. févr. 01, 2018 4:16 am

Hello, BP

The variable "d" is stored correctly using InputStr. Is possible that inputForm specifies the type of object to receive?
Thanks

Code : Tout sélectionner

test_inputs():={
	
	local a; 
	local b; 
	local c; 
	local d; 
	
	print(); 
	
	input( "integer", a ); 
	input( "real", b ); 
	input( "boolean", c ); 
	InputStr( "string", d );
	
	print( a ); 
	print( b ); 
	print( c ); 
	print( d ); 
	
	inputform( "integer", a, "real", b, "boolean", c, "string",d  ); 
	
	print( a+" "+b+" "+c+" "+d );  
}:;
inputForm does not decode the variable d

parisse
Messages : 5882
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Inputs cmds

Message par parisse » jeu. févr. 01, 2018 12:43 pm

I don't see what's wrong. Inside the inputform you must of course surround the string d with ", because otherwise it is parsed (and this will error if the field is not a valid commandline).

compsystems
Messages : 603
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: Inputs cmds

Message par compsystems » jeu. févr. 01, 2018 12:51 pm

ok, but to avoid writing the quotes, (idea) you can add an optional extra parameter that determines the type of object

inputform( "integer", a, "real", b, "boolean", c, "string",d );


=>

inputform( "integer", a, "real", b, "boolean", c, "string", [ d DOM_STRING ] );

parisse
Messages : 5882
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Inputs cmds

Message par parisse » jeu. févr. 01, 2018 1:03 pm

I don't want to do things like that, because I think that interactive inputs should be avoided as soon as possible, one should teach functions and arguments as soon as possible instead.

Répondre