Indigo Rose Software
  #1  
Old 1 Week Ago
rexzooly rexzooly is offline
Forum Enthusiast
 
Join Date: Jul 2007
Posts: 1,515
function creation

When making functions how do i enable it so i can use EG:

_Left or _Right not "_Left" or "_Right",

I really can't work it out any ideas? as this would clean up my functions and also help with my plugin

Rex
Reply With Quote
  #2  
Old 1 Week Ago
rexzooly rexzooly is offline
Forum Enthusiast
 
Join Date: Jul 2007
Posts: 1,515
Is this right

Ok am i right in thinking i have to defind them vebs before

_Right = "_Right";
_Left = "_Left";

Rex
Reply With Quote
  #3  
Old 1 Week Ago
rexzooly rexzooly is offline
Forum Enthusiast
 
Join Date: Jul 2007
Posts: 1,515
Ok new problem.

I get my others working and say i do Get(_Right, eType);

and the Get is

function Get(_Right, eType, eName);

eType..Prop = eType.GetPos(eName);

end

i get a error bla bla =;

I want to streal line a function to do many things and i need to do this how can
i do it?

Why can't i dynamicly get set my verbs?
Reply With Quote
  #4  
Old 1 Week Ago
Sakuya's Avatar
Sakuya Sakuya is offline
Forum Member
 
Join Date: Oct 2009
Posts: 113
Quote:
Originally Posted by rexzooly View Post
Ok new problem.

I get my others working and say i do Get(_Right, eType);

and the Get is

function Get(_Right, eType, eName);

eType..Prop = eType.GetPos(eName);

end

i get a error bla bla =;

I want to streal line a function to do many things and i need to do this how can
i do it?

Why can't i dynamicly get set my verbs?
You lost me.

Streal line a function? Dynamically set verbs?

Also I don't think this is Lua..

Code:
eType..Prop = eType.GetPos(eName);
I'm pretty sure it should be:

Code:
eType.Prop = eType.GetPos(eName);
..and if I assume that eType is a table such as Image and eName is the object name, what are you trying to do?
Reply With Quote
  #5  
Old 1 Week Ago
rexzooly rexzooly is offline
Forum Enthusiast
 
Join Date: Jul 2007
Posts: 1,515
Not sure what i was trying to way there sorry lol i will explane again silly me.


Ok i have a function

Something(_Img, "Image1");

function Something(eType, eName)
if eType == _Img then
ImageName Do
elseif eType == _Label then
LableName Do
end
end

what i want do do is insted of all the else ifs i wants to make the sting to right the Veb Dynamic aka eType.SetVisable(eName);

I have manual did the if commands for now but i was just thinking od a way to shorten my functions.
Reply With Quote
  #6  
Old 1 Week Ago
holtgrewe holtgrewe is offline
Indigo Rose Customer
 
Join Date: Jul 2002
Location: Just South of Reality
Posts: 732
Code:
function SetVisible(MyObject)
  TheObj=Page.GetObjectType (""..MyObject)
  if TheObj == 0 then Button.SetVisible(""..MyObject, true)
  elseif TheObj == 1 then Label.SetVisible(""..MyObject, true)
  elseif TheObj == 2 then Paragraphl.SetVisible(""..MyObject, true)
  elseif TheObj == 3 then Image.SetVisible(""..MyObject, true)
--etc for the rest of the objects
  end 
end -- function
Somewhere in the coding you will have to determine what the object type is, using nested if's or whatever method...if it's in a functon, it is a simple copy and paste from one project to the next.

I'm certain that someone with the skills could write a plugin or dll to accomplish this also...but why...?

The above example should set any object on a page visible (you will have to include the "elseif logic" for the remainder of the AMS objects of course. You could easily convert the coding to a table structure as well.

SetVisible("AnyObject")

You could create similar function for "SetInvisible", "SetEnabled", etc.

hth

Last edited by holtgrewe; 1 Week Ago at 08:53 AM.
Reply With Quote
  #7  
Old 1 Week Ago
Sakuya's Avatar
Sakuya Sakuya is offline
Forum Member
 
Join Date: Oct 2009
Posts: 113
Quote:
Originally Posted by holtgrewe View Post
Code:
function SetVisible(MyObject)
  TheObj=Page.GetObjectType (""..MyObject)
  if TheObj == 0 then Button.SetVisible(""..MyObject, true)
  elseif TheObj == 1 then Label.SetVisible(""..MyObject, true)
  elseif TheObj == 2 then Paragraphl.SetVisible(""..MyObject, true)
  elseif TheObj == 3 then Image.SetVisible(""..MyObject, true)
--etc for the rest of the objects
  end 
end -- function
Somewhere in the coding you will have to determine what the object type is, using nested if's or whatever method...if it's in a functon, it is a simple copy and paste from one project to the next.

I'm certain that someone with the skills could write a plugin or dll to accomplish this also...but why...?

The above example should set any object on a page visible (you will have to include the "elseif logic" for the remainder of the AMS objects of course. You could easily convert the coding to a table structure as well.

SetVisible("AnyObject")

You could create similar function for "SetInvisible", "SetEnabled", etc.

hth
I'm confused as to why you do this:

Code:
""..MyObject
and not just

Code:
MyObject
does this automatically turn the variable into a string? If it does, you may as well have done this instead of making Lua turn the variable into a string 5 times.

Code:
function SetVisible(MyObject)
  TheObj=Page.GetObjectType (MyObject)
  MyObject = tostring(MyObject);
  if TheObj == 0 then Button.SetVisible(MyObject, true)
  elseif TheObj == 1 then Label.SetVisible(MyObject, true)
  elseif TheObj == 2 then Paragraphl.SetVisible(MyObject, true)
  elseif TheObj == 3 then Image.SetVisible(MyObject, true)
--etc for the rest of the objects
  end 
end -- function
Reply With Quote
  #8  
Old 1 Week Ago
holtgrewe holtgrewe is offline
Indigo Rose Customer
 
Join Date: Jul 2002
Location: Just South of Reality
Posts: 732
Quote:
Originally Posted by Sakuya View Post
does this automatically turn the variable into a string? If it does, you may as well have done this instead of making Lua turn the variable into a string 5 times.
Thanks for pointing that out. It's so great having a code monitor looking over our shoulder to point out our coding flaws...LOL
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -6. The time now is 02:11 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software