The eccoMAGIC Forums
http://forums.eccoMAGIC.com/forum/YaBB.pl
Ecco Tutorials, Tips and How-to Guides >> How do I ..... >> LUA basics: IF THEN ELSE...
http://forums.eccoMAGIC.com/forum/YaBB.pl?num=1209912956

Message started by ykorovin on 05/04/08 at 09:55:55

Title: LUA basics: IF THEN ELSE...
Post by ykorovin on 05/04/08 at 09:55:55

hi guys, i take basic example from http://lua-users.org/wiki/ControlStructureTutorial

Code:
if 1>10 then print("bigger") else print("smaller") end

post it into LUA script and it doe snot work.
I post it into LUA expression evaluator , and it says [Syntax error at char [4]!]

Title: Re: LUA basics: IF THEN ELSE...
Post by Admin on 05/05/08 at 18:29:24




1.  notice the "Normal" ... this is for testing normal rule expressions.

goto that box and down arrow to LUA  then try again..


2. 'print'  not very productive this way in ecco... maybe try like this instead:


Code:
if 1>10 then msgbox("bigger") else msgbox("smaller") end



Title: Re: LUA basics: IF THEN ELSE...
Post by ykorovin on 05/06/08 at 12:27:03

Thanks for hint with arrow! drop down list looks inviting, but does not work ;)

And thanks, this work now with your help.

This is a basic function that sets a key number to the ItemKeyNumber folder.
If key number was set already, it leaves it intact.
If it was not set, it makes it max+1.

This can be useful when you export your items somewhere, eg to excel, and want to have a specific key to identify items. For example if you make pivots and summarize costs by another columns, or draw graphs.


Code:
function setnewkey()
curentvalue = 0 + ("0" .. get_folder_value("ItemKeyNumber",get_select_items()[1]) )   --- leave current value as is, or set it = 0, but not leave NULL.
if curentvalue ==0 then                          --- then set curentvalue = max+1
     x = get_folder_items("ItemKeyNumber")  
     max=table.maxn(x)
     m=0
           for i=1,max do                        --- discover what is the max
           m = math.max(m, get_folder_value("ItemKeyNumber",x[i]) )
           end
     set_folder_value("ItemKeyNumber",get_select_items()[1],m+1)
end
end

The eccoMAGIC Forums » Powered by YaBB 2.1!
YaBB © 2000-2005. All Rights Reserved.