Help with Lua


TheSilentDrifter
Member
Registered: 29.12.11 18:02
Timezone: UTC -7
Posts: 22

I am trying to install a window manager on my linux box, but there is an error with the source code from the designer. If anyone knows Lua, I would greatly appreciate the help.

Here is the original code:

function texfriendly_typeormod(nm)
      if string.find(nm, "A-Z") then
>>        return "\\type{"..string.gsub(nm, '_', '\_').."}"
      else
          return "\\code{"..nm.."}"
      end
end

According to my compiler:

  return "\\type{"..string.gsub(nm, '_', '\_').."}" 

Tells me

---this---> '\_'

is an invalid escape.

Again, any help would be fantastic

i169.photobucket.com/albums/u209/eowdaemon/TheSilentDrifter-1.jpg


j4m32
Member
Registered: 25.08.11 02:05
Timezone: UTC +0
Posts: 11

Hello there,

I'm not overly familiar with Lua, so forgive me if I am wrong in my assumptions, however the escape sequences used for strings are pretty much universal in form between languages.

If I've interpreted the code you've written correctly, you're trying to output a replaced string which provides the escaped version of the character '_' as '\_'?

If so, then I think you may need to put '\\_'.

If not, then I don't know and I hope you find the right solution. smile

Jim,


ynori7
Administrator
Registered: 24.08.11 12:16
Timezone: UTC +2
Posts: 168

Yeah, as james said, \ is not only an escape character in regex, but also usually an escape character in strings in most languages, so you have to escape the backslash as well.

i537.photobucket.com/albums/ff338/ynori77/archenemysig1.jpg


TheSilentDrifter
Member
Registered: 29.12.11 18:02
Timezone: UTC -7
Posts: 22

See, that is what I thought, but it is still throwing me an error when I run 'make.'

make[1]: Entering directory `/home/<user>/Downloads/ion-3-20090110/mod_tiling'
/usr/local/bin/lua ../libextl/libextl-mkexports -module mod_tiling -o exports.c -h exports.h \
        main.c tiling.c placement.c split.c split-stdisp.c splitfloat.c panehandle.c ops.c 
/usr/local/bin/lua: ../libextl/libextl-mkexports:761: attempt to call field 'getn' (a nil value)
stack traceback:
        ../libextl/libextl-mkexports:761: in main chunk
        [C]: in ?
make[1]: *** [exports.c] Error 1
make[1]: Leaving directory `/home/<user>/Downloads/ion-3-20090110/mod_tiling'
make: *** [subdirs] Error 2

So i looked at line 761 and it has this:

if table.getn(inputs)==0 then
    usage()
end

Is there just an issue with the variables being passed?
It seems like I am missing something totally obvious...

Thanks again.

i169.photobucket.com/albums/u209/eowdaemon/TheSilentDrifter-1.jpg


ynori7
Administrator
Registered: 24.08.11 12:16
Timezone: UTC +2
Posts: 168

I'm guessing that file is a library, right?

It's a pretty unclear error message, but based on this:

/usr/local/bin/lua: ../libextl/libextl-mkexports:761: attempt to call field 'getn' (a nil value)

I would guess that either table, getn, or input is null. But since it's probably a library I guess that table and getn are there, so input is the likely suspect.

EDIT: Just to be clear, I don't know any Lua, so I'm just making an educated guess on this stuff.

i537.photobucket.com/albums/ff338/ynori77/archenemysig1.jpg


TheSilentDrifter
Member
Registered: 29.12.11 18:02
Timezone: UTC -7
Posts: 22

ynori7 wrote:
EDIT: Just to be clear, I don't know any Lua, so I'm just making an educated guess on this stuff.

I understand that Lua not a very popular language, but it's what they used. Any information can help. Thanks for that. Still working with it. I'll post an update if I figure it out.

i169.photobucket.com/albums/u209/eowdaemon/TheSilentDrifter-1.jpg