Sign in to follow this  
Followers 0
B540glenn

Is My Assumption Correct - StringLen() syntax error

4 posts in this topic

I have a script (V3.3.8.1) that selects records from a delimited file based on a field on the record. To do this I use:

…
$fields = StringSplit($line_text, '|', 1)
If $fields[0] > 0 Then
     $length = StringLen($fields[11])

MsgBox(0, "Display", "Input Field 11 " & $fields[11] & " " & $length)

    If $length > 0 Then
…

The syntax check in Scite returns no errors.

When I run the script it produces the expected output but I get this syntax error:

$length = StringLen($fields[11])

$length = StringLen(^ ERROR

The MsgBox displays a zero for those fields that are empty so why the error?

Is this because on some records $fields[11] does not exist?

If not, what is the cause?

Just trying to understand.

Thanks,

Glenn

Share this post


Link to post
Share on other sites



The error text following ^Error describes what's going on. Can you post the text?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Once again, your socratic method has put the student on the correct path.

The message appearing above the syntax error, "Array variable has incorrect number of subscripts or subscript dimension range exceeded.:" pointed me to the field array, which, after reading all the records becomes 1 at the end of the file.

I will review my While Loop and end of file process and accomodate this situation.

Thanks for your help,

Glenn

Share this post


Link to post
Share on other sites

Glad to be of service :D


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0