Jump to content

Is My Assumption Correct - StringLen() syntax error


Recommended Posts

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

Link to comment
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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
Share on other sites

Glad to be of service :D

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...