input and carriage return

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
aranginor
Giant
Posts: 131
Joined: Fri Dec 05, 2008 2:32 pm

input and carriage return

Post by aranginor »

When using input with a textbox, if you paste information that contains carriage returns, are those carriage returns automatically stripped before assigning the information to the variable?
If not, can the carriage returns be detected?

User avatar
Bone White
Great Wyrm
Posts: 1124
Joined: Tue Aug 23, 2011 11:41 am
Location: Cornwall, UK

Re: input and carriage return

Post by Bone White »

aranginor wrote:When using input with a textbox, if you paste information that contains carriage returns, are those carriage returns automatically stripped before assigning the information to the variable?
If not, can the carriage returns be detected?
To your first question, I don't know, but you can find out with my answer below, which explains how to detect them.

Use Wiki: encode() then search the encoded string for the code for carriage return. (%0D)

You can find a full list of encoded non-printing characters at the bottom of this page: http://www.w3schools.com/tags/ref_urlencode.asp

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: input and carriage return

Post by aliasmask »

No, they are not stripped. I have a lib:token called RPEdit that uses a textbox and there are some things you have to do to clean stuff up. For example, if you want to change all the line feeds to html <br> tags, then you do this.

Code: Select all

[H: textboxText = replace(textboxText,"\\n","<br />")] 
Another thing to note about textbox data being passed is that it converts all the ; to &#59, so you'll need to replace those as well. If you end up using RPEdit, you have to code that string as "&#"+59 so the parser doesn't convert it inadvertently.

I also recommend using Notepad++ or similar product to filter your data, or to at least establish what kind of funky characters you may be processing. I would convert the windows open and close quotes to " as an example. I don't know the unicode for those offhand.

aranginor
Giant
Posts: 131
Joined: Fri Dec 05, 2008 2:32 pm

Re: input and carriage return

Post by aranginor »

ok, here is what I am trying

[H: status = input("inputtext|Paste Here|Paste Test|TEXT|WIDTH = 40")]
[H: inputtext = replace(inputtext,"\\n","<br />")]
[r: inputtext]

I am copying from Notepad++ and pasting into the input. The data is as follows:
This<CR><LF>
is<CR><LF>
a<CR><LF>
test

This is the result:
This is a test

This is the desired result:
This
is
a
test

What am I doing wrong?

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: input and carriage return

Post by Azhrei »

Bone White wrote:You can find a full list of encoded non-printing characters at the bottom of this page: http://www.w3schools.com/tags/ref_urlencode.asp
Or use the one hosted at RPTools.net which has a filtering text box that makes it much easier to find what you want. 8)

http://www.rptools.net/index.php?page=h ... in-maptool

User avatar
Bone White
Great Wyrm
Posts: 1124
Joined: Tue Aug 23, 2011 11:41 am
Location: Cornwall, UK

Re: input and carriage return

Post by Bone White »

Azhrei wrote:
Bone White wrote:You can find a full list of encoded non-printing characters at the bottom of this page: http://www.w3schools.com/tags/ref_urlencode.asp
Or use the one hosted at RPTools.net which has a filtering text box that makes it much easier to find what you want. 8)

http://www.rptools.net/index.php?page=h ... in-maptool
You wrote all that to replace my ctrl+F shortcut?

My keyboard will be indebted to you for the extra few seconds it takes to break ;)

I have to ask however, why if I encode a carriage return in maptool and output it to chat i get "%0D" yet if I look at the entry on the page you linked, it shows "↵ crarr #8629 downwards arrow with corner leftwards = carriage return, U+21B5 NEW".

How do I use that information to search for carriage return? Do I search the non-encoded string for "#8629"?

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: input and carriage return

Post by Azhrei »

Bone White wrote:You wrote all that to replace my ctrl+F shortcut?
Your ^F doesn't do the same thing. And you're welcome. 8)
I have to ask however, why if I encode a carriage return in maptool and output it to chat i get "%0D" yet if I look at the entry on the page you linked, [...]
Um, because I'm a dufus and didn't notice that you were talking about Wiki: encode()?

The page I linked has no help whatsoever for what you're talking about (encoded ASCII). It's geared towards helping people find the HTML entity for a particular glyph. My bad. :(

Post Reply

Return to “Macros”