Welcome, Guest. Please Login or Register.
eccoMAGIC Forums
05/04/24 at 15:05:57
News: Welcome to the eccoMAGIC forum.
Home Help Search Login Register


Pages: 1
Send Topic Print
LUA basics: IF THEN ELSE... (Popularity: 5329 )
cowdad
Contributing  Member
***


I Love Ecco!

Posts: 23
Show the link to this post LUA basics: IF THEN ELSE...
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]!]
Back to top
 

lua_-_if_then_else.gif
  IP Logged
Admin
Administrator
*****


I love Ecco!

Posts: 134
Show the link to this post Re: LUA basics: IF THEN ELSE...
Reply #1 - 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  


 
Back to top
 
 

The Administrator.
WWW   IP Logged
cowdad
Contributing  Member
***


I Love Ecco!

Posts: 23
Show the link to this post Re: LUA basics: IF THEN ELSE...
Reply #2 - 05/06/08 at 12:27:03
 
Thanks for hint with arrow! drop down list looks inviting, but does not work Wink
 
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
 

Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print