ma701sss
asked on
Textstream - adding new lines, tabs, etc.
I create a textstream in my ASP page and read in a text file. In this text file is an email confirmation standard message, with also the text #ORDERINFO# in it somewhere. What I do once I have read in the text file is to loop through the order info then build a piece of text named orderstxt which has the order details in it. I then replace #ORDERINFO# with orderstxt. The problem is building orderstxt because I can't figure out how to add newlines, tabs, etc.
For example...
For i=0 to ubound(CCcart,2)
if CCcart(CC_PRODUCTID,i) <> "" then
orderstxt = orderstxt & "\n " & CCcart(CC_ProductID,i)
end if
Next
...just puts "\n " into the text instead of creating a newline. Should I be using ASCII characters? I don't understand if what I'm reading in is ASCII, Unicode, etc.
For example...
For i=0 to ubound(CCcart,2)
if CCcart(CC_PRODUCTID,i) <> "" then
orderstxt = orderstxt & "\n " & CCcart(CC_ProductID,i)
end if
Next
...just puts "\n " into the text instead of creating a newline. Should I be using ASCII characters? I don't understand if what I'm reading in is ASCII, Unicode, etc.
ASKER
My text file has this in it:
<--BEGIN-->
Thanks for your order!
We have pleasure in confirming your order below.
#ORDERINFO#
Please allow 2 to 3 days for your order to arrive.
<--END-->
I then read in to a textstream the text file above. I then want to take the items ordered from the shopping cart and loop through them, adding newline and tab characters, and placing them into the variable orderstxt. The text in #ORDERINFO# is then replaced with orderstxt. I then take the textstream and use it as the body in a CDONTS message, and email it to the customer.
<--BEGIN-->
Thanks for your order!
We have pleasure in confirming your order below.
#ORDERINFO#
Please allow 2 to 3 days for your order to arrive.
<--END-->
I then read in to a textstream the text file above. I then want to take the items ordered from the shopping cart and loop through them, adding newline and tab characters, and placing them into the variable orderstxt. The text in #ORDERINFO# is then replaced with orderstxt. I then take the textstream and use it as the body in a CDONTS message, and email it to the customer.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh ok...
Now, I understand, I think.....
If your email body is PLAIN TEXT then you will use "\n" and If your email body is HTML then you will need to use "<br>" for "new line".
For TAB, you can use "\t" in PLAIN TEXT but don't think there is TAB in HTML, so you might need to use (non breaking space) instead.
Inserting "new line"
PLAIN TEXT---------------------- ---------- ---------- ---------- ------
For i=0 to ubound(CCcart,2)
if CCcart(CC_PRODUCTID,i) <> "" then
orderstxt = orderstxt & "\n " & CCcart(CC_ProductID,i)
end if
Next
HTML -------------------------- ---------- ---------- ---------- ---------
For i=0 to ubound(CCcart,2)
if CCcart(CC_PRODUCTID,i) <> "" then
orderstxt = orderstxt & "<br>" & CCcart(CC_ProductID,i)
end if
Next
Insert TAB
PLAIN TEXT---------------------- ---------- ---------- ---------- ------
For i=0 to ubound(CCcart,2)
if CCcart(CC_PRODUCTID,i) <> "" then
orderstxt = orderstxt & "\t " & CCcart(CC_ProductID,i)
end if
Next
HTML -------------------------- ---------- ---------- ---------- ---------
For i=0 to ubound(CCcart,2)
if CCcart(CC_PRODUCTID,i) <> "" then
orderstxt = orderstxt & " " & CCcart(CC_ProductID,i)
end if
Next
Now, I understand, I think.....
If your email body is PLAIN TEXT then you will use "\n" and If your email body is HTML then you will need to use "<br>" for "new line".
For TAB, you can use "\t" in PLAIN TEXT but don't think there is TAB in HTML, so you might need to use (non breaking space) instead.
Inserting "new line"
PLAIN TEXT----------------------
For i=0 to ubound(CCcart,2)
if CCcart(CC_PRODUCTID,i) <> "" then
orderstxt = orderstxt & "\n " & CCcart(CC_ProductID,i)
end if
Next
HTML --------------------------
For i=0 to ubound(CCcart,2)
if CCcart(CC_PRODUCTID,i) <> "" then
orderstxt = orderstxt & "<br>" & CCcart(CC_ProductID,i)
end if
Next
Insert TAB
PLAIN TEXT----------------------
For i=0 to ubound(CCcart,2)
if CCcart(CC_PRODUCTID,i) <> "" then
orderstxt = orderstxt & "\t " & CCcart(CC_ProductID,i)
end if
Next
HTML --------------------------
For i=0 to ubound(CCcart,2)
if CCcart(CC_PRODUCTID,i) <> "" then
orderstxt = orderstxt & " " & CCcart(CC_ProductID,i)
end if
Next
ASKER
No, the "\t" doesn't work, as already mentioned.
Your suggestion of chr(9) and chr(13) works.
Your suggestion of chr(9) and chr(13) works.
Can you provide an exmaple, of the input and the output.... thanks
Are you looking for a string replace function like this (from w3school):
dim txt
txt="This is a beautiful day!"
document.write(Replace(txt
Output:This is a horrible day!