Description field line breaks when exporting in vbscript
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.
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.
Re: Description field line breaks when exporting in vbscript
Yes please little lost why it works unless the description is pretty long. Thanks.
Re: Description field line breaks when exporting in vbscript
The does not match up to the output I see. The description field is multi-valued and it pulls the entire description, in only certain instances where the description happens to be over x characters does it break to a new line when writing the output. Guess I am missing something. That same function I use, and so do others, and never see an issue, wouldn't I if it were incorrect, if i were not concatenating it?
Re: Description field line breaks when exporting in vbscript
You are assigning the description to a variable. The d3escripton is more than one line in many cases. If there is more than one lone assignment will give only the last line which may even be blank. Any multiline will not give you output to a file so it will appear to be blank.
Ther are two ways to "cat" or catentate an array. One is to use the 'Join" operator>
x = Join(myarray, "|")
The other is to enumerate the elements and catenate then with string operators;
x = x & item
"&" is the string concatenation operator.
It just hit me that you do not speak English as a first language so here are some translations for catenate:
spanish: encadenar
german: verketten
french: enchaîner
VB has the "Join" function which is misleading because "join" does not mean specifically to "catenate". It also adds a selectable piece into the catenation.
What we want is an end to end catenation. Some call that concatenating which is a redundant word in my opinion and seems awkward. The computer term has been "cat" for decades.
Some think of it as adding strinsggs to gether but that is not really what is happening.
The following will not cat these two items:
x = "1234" + 1
MsgBox x
The following will:
x = "1234" & 1
MsgBox x
The "&" is the string operator for catenation in VB languages. The + is addition. It will not correctly catenate strings in most cases if some objects are not strings. Since all variable look the same from the outside the + operator cannot be relied on to function as expected. VB adds the "&" to help solve this problem.
So in your loop try catenating the pieces of the array and you will get the whole description.
Ther are two ways to "cat" or catentate an array. One is to use the 'Join" operator>
x = Join(myarray, "|")
The other is to enumerate the elements and catenate then with string operators;
x = x & item
"&" is the string concatenation operator.
It just hit me that you do not speak English as a first language so here are some translations for catenate:
spanish: encadenar
german: verketten
french: enchaîner
VB has the "Join" function which is misleading because "join" does not mean specifically to "catenate". It also adds a selectable piece into the catenation.
What we want is an end to end catenation. Some call that concatenating which is a redundant word in my opinion and seems awkward. The computer term has been "cat" for decades.
Some think of it as adding strinsggs to gether but that is not really what is happening.
The following will not cat these two items:
x = "1234" + 1
MsgBox x
The following will:
x = "1234" & 1
MsgBox x
The "&" is the string operator for catenation in VB languages. The + is addition. It will not correctly catenate strings in most cases if some objects are not strings. Since all variable look the same from the outside the + operator cannot be relied on to function as expected. VB adds the "&" to help solve this problem.
So in your loop try catenating the pieces of the array and you will get the whole description.
Re: Description field line breaks when exporting in vbscript
Catenating in VBScript:
VBScript Code
Double-click the code block to select all.' ways of catenating a = Array("Hello","World","!") MsgBox Join(a,"|") For Each s In a x = x & s Next MsgBox x a = "Hello" MsgBox a 'this will cause an error MsgBox Join(a,"|")
Re: Description field line breaks when exporting in vbscript
Changed the function to the below with same result.
arrDesc = adoRecordSet.Fields("description").Value
' 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
strDisplayDescription = ""
Else
For Each strValue In strDescription
strDisplayDescription = strDisplayDescription & strValue
Next
End If
arrDesc = adoRecordSet.Fields("description").Value
' 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
strDisplayDescription = ""
Else
For Each strValue In strDescription
strDisplayDescription = strDisplayDescription & strValue
Next
End If
Re: Description field line breaks when exporting in vbscript
I have no idea why because I cannot see all of your code.
Change this line:
strDisplayDescription = strDisplayDescription & strValue
to:
WScript.Echo "DESC:" & strValue
See what you get.
Change this line:
strDisplayDescription = strDisplayDescription & strValue
to:
WScript.Echo "DESC:" & strValue
See what you get.
Re: Description field line breaks when exporting in vbscript
When I did that it does not output any of the description field. I made a grammar change to a few variables and attached the code. Obviously I am missing something here. Thank you.
- Attachments
-
- Document7.txt
- (5.71 KiB) Downloaded 559 times