Avoiding words longer than X letters

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?

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

I imagine you need to use a *temp variable.

*temp length 0
*set length length(word)

*if (length >7)
	Text here.
1 Like
*label str_input
*temp str
*input_text str
*if (length(str) > 7)
    *goto str_input

Works OK for me.


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:

  1. The length of an input
  2. 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

I am Not sure,but from Just looking at it, shouldn’t you Check length(fname) to get the length of it? Like:

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


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


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


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.)


You can also try “*if choice_randomtest”.


This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.