From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/59353 Path: news.gmane.org!not-for-mail From: Jaroslav Hajtmar Newsgroups: gmane.comp.tex.context Subject: Re: Lua in LuaLaTeX is diferent?? Date: Sun, 06 Jun 2010 01:35:23 +0200 Message-ID: <4C0ADF3B.9030308@gyza.cz> References: <4C0AB151.4060808@gyza.cz> Reply-To: hajtmar@gyza.cz, mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1275780939 5347 80.91.229.12 (5 Jun 2010 23:35:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 5 Jun 2010 23:35:39 +0000 (UTC) To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Sun Jun 06 01:35:36 2010 connect(): No such file or directory Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OL2tr-0005ly-O8 for gctc-ntg-context-518@m.gmane.org; Sun, 06 Jun 2010 01:35:35 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 2F99EC9C67; Sun, 6 Jun 2010 01:35:35 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id iClgNjlal68g; Sun, 6 Jun 2010 01:35:32 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id A282AC9C04; Sun, 6 Jun 2010 01:35:32 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id DAFE3C9C04 for ; Sun, 6 Jun 2010 01:35:30 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id eZESojtsgbAu for ; Sun, 6 Jun 2010 01:35:28 +0200 (CEST) Original-Received: from psi2.forpsi.com (smtpa.forpsi.com [81.2.195.204]) by balder.ntg.nl (Postfix) with SMTP id 1B950C9BB3 for ; Sun, 6 Jun 2010 01:35:28 +0200 (CEST) Original-Received: (qmail 21215 invoked by uid 89); 5 Jun 2010 23:35:26 -0000 Original-Received: from unknown (HELO ?192.168.1.3?) (hajtmar@gyza.cz@88.103.230.14) by psi02 with ESMTPA; 5 Jun 2010 23:35:26 -0000 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; cs; rv:1.9.1.8) Gecko/20100216 Thunderbird/3.0.2 In-Reply-To: <4C0AB151.4060808@gyza.cz> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:59353 Archived-At: Hi, I am sending examples of functions: The first function is functional in ConTeXt MKIV even LuaLaTeX. -- Global variables for setup in library (it be used when glob. vars Sep, Ld, Rd is not setting in main aplication): UserCSVSeparator=';' UserCSVLeftDelimiter='' UserCSVRightDelimiter='' function ParseCSVdata(s) local Sep = (Sep == nil) and UserCSVSeparator or Sep local Ld = (Ld == nil) and UserCSVLeftDelimiter or Ld local Rd = (Rd == nil) and UserCSVRightDelimiter or Rd if Ld ~= '' or Rd ~= '' then local s=string.sub(s, string.find(s, Ld)+1, string.find(s, Rd,-1)-1) end local fieldsep=tostring(Rd..Sep..Ld) local result = {} local from = 1 local sep_from, sep_to = string.find( s, fieldsep, from ) while sep_from do table.insert( result, string.sub( s, from , sep_from-1 ) ) from = sep_to + 1 sep_from, sep_to = string.find( s, fieldsep, from ) end table.insert( result, string.sub( s, from ) ) return result end The second is more universal, but it only works in ConTeXt MKIV. LuaLaTeX report error: "attempt to call field 'split' (a nil value) ... ." function ParseCSVdata(string2parse, separator, leftdelimiter, rightdelimiter) Sep = (Sep == nil) and UserCSVSeparator or Sep Ld = (Ld == nil) and UserCSVLeftDelimiter or Ld Rd = (Rd == nil) and UserCSVRightDelimiter or Rd local separator = (separator == nil) and Sep or separator local leftdelimiter = (leftdelimiter == nil) and Ld or leftdelimiter local rightdelimiter = (rightdelimiter == nil) and Rd or rightdelimiter local result={} if leftdelimiter ~= '' and rightdelimiter ~= '' then string.gsub(string2parse, leftdelimiter.."(.-)"..rightdelimiter, function(a) table.insert(result,a) end ) else result=string.split(string2parse,separator) end return result end I would like to benefit from the second function, but I want the application was applicable even LuaLaTeX Thanx Jaroslav Dne 5.6.2010 22:19, Jaroslav Hajtmar napsal(a): > Hi, > I did a Lua application for ConTeXt, and now I wanted to adapt it to > work even LuaLaTeX. > On what needs to be careful? Compiling by LuaLaTeX specific messages > appear as if the Lua in LuaLaTeX didnt know some Lua commands (i.e. > split, find .... ). > > On what needs to be careful generaly when programming applications for > LuaLaTeX? > > Thanx Jaroslav > ___________________________________________________________________________________ > > If your question is of interest to others as well, please add an entry > to the Wiki! > > maillist : ntg-context@ntg.nl / > http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ > > ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________