notta Posted October 22, 2008 Share Posted October 22, 2008 (edited) I'm looping through a list of Dell, HP, and some other companies serial numbers, but I'm having a problem dealing with empty fields. I want to continueloop if the field is "empty" I just did a stringlen on each element and I'm finding the "empty" fields can range from 1 character to 5 characters in length so far. I checked the ASCII of some of the empty fields and I'm getting 0 and 32(whitespace and null.) How would you guys deal with this? Thanks. Edited October 22, 2008 by notta Link to comment Share on other sites More sharing options...
martin Posted October 22, 2008 Share Posted October 22, 2008 I'm looping through a list of Dell, HP, and some other companies serial numbers, but I'm having a problem dealing with empty fields. I want to continueloop if the field is "empty" I just did a stringlen on each element and I'm finding the "empty" fields can range from 1 character to 5 characters in length so far. I checked the ASCII of some of the empty fields and I'm getting 0 and 32(whitespace and null.)How would you guys deal with this? Thanks.Can you give a small sample of what you are reading, and tell us what separates one field from another? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
notta Posted October 22, 2008 Author Share Posted October 22, 2008 I have a 1-dimensional array with about 1000 serial numbers(1 per element), but some of the elements of the array are empty. Dell sometimes doesn't bother to add the serial to the motherboard on replacements. Well I'm looping through the array and I'm checking if the element is one of the empty fields. If it is I ignore it and continue with the next iteration. I started off checking for "", but that would fail. Then I thought it might only be 1 character like a space or a TAB, so I checked for strlen <= 1, but that failed because some of the strlen returned values up to 5. Even though the one that returned 5 still returned 32 in ASCII. 5 spaces maybe? Anyway, I'm currently trying and see if that works if Asc($aSerialNumberArray[$i]) = 0 Or Asc($aSerialNumberArray[$i]) = 32 Then ContinueLoop but I'm thinking you guys would know a better way to do this. Link to comment Share on other sites More sharing options...
martin Posted October 22, 2008 Share Posted October 22, 2008 I have a 1-dimensional array with about 1000 serial numbers(1 per element), but some of the elements of the array are empty. Dell sometimes doesn't bother to add the serial to the motherboard on replacements. Well I'm looping through the array and I'm checking if the element is one of the empty fields. If it is I ignore it and continue with the next iteration. I started off checking for "", but that would fail. Then I thought it might only be 1 character like a space or a TAB, so I checked for strlen <= 1, but that failed because some of the strlen returned values up to 5. Even though the one that returned 5 still returned 32 in ASCII. 5 spaces maybe? Anyway, I'm currently trying and see if that works if Asc($aSerialNumberArray[$i]) = 0 Or Asc($aSerialNumberArray[$i]) = 32 Then ContinueLoop but I'm thinking you guys would know a better way to do this.Asc will only give the code for the first character of a string. (I am assuming that $aSerialNumberArray[$i] is your whole serial number, ie the 1-d array is $aSerialNumberArray) Maybe if there are only whitespace characters then continueloop if not StringRegExp($aSerialNumberArray[$i],"\S") then ContinueLoop Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
notta Posted October 22, 2008 Author Share Posted October 22, 2008 (edited) That's correct. $aSerialNumberArray[$i] is the current serial number I'm checking.if not StringRegExp($aSerialNumberArray[$i],"\S") then ContinueLoopI'm sorry, but regular expressions are cryptic to me. Does that check if a whitespace character is anywhere in the string? If so I'm just wondering if a serial number is in the form "DF4HSJ_________" with the trailing white space characters at the end or at the front. Know what I mean? Edited October 22, 2008 by notta Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 22, 2008 Share Posted October 22, 2008 That's correct. $aSerialNumberArray[$i] is the current serial number I'm checking. if not StringRegExp($aSerialNumberArray[$i],"\S") then ContinueLoop I'm sorry, but regular expressions are cryptic to me. Does that check if a whitespace character is anywhere in the string? If so I'm just wondering if a serial number is in the form "DF4HSJ_________" with the trailing white space characters at the end or at the front. Know what I mean? Try it this way: If StringStripWS($aSerialNumberArray[$i], 8) = "" Then ContinueLoop Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
martin Posted October 22, 2008 Share Posted October 22, 2008 That's correct. $aSerialNumberArray[$i] is the current serial number I'm checking. if not StringRegExp($aSerialNumberArray[$i],"\S") then ContinueLoop I'm sorry, but regular expressions are cryptic to me. Does that check if a whitespace character is anywhere in the string? If so I'm just wondering if a serial number is in the form "DF4HSJ_________" with the trailing white space characters at the end or at the front. Know what I mean?It checks to see if there is anything which is not a whitespace character in the string. If not , ie if there are only whitespace charaters, then continueloop. PsaltyDS's method is simpler but I thought there could be other white space characters as well as spaces, say a tab or CR or LF. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 22, 2008 Share Posted October 22, 2008 It checks to see if there is anything which is not a whitespace character in the string. If not , ie if there are only whitespace charaters, then continueloop.PsaltyDS's method is simpler but I thought there could be other white space characters as well as spaces, say a tab or CR or LF.Of course, nobody ever complains if you can find a way to slip a RegExp in there.Five geek points for martin! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
notta Posted October 23, 2008 Author Share Posted October 23, 2008 Thanks guys. if Asc($aSerialNumberArray[$i]) = 0 Or Asc($aSerialNumberArray[$i]) = 32 Then ContinueLoop if not StringRegExp($aSerialNumberArray[$i],"\S") then ContinueLoop If StringStripWS($aSerialNumberArray[$i], 8) = "" Then ContinueLoop All 3 are giving me the same exact results. I thinking I'm going to use the geek route Thanks Martin. Oh yea, I spent 2 hours and 100 lines of debug statements trying to resolve an issue. Using _arraySort and having the syntax as _arraySort($array,1) when you really meant _arraySort($array,0, 1) is bad Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now