Recognition of assume(s,DOM_STRING);

Messages in english

Modérateur : xcasadmin

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

Recognition of assume(s,DOM_STRING);

Message par compsystems » ven. sept. 07, 2018 10:34 pm

Hello, although there is the InputStr command to capture a string type data, for example with spaces, I think that the INPUT command could also act similarly if the variable is predefined as a string


EXAMPLE 1

Code : Tout sélectionner

InputStr("Enter a string",s);
print("s="+s);
If the user enters 1 2 3
print
1 2 3 // ok

EXAMPLE 2

Code : Tout sélectionner

input("Enter a string",s);
print("s="+s);
If the user enters 1 2 3
syntax error // ok

EXAMPLE 3

Code : Tout sélectionner

assume(s,DOM_STRING);
input("Enter a string",s);
print("s="+s);
should not return syntax error, because the expected type is a string

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

Re: Recognition of assume(s,DOM_STRING);

Message par parisse » sam. sept. 08, 2018 5:58 am

input does not check anything on the previous content of variables, it just overwrites. Like := or assume. And I don't see why it would be better to run 2 commands (assume+input) instead of 1 (InputStr).

Répondre