Is there an inherit Textarea or Textbox Character Limit? NOT REFERRING to MaxLength - textarea

So I have records being read from a database and placed into a Textarea. From there the textarea is being submitted by a form so it can write the text from the textbox to a file. I am putting my code below but this really isn't a question about code... it is a question about the limitations of a textarea. Does anyone know if such limits exist?
I have run over 25,000 40 Character lines through this code with no issues. I just tried to do 125,000 40 Character lines and even though the database is right, the output file the textbox was written to only has 69,000 of the 125,000. Weird right? I assumed if this was a buffer issue I would have seen an error.
DBTABLE(125,000 Rows) --ReptRGn--> Textarea(125,000 Rows?) --POST--> WriteToFile (69,000 Rows)
Textbox with a Repeat Region in it pulling all rows (single column) from a Database Table:
<textarea name="output2" cols="50" rows="5" id="output2"><% While ((Repeat1__numRows <> 0) AND (NOT ReadTable.EOF)) %><%=(ReadTable.Fields.Item("NUMBER40").Value) %><%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
If (NOT ReadTable.EOF) Then Response.Write(vbCr)
ReadTable.MoveNext()
Wend
%></textarea>
Code to output the POSTed "output2" field into a file:
<%
function WriteToFile(FileName, Contents, Append)
on error resume next
if Append = true then
iMode = 8
else
iMode = 2
end if
set oFs = server.createobject("Scripting.FileSystemObject")
set oTextFile = oFs.OpenTextFile(FileName, iMode, True)
oTextFile.Write Contents
oTextFile.Close
set oTextFile = nothing
set oFS = nothing
end function
forty = Request.Form("output2")
WriteToFile "C:\inetpub\wwwroot\export\NUMBER40.txt", forty, False
%>
I did some research online but all I found was talk about MaxLength properties which is not this issue.
Just as a side note... I started thinking while writing this... the application starts off by you pasting in the 125,000 rows into a textarea, which gets inserted into the database table. So that sort of ruins my theory that there is a limitation on the textarea.
I would still like to know thoughts on what may be causing the data to stop being output to a file.

Related

How to detect if a field contains a character in Lua

I'm trying to modify an existing lua script that cleans up subtitle data in Aegisub.
I want to add the ability to delete lines that contain the symbol "♪"
Here is the code I want to modify:
-- delete commented or empty lines
function noemptycom(subs,sel)
progress("Deleting commented/empty lines")
noecom_sel={}
for s=#sel,1,-1 do
line=subs[sel[s]]
if line.comment or line.text=="" then
for z,i in ipairs(noecom_sel) do noecom_sel[z]=i-1 end
subs.delete(sel[s])
else
table.insert(noecom_sel,sel[s])
end
end
return noecom_sel
end
I really have no idea what I'm doing here, but I know a little SQL and LUA apparently uses the IN keyword as well, so I tried modifying the IF line to this
if line.text in (♪) then
Needless to say, it didn't work. Is there a simple way to do this in LUA? I've seen some threads about the string.match() & string.find() functions, but I wouldn't know where to start trying to put that code together. What's the easiest way for someone with zero knowledge of Lua?
in is only used in the generic for loop. Your if line.text in (♪) then is no valid Lua syntax.
Something like
if line.comment or line.text == "" or line.text:find("\u{266A}") then
Should work.
In Lua every string have the string functions as methods attached.
So use gsub() on your string variable in loop like...
('Text with ♪ sign in text'):gsub('(♪)','note')
...thats replace the sign and output is...
Text with note sign in text
...instead of replacing it with 'note' an empty '' deletes it.
gsub() is returning 2 values.
First: The string with or without changes
Second: A number that tells how often the pattern matches
So second return value can be used for conditions or success.
( 0 stands for "pattern not found" )
So lets check above with...
local str,rc=('Text with strange ♪ sign in text'):gsub('(♪)','notation')
if rc~=0 then
print('Replaced ',rc,'times, changed to: ',str)
end
-- output
-- Replaced 1 times, changed to: Text with strange notation sign in text
And finally only detect, no change made...
local str,rc=('Text with strange ♪ sign in text'):gsub('(♪)','%1')
if rc~=0 then
print('Found ',rc,'times, Text is: ',str)
end
-- output is...
-- Found 1 times, Text is: Text with strange ♪ sign in text
The %1 holds what '(♪)' found.
So ♪ is replaced with ♪.
And only rc is used as a condition for further handling.

0 Checking if TextBox.Text contains the string in the table. But it doesn't work? Lua

I am making a script inside TextButton script that will check if the TextBox contains any of the word or string inside the table.
text = script.Parent.Parent:WaitForChild('TextBox')
label = script.Parent.Parent:WaitForChild('TextLabel')
a = {'test1','test2','test3'}
script.Parent.MouseButton1Click:connect(function()
if string.match(text.Text, a) then
label.Text = "The word "..text.Text.." was found in the table."
else
label.Text = "The word "..text.Text.." was not found in the table."
end
end)
But it gives an error string expected, got table. from line 7 which is refering to the line if string.match....
Is there any way to get all text in the table?
What's the right way to do it?
Oh boy, there's a lot to say about this.
The error message
Yes.
No, seriously, the answer is yes. The error message is exactly right. a is a table value; you can clearly see that on the third line of code. string.match needs a string as its second argument, so it obviously crashes.
Simple solution
use a for loop and check for each string in a separately.
found = false
for index, entry in ipairs(a) do
if entry == text.Text then
found = true
end
end
if found then
... -- the rest of your code
The better* solution
In Lua, if we want to know if a single element is in a set, we usually take advantage of the fact that tables are implemented as hashmaps, meaning they are very fast when looking up keys.
For that to work, one first needs to change the way the table looks:
a = {["test1"] = true, ["test2"] = true, ["test3"] = true}
Then we can just index a with a string to find out if it is contained int eh set.
if a[text.Text] then ...
* In practice this is just as good as the first solution as long as you only have a few elements in your table. It only becomes relevant when you have a few hundred entries or your code needs to run absolutely as fast as possible.

How to show String new lines on gsp grails file?

I've stored a string in the database. When I save and retrieve the string and the result I'm getting is as following:
This is my new object
Testing multiple lines
-- Test 1
-- Test 2
-- Test 3
That is what I get from a println command when I call the save and index methods.
But when I show it on screen. It's being shown like:
This is my object Testing multiple lines -- Test 1 -- Test 2 -- Test 3
Already tried to show it like the following:
${adviceInstance.advice?.encodeAsHTML()}
But still the same thing.
Do I need to replace \n to or something like that? Is there any easier way to show it properly?
Common problems have a variety of solutions
1> could be you that you replace \n with <br>
so either in your controller/service or if you like in gsp:
${adviceInstance.advice?.replace('\n','<br>')}
2> display the content in a read-only textarea
<g:textArea name="something" readonly="true">
${adviceInstance.advice}
</g:textArea>
3> Use the <pre> tag
<pre>
${adviceInstance.advice}
</pre>
4> Use css white-space http://www.w3schools.com/cssref/pr_text_white-space.asp:
<div class="space">
</div>
//css code:
.space {
white-space:pre
}
Also make a note if you have a strict configuration for the storage of such fields that when you submit it via a form, there are additional elements I didn't delve into what it actually was, it may have actually be the return carriages or \r, anyhow explained in comments below. About the good rule to set a setter that trims the element each time it is received. i.e.:
Class Advice {
String advice
static constraints = {
advice(nullable:false, minSize:1, maxSize:255)
}
/*
* In this scenario with a a maxSize value, ensure you
* set your own setter to trim any hidden \r
* that may be posted back as part of the form request
* by end user. Trust me I got to know the hard way.
*/
void setAdvice(String adv) {
advice=adv.trim()
}
}
${raw(adviceInstance.advice?.encodeAsHTML().replace("\n", "<br>"))}
This is how i solve the problem.
Firstly make sure the string contains \n to denote line break.
For example :
String test = "This is first line. \n This is second line";
Then in gsp page use:
${raw(test?.replace("\n", "<br>"))}
The output will be as:
This is first line.
This is second line.

Razor adding extra newline character and white spaces to hyperlinks

I'm writing a web application that parses a text file and replaces line numbers with hyperlinks so that the user can easily navigate to a specific line number of the text file they inputted.
I'm printing a list of objects stored in the Viewbag within a .cshtml View. When I print everything as normal text, everything looks fine. For example:
--------
Summary
--------
Version 23.00.00.00
Error 007 2 at lines (09/02/2014-06:13:32.607, 5662);
Timeouts 0
Reboots 1 at lines (09/02/2014-06:12:59.900, 2)
But when I print the line numbers as hyperlinks, this happens:
--------
Summary
--------
Version 23.00.00.00
Error 007 2 at lines (09/02/2014-06:13:32.607, [5662]
);
Timeouts 0
Reboots 1 at lines (09/02/2014-06:12:59.900, [2]
)
My parser works just fine when the hyperlinks are printed as normal strings, so it looks like razor is adding extra white space before each hyperlink and an extra newline character after each hyperlink. Here is the code within the View:
<pre>
#for (int i = 0; i < ViewBag.links.Count; i++)
{
if (ViewBag.links[i].isHyperLink == true)
{
#ViewBag.links[i].text //hyperlink printed
}
if (ViewBag.links[i].isHyperLink == false)
{
#ViewBag.links[i].text; //normal text printed
}
}
</pre>
I'm quite the asp.net/razor noob so any help is very much appreciated. Thanks for your time.
P.S. I've put the text that is supposed to be hyperlinked within brackets. The hyperlink functionality didn't carry over well to stackoverflow.
edit: Here is the source as requested
--------
Summary
--------
Version 23.00.00.00
Error 007 2 at lines (09/02/2014-06:13:32.607, 5662
);
Timeouts 0
Reboots 1 at lines (09/ 2
/2014-06:12:59.900, 2)
The browser always ignores whitespace when rendering HTML. That's why the <pre> element exists. It's sole function is to tell the browser to actually take the whitespace into account when rendering. However, it's an either or proposition: either you see the whitespace, all the whitespace, or you don't. That means that if you're going to use a preformatted block, then you need to pay attention to the whitespace in your Razor code. You can do something like:
#for (int i = 0; i < ViewBag.links.Count; i++)
{
if (ViewBag.links[i].isHyperLink == true)
{#ViewBag.links[i].text}
else
{#ViewBag.links[i].text}
}
Notice how the code brackets have been collapsed around the text so that no whitespace exists. Or, preferably, since the above is quite ugly use something like a ternary:
#Html.Raw(ViewBag.links[i].isHyperLink == true
? string.Format("<a href='{0}'>{1}</a>", ViewBag.links[i].url, ViewBag.links[i].text)
: ViewBag.links[i].text)

How to keep TYPO3's RTE from adding an empty line before <ul>s

In TYPO3 4.5 as well as 6.1, whenever I add an unordered list element, RTEhtmlarera (or some of its many processing routines) will add an extra
<p> </p>
before the ul tag on saving the content element.
This happens only once, when the ul is inserted first. When the p tag is removed and the content element is saved again, it won't happen again.
How can this erroneous behaviour be removed?
Hi try set encapsLines to zero..
Setup typoscript:
tt_content.stdWrap.dataWrap >
lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines >
Not a real solution but maybe a hint in the right direction.
If you write down your list, do not press enter before the first list entry but shift+enter.
Example:
Here comes the list: <<-- AT THIS POINT PRESS SHIFT+ENTER
- a <<-- Here it does not matter if you press enter or shift+enter
- b
- c
- ...
This works for me as a workaround. I've done a lot of research in sysext:rtehtmlarea but nothing worked. So this looks for me like some kind of mysterious bug/feature connected with the "BR to P" (or vice versa) configuration you can define in pageTS or Setup. BTW: I never fully understood this conversion-thing :)
For me with 6.1 this worked:
lib.parseFunc_RTE {
externalBlocks = table, blockquote, ol, ul, div, dl, address, hr
externalBlocks {
ol.stripNL=1
ol.stdWrap.parseFunc = < lib.parseFunc
ul.stripNL=1
ul.stdWrap.parseFunc = < lib.parseFunc
# i have also seen this setting, but didn´t test it:
# blockquote.stripNLprev = 1
# blockquote.stripNLnext = 1
}
}
I removed many lines for this example, be aware that you overwrite previous settings by using {} ..

Resources