This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ardera's profile picture

Unfinished Capture?

Started by ardera, 22 June 2012 - 04:33 PM
ardera #1
Posted 22 June 2012 - 06:33 PM
I am working on a server and a browser that can read a special programming languange,
and in the browser there is a problem: Every time I run the browser, there is an error wich says:
"dat3:414: unfinished capture"
here is the piece of code where the error happened (whole program is 456 lines long):

if string.find(lineArray2[counter15], "SysPrt")~=nil and string.find(lineArray2[counter15], "(")~=nil and string.find(lineArray2[counter15], ")")~=nil then
   prtOutStr=""
   posAA, posBB = string.find(lineArray1[counter15], "SysPrt(")
   posAB = string.find(lineArray1[counter15], ")") - 1
   posBC=posBB+1
   varText=string.sub(posAB, posBC)
   firstPar=table.maxn(sysPrtOut)+1
   while true do
	 if string.find(varText, ">")~=nil and string.find(varText, "<")~=nil then
	   posCA = string.find(varText, ">")+1
    posDA = string.find(varText, ">")
    posDB = string.find(varText, "<")
    posCB = string.find(varText, "<")-1
    text=">"..string.sub(varText, posCA, posCB).."<"
    value=string.sub(virtVarValues[virtVarGetPos(virtVarNames, string.sub(varText, posCA, posCB))], 3, -1)
    if virtVarExist(virtVarNames, string.sub(varText, posCA, posCB)) then
   prtOutStr=ersetze(prtOutStr, text, value)
    else
	  error("Site error: Line: "..tostring(counter15+prtOut)..": Var doesn't exist: "..string.sub(varText, posCA, posCB))
    end
  else
	   break
	 end
   end
   print(prtOutStr)
elseif string.find(lineArray2[counter15], "(")~=nil then
The error happens in the last line, but in my minecraft the error happens usually 1-3 lines before the line that the error message says…
(ersetze means replace in english)
the function ersetze could be the reason for the error too, so here is the code of the ersetze function:

function ersetze(mString, pString, rString)
  if string.find(mString, pString)~=nil then
    pos1, pos2 = string.find(mString, pString)
    teilA = string.sub(mString, 1, pos1-1)
    teilB = string.sub(mString, pos2+1, -1)
    return teilA..rString..teilB
  else
    return nil
  end
end
I hope you can help me
(I come from Germany, and my English skills are bad, please forgive me)
MysticT #2
Posted 22 June 2012 - 07:29 PM
string.find gets a pattern as it's second parameter. In patterns, the ( (left bracket) is the start of a capture, so you have to escape it:

string.find(someString, "%(")
It will search for a ( in the string not %(, since % is the escape character.
More on lua patterns:
lua manual
patterns tutorial
ardera #3
Posted 22 June 2012 - 07:43 PM
ah thanks :P/>/>