From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/59354 Path: news.gmane.org!not-for-mail From: Khaled Hosny Newsgroups: gmane.comp.tex.context Subject: Re: Lua in LuaLaTeX is diferent?? Date: Sun, 6 Jun 2010 05:46:19 +0300 Message-ID: <20100606024619.GA2630@khaled-laptop> References: <4C0AB151.4060808@gyza.cz> <4C0ADF3B.9030308@gyza.cz> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1275792435 28163 80.91.229.12 (6 Jun 2010 02:47:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 6 Jun 2010 02:47:15 +0000 (UTC) To: hajtmar@gyza.cz, mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun Jun 06 04:47:13 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 1OL5tI-0005p1-P4 for gctc-ntg-context-518@m.gmane.org; Sun, 06 Jun 2010 04:47:12 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 2825FC9C67; Sun, 6 Jun 2010 04:47:12 +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 mByLvRCdAeIo; Sun, 6 Jun 2010 04:47:11 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 8DBADC9C87; Sun, 6 Jun 2010 04:47:09 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 01917C9C87 for ; Sun, 6 Jun 2010 04:47:07 +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 ySB1Ox+lIOkS for ; Sun, 6 Jun 2010 04:47:02 +0200 (CEST) Original-Received: from mail-ww0-f41.google.com (mail-ww0-f41.google.com [74.125.82.41]) by balder.ntg.nl (Postfix) with ESMTP id 7D694C9C67 for ; Sun, 6 Jun 2010 04:47:02 +0200 (CEST) Original-Received: by wwb24 with SMTP id 24so1968958wwb.14 for ; Sat, 05 Jun 2010 19:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:date:from:to:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=a3Ibkh0U838S6/gfWSEDLz7BDMKAWFyEszuoDA6rtfs=; b=GqJlIs27wHMkVsxyrpHIxK+m8TfxEtu1qToCyKH+lNfbppXlnWWSF9Yb7qcMsyxWx2 JmaW8rQScoc3x/AokFjWoiH5TCH03gssIUq8n2hieV1gEHcCOAfZLFcOhdsNO4McUs2B 8vDizuqD3k2nHPiwUxDbOW6XyJEGakArFqZds= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=KUKXyjB4BCgq8T4IDQ3I2S5AGv4z3ugC64xN9/7H5+0bb8yoJvSd75dKOOqkahQB9s AVyQaQv/NZX77yhKLsjtmYe0dCpDZdrNibm3fmZ9zNmfBnY6O4hRzX3eQ+H+VQGQ8fVi mMVoSG9O8n8lTQMvmKNJ/vunNrbXxzPCv2MeI= Original-Received: by 10.227.145.141 with SMTP id d13mr4109775wbv.40.1275792422112; Sat, 05 Jun 2010 19:47:02 -0700 (PDT) Original-Received: from localhost ([41.238.234.153]) by mx.google.com with ESMTPS id r35sm24533980wbv.17.2010.06.05.19.46.48 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 05 Jun 2010 19:47:01 -0700 (PDT) Content-Disposition: inline In-Reply-To: <4C0ADF3B.9030308@gyza.cz> User-Agent: Mutt/1.5.20 (2009-06-14) 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:59354 Archived-At: On Sun, Jun 06, 2010 at 01:35:23AM +0200, Jaroslav Hajtmar wrote: > 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 You need the lualibs package, which imports some of the extended lua librarires from ConTeXt, since string.split() is not a standad lua function. Regards, Khaled > > 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 > ___________________________________________________________________________________ -- Khaled Hosny Arabic localiser and member of Arabeyes.org team Free font developer ___________________________________________________________________________________ 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 ___________________________________________________________________________________