There was a way to keep words from the input_text command below a certain length. What was it again?
If I use
*if (length(word) >7)
it tells me it’s not a number. How can I avoid longish inputs?
EDIT:
Found the culprit: Checking it against a number seems to work fine, but checking it against another words length isn’t:
*if ((length(sname) >7) or (length(sname) >(fname))
How can I check if ‘sname’ is longer than ‘fname’ ?
1 Like
CJW
April 7, 2021, 6:06pm
3
*label str_input
*temp str
*input_text str
*if (length(str) > 7)
*goto str_input
Works OK for me.
2 Likes
Szaal
April 7, 2021, 6:09pm
4
length(variable)
is not a variable on itself; it’s an operator, similar as +variable
or round(variable)
. By same logic, you can’t have a +variable > 7
statement.
1 Like
Okay, I think I found the problem.
The *if in question checks for two things:
The length of an input
the length of an input compared to another. I think the issue stems from this:
*if ((length(sname) >7) or (length(sname) >(fname))
How can I make it check if variable A is longer than B?
1 Like
Kaelyn
April 8, 2021, 7:24am
6
I am Not sure,but from Just looking at it, shouldn’t you Check length(fname) to get the length of it? Like:
length(sname)>length(fname)
So that the length will be compared? Or is the variable fname a number?
1 Like
It will tell me it’s not a number.
All I want is to check if X is longer than Y.
Example: if sname is Macky and fname is Mark… granted, that would work as a nickname, but you catch my drift
2 Likes
CJW
April 8, 2021, 10:21am
8
As @Kaelyn says, you need to do a length call on both strings.
“fname” will indeed, not be a number.
length(fname) will be.
1 Like
I tried that. It says it expected a parentheses in there somewhere…
*if ((length(sname) >7) or (length(sname) > length(fname))
i just don’t know where to put it
2 Likes
Kaelyn
April 8, 2021, 10:55am
10
There is a Last ) Missing at the end, you have one for (fname) and one for the comparison, the one for the whole If statement is missing
6 Likes
Thanks, it finally worked (just need to remember to remove it when i’m running randomtest. Or remove it entirely after all down the line. we’ll see.)
3 Likes
CJW
April 8, 2021, 5:40pm
12
You can also try “*if choice_randomtest”.
3 Likes
system
Closed
April 9, 2021, 5:41pm
13
This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.