RPTools.net

Discussion and Support

Skip to content

It is currently Mon Dec 18, 2017 12:16 am 






Reply to topic  [ 7 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Cave Troll
 
Joined: Fri Dec 05, 2008 2:32 pm
Posts: 48
 Post subject: input and carriage return
PostPosted: Sat Oct 15, 2011 11:44 am 
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?


Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Tue Aug 23, 2011 10:41 am
Posts: 1134
Location: Cornwall, UK
 Post subject: Re: input and carriage return
PostPosted: Sat Oct 15, 2011 12:05 pm 
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

_________________
How to get around the two code nest limit in MapTool (and MOTE)


Top
 Profile  
 
User avatar  Online
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7969
Location: Bay Area
 Post subject: Re: input and carriage return
PostPosted: Sat Oct 15, 2011 1:00 pm 
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:
[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.

_________________
Downloads:


Top
 Profile  
 
 Offline
Cave Troll
 
Joined: Fri Dec 05, 2008 2:32 pm
Posts: 48
 Post subject: Re: input and carriage return
PostPosted: Sat Oct 15, 2011 3:49 pm 
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?


Top
 Profile  
 
User avatar  Offline
Site Admin
 
Joined: Mon Jun 12, 2006 12:20 pm
Posts: 12103
Location: Tampa, FL
 Post subject: Re: input and carriage return
PostPosted: Sun Oct 16, 2011 6:21 pm 
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


Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Tue Aug 23, 2011 10:41 am
Posts: 1134
Location: Cornwall, UK
 Post subject: Re: input and carriage return
PostPosted: Sun Oct 16, 2011 6:27 pm 
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"?

_________________
How to get around the two code nest limit in MapTool (and MOTE)


Top
 Profile  
 
User avatar  Offline
Site Admin
 
Joined: Mon Jun 12, 2006 12:20 pm
Posts: 12103
Location: Tampa, FL
 Post subject: Re: input and carriage return
PostPosted: Sun Oct 16, 2011 9:39 pm 
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)

Quote:
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. :(


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 7 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 2 guests





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman