OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: dmakatra on 07 Oct 2003, 19:06:51

Title: Check number of letters in CT_EDIT
Post by: dmakatra on 07 Oct 2003, 19:06:51
I was wondering if there's a way to see if there's been written anything in a CT_EDIT field. Perhaps check the number of letters or something ???

:cheers: Cheers! :cheers:

:beat: *Gets Shot* :beat:
Title: Re:Check number of letters in CT_EDIT
Post by: dmakatra on 08 Oct 2003, 08:02:15
OK, I'll explain in more detail:

What I'm trying to do is a dialog where the player chooses the amount of players("hotseat" in OFP) and then, in the same dialoge, writing in the names in a CT_EDIT field. What I want is to check if the amount of players, say 4, have written their names in the correct CT_EDIT field, and if they have not, for example p1, p2, p3 has written in the right but p4 has written in p6's field, an error will come up.
Anyone have any ideas?

:beat: *Gets Shot* :beat:
Title: Re:Check number of letters in CT_EDIT
Post by: Spinor on 08 Oct 2003, 13:48:12
To check if anything has been entered into an edit field, you simply test for
ctrlText id != ""
e.g. with a waiting command (to capture the input instantly) like:

@ctrlText id != _old
hint "Text entered"

To check for the length of the entered string is possible (with constraints),
but very tricky. In essence, you have capture every entering of a character
with somethin like:

_length = 0

#NewCheck
_old = ctrlText id
@ctrlText id != _old
_length = _length + 1; hint format["Length: %1", _length]
goto "NewCheck"

This is not foolproof, though: Using Backspace will mess it up.