# Thread: is it possible to check maxlength?

1. ## is it possible to check maxlength?

is it possible to check maxlength value for textfield with silktest?

2. ## Re: is it possible to check maxlength?

yeah u can ,the below code u can use this is used to check the text field which accepts only 32
the code
[ ] string char33 = "012345678901234567890123456789abc"
[ ] string actual
if (Len(actual) == 32 )
print ("The text field accepts 32 characters")
else if (Len(actual)&lt;32)
Print("The text field accepts less than 32 characters")
else
print("The text field accepts more than 32 character")

3. ## Re: is it possible to check maxlength?

Try this:

<font class="small">Code:</font><hr /><pre>
[ ] use "msw.inc"
[-] integer intHex2Dec(string sHex)
[ ] //********
// @func integer | intHex2Dec |
// Returns an integer form the decimal representation of the hexidecimal value in sDec
// @parm string | sHex |
// sHex is a hexidecimal string value like "1a4c"
// @rdesc returns an integer where the hexidecimal value is converted to decimal
// @end
//********
[ ] integer iCounter, iResult = 0
[ ] sHex = Replicate("0", 8 - Len(sHex)) + Upper(sHex)
[ ]
[-] for (iCounter = 7; iCounter &gt;= 0; iCounter--)
[-] switch sHex[8-iCounter]
[-] case "0","1","2","3","4","5","6","7","8","9"
[ ] iResult = iResult + Val(sHex[8-iCounter]) * 16**iCounter
[-] case "A","B","C","D","E","F"
[ ] iResult = iResult + (Asc(sHex[8-iCounter])-55) * 16**iCounter

[-] winclass TextField : TextField // Additional and overridden methods for built-in class
[+] long GetMaxInput()
[ ] //********
// @mfunc long | TextField | GetMaxInput | Returns the maximum number of characters allowed for input
//********
[ ] integer hTxt
[ ] long lMaxLngth
[ ] hTxt = this.GetHandle()
[ ]
[ ] lMaxLngth = SendMessage(hTxt,intHex2Dec("&amp;HD5"),0,0)
[ ] return lMaxLngth

[-] testcase TestTextFieldLength() appstate none
[ ]
[ ] print(MyWindow.MyTextField.GetMaxInput())

</pre><hr />

5. ## Re: is it possible to check maxlength?

I don't know of any literature available.

6. ## Re: is it possible to check maxlength?

It used to be taught in Segue's Advanced Training class. It might still be in there. I don't know. Basically msw.inc defines some of the windows API functions. If you want specifics on what those calls do, go to Microsoft's site and search for "win32 API".

7. ## Re: is it possible to check maxlength?

I'm getting error :
*** Error: Function intHex2Dec should return a value

I changed only "winclass TextField : TextField" to
"winclass HtmlTextField : HtmlTextField"

Any ideas?

8. ## Re: is it possible to check maxlength?

Yeah, I forgot to put the 'return iResult' line at the end of the intHex2Dec() function.

9. ## Re: is it possible to check maxlength?

Actually I already tried to add it, but got some DLL related error (do not remember exact words). I will try again on Monday.

10. ## Re: is it possible to check maxlength?

during script execution i got pop up windows with text "the application or dll c:\windows\system32.user.exe is not valid Windows image. Please check against your installation diskette."

and the following error form SilkTest

*** Error: Dll cannot be loaded -- Error 139
Occured in SendMessage

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.