OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: KTottE on 02 Jan 2003, 14:22:06
-
Righto, I wonder if any of you lot have a (simple) way of limiting the amount of input in an edit box (CT_EDIT)?
I know I can probably do a work around, but I'd rather not, so I wonder if there's an easy way of limiting the number of letters and numbers in an edit field. (Got two edit fields, one for letters, one for numbers, max 2 in each)
*rolls off*
-
Only one idea, 2 fields, one for input letter one by one, and a second with the text. And for manage this an array.
Like 60' computers... ::)
For me most part of entries are solve by combos and buttons. What do you want exactly?
-
Erm, I'd appriciate it if you'd read my posts before answering, this is the second time today you pretty much repeat what I said ;D
I have
Two edit fields.
Edit 1 will take two letters
Edit 2 will take two numbers
One submit button (OK) which will execute a script that gets the numbers and letters from Edit 1 and Edit 2.
What I need
Something to limit the number of characters a player can input in Edit 1 and Edit 2.
Maximum of 2 letters or 2 numbers (depending on edit field).
How do I stop a player from entering more than two letters into an edit field?
-
For letters
One field and a second field
MyoneField = ctrltext idcofOneField
? MyOneField != "" : MyArray = MyArray + MyOnefield ; TextOfSecondField = TextOfSecondField + MyOneField ; ctrlSettext [idcofOneField,""] ; ctrlsettext [idcOfSecondField,TextOfSecondField ]
? count Myarray > 2 : ctrlEnable [idcOfMyOnefield, false]
For numbers
You can convert string to num with this :
TheNumberString = ctrlText 100
TheNumber = -1
("TheNumber = " + TheNumberString ) ForEach [0] ("TheNumber = " + TheNumberString ) ForEach
? theNumber > 99 :ctrlEnable [100, false]
Or you can do the same for number and do a filter, don't know if ? stringA == stringB works but with array works.
Sorry if I'm not clear, it's my English and .... my nature
-
? count Myarray > 2 : ctrlEnable [idcOfMyOnefield, false]
What will that do exactly?
Will it disable the player from entering more letters, or will it disable the entire control and therefore clearing the contents out?
-
I do some test :
If you desable a ct_edit you cannot entry but if you assign a value you see it.
This works :
; 100004 idc of the edit field, 1000012 idc for show value
_text = ""
ctrlenable [100012,false]
_Z = 0
#MainLoop
~0.1
? _Z < 3 : ctrlSetText [100012,_Text ]
? (ctrltext 100004 != "") : _Text = _Text + ctrltext 100004 ; ctrlSetText [100004,""] ; _z =_z +1
? (ctrlVisible 100004) : goto "Mainloop"
For a better effect I have put the 2 field at the same place, only one minor problem the cursor is always left.
The array is not useful in fact.
-
;D
I'll work something out then, thanks for your help anyways.