Description field line breaks when exporting in vbscript

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 10 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
new_user
Posts: 157
Last visit: Tue May 06, 2014 5:46 pm

Description field line breaks when exporting in vbscript

Post by new_user »

Hello. I am looking for some help with an issue that I have not seen before when using an array to export the description field for user accounts. I can attached the entire script if needed although the arr used is below. On some users they have a long description for one reason or another and when writing out to a log file it breaks to a new line at some point in writing the description. I am writing 5-6 different attributes and description is last if that matters. Any help is appreciated.

The description attribute is multi-valued, but
' there is never more than one item in the array.
arrDesc = adoRecordset.Fields("description").Value
If IsNull(arrDesc) Then
strDescription = ""
Else
For Each strItem In arrDesc
strDescription = strItem
Next
End If
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Description field line breaks when exporting in vbscript

Post by jvierra »

Take a look at you post. The text is unreadable.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Description field line breaks when exporting in vbscript

Post by jvierra »

Just get the fist item
desc = arrDesc(0)
User avatar
new_user
Posts: 157
Last visit: Tue May 06, 2014 5:46 pm

Re: Description field line breaks when exporting in vbscript

Post by new_user »

Sorry. The description arr I am using to get everything in the description field is:

' The description attribute is multi-valued, but
' there is never more than one item in the array.
arrDesc = adoRecordset.Fields("description").Value
If IsNull(arrDesc) Then
strDescription = ""
Else
For Each strItem In arrDesc
strDescription = strItem
Next
End If
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Description field line breaks when exporting in vbscript

Post by jvierra »

new_user wrote:Sorry. The description arr I am using to get everything in the description field is:

' The description attribute is multi-valued, but
' there is never more than one item in the array.
arrDesc = adoRecordset.Fields("description").Value
If IsNull(arrDesc) Then
strDescription = ""
Else
For Each strItem In arrDesc
strDescription = strItem
Next
End If
But that only gets the last element of the array. Try catting them.
User avatar
new_user
Posts: 157
Last visit: Tue May 06, 2014 5:46 pm

Re: Description field line breaks when exporting in vbscript

Post by new_user »

Thank you for the reply not sure what you are referring to by catting them; how would that array to capture the description field contents change?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Description field line breaks when exporting in vbscript

Post by jvierra »

Sorry - catenate them.
User avatar
new_user
Posts: 157
Last visit: Tue May 06, 2014 5:46 pm

Re: Description field line breaks when exporting in vbscript

Post by new_user »

My code is attached to show how I am calling the array. and example of the output capture is also attached. This does work except if the data in the description field is very long. I am not clear regarding concatenating.
Attachments
Capture.JPG
Capture.JPG (65.18 KiB) Viewed 26174 times
LockedOut_.txt
(5.65 KiB) Downloaded 535 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Description field line breaks when exporting in vbscript

Post by jvierra »

It is used all of the time in every area of language and computers.

http://www.thefreedictionary.com/catenate

We "cat" something. In Unix there is even a command called "cat". It comes from "catenate". It has nothing to do with cute little kitties.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Description field line breaks when exporting in vbscript

Post by jvierra »

To be clearer. You are assigning an array element to a string. It needs to be catenated and not assigned.

There is a command that does that.

Do you need an example?
This topic is 10 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked