Page 1 sur 1

Inputs cmds

Publié : jeu. févr. 01, 2018 4:16 am
par compsystems
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

Re: Inputs cmds

Publié : jeu. févr. 01, 2018 12:43 pm
par parisse
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).

Re: Inputs cmds

Publié : jeu. févr. 01, 2018 12:51 pm
par compsystems
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 ] );

Re: Inputs cmds

Publié : jeu. févr. 01, 2018 1:03 pm
par parisse
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.