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 ___________________________________________________________________________________