Parse String to test the length of a string

Got a problem you cannot solve? Try here.
MattWilkinson
Posts: 29
Joined: Thu Feb 11, 2010 7:05 am

Parse String to test the length of a string

Postby MattWilkinson » Fri Nov 18, 2011 9:10 am

I am using Parse String to try and work out the length of a string.

I am splitting a string at position 21
Parse String $VMS_SERIALNUM$ into Variables VMS_SERIAL_A and VMS_SERIAL_B (Split at position from start)
However if VMS_SERIALNUM is say 12 chars, VMS_SERIAL_A is 12 chars long, so I can't tell how long this string is if it is less than the requried length.

How can I detect the length of a string using this or another method?

giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Parse String to test the length of a string

Postby giaviv » Fri Nov 18, 2011 1:07 pm

You can use the Call DLL Function to invoke lstrlenA in kernel32.dll.

Here is a code that does this (paste this in IA):

Code: Select all

~InstallAware Clipboard Data~
~MessageBox~
~{4C809D69-42FB-4B93-AF20-590FA8966D29}~
~$SIZE$~
~$SIZE$~
~0~
~1~
~~
~Call DLL Function~
~{FF933DFF-A468-4212-92A5-508B11D56E43}~
~kernel32.dll,lstrlenA,byte,SIZE,"allocated string buffer (MAX_PATH length)",$STRING$,$~
~mIDEFunc.dll\mEXEFunc.dll~
~Set Variable~
~{7BFF1598-E6BC-448A-B195-621CEF4BD170}~
~SIZE$MYAH$MYAH$FALSE~
~~
~Set Variable~
~{6849524D-4D5A-48F3-AAC6-C0D0A50EF6B6}~
~STRING$MYAH$MYAH$FALSE~
~InstallAware~

Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

MattWilkinson
Posts: 29
Joined: Thu Feb 11, 2010 7:05 am

Re: Parse String to test the length of a string

Postby MattWilkinson » Mon Nov 21, 2011 3:49 am

Thanks Aviv - which operating system can this be used on? XP, Vista, 7, 2003, 2008 will work I am assuming?

giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Parse String to test the length of a string

Postby giaviv » Mon Nov 21, 2011 8:29 am

This works on a minimum OS of Windows 2000.
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Technical Support”

Who is online

Users browsing this forum: Bing [Bot], vaibhavopkey and 141 guests