ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Jaroslav Hajtmar <hajtmar@gyza.cz>
To: ntg-context@ntg.nl
Subject: Re: Lua in LuaLaTeX is diferent??
Date: Sun, 06 Jun 2010 01:35:23 +0200	[thread overview]
Message-ID: <4C0ADF3B.9030308@gyza.cz> (raw)
In-Reply-To: <4C0AB151.4060808@gyza.cz>

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
___________________________________________________________________________________


  reply	other threads:[~2010-06-05 23:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-05 20:19 Jaroslav Hajtmar
2010-06-05 23:35 ` Jaroslav Hajtmar [this message]
2010-06-06  2:46   ` Khaled Hosny
2010-06-06  6:15     ` Jaroslav Hajtmar
2010-06-06  6:34       ` Jaroslav Hajtmar
2010-06-06 11:17         ` Hans Hagen
2010-06-06 13:00       ` Khaled Hosny
2010-06-06 11:42   ` Hans Hagen
2010-06-06 11:13 ` Hans Hagen
2010-06-06 18:24   ` Jaroslav Hajtmar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C0ADF3B.9030308@gyza.cz \
    --to=hajtmar@gyza.cz \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).