Dear,
It's very first time for me to use iX Developer Script and it really confusing me where to put delegate declare. In my opinion, iX Developer divide every object into many class, and user just add small script into every event handler. So I couldn't found Main program in iX Developer.
Thanks,
Mike
Where to put delegate in Script?
-
- Posts: 1
- Joined: Tue Mar 13, 2012 5:52 am
Re: Where to put delegate in Script?
Each screen or script module is contained in a separate class, in which you can declare your own delegates or variables (this is also where the screen event handlers are put). Main program is not within reach for the end user. It could be found in your project folder to be opened with a text editor, but every change you may do to this file is overwritten on next project verification.
Re: Where to put delegate in Script?
Mike,
If you are looking to write a script that will span many screens, have a look at creating it as a script module. But as Henrik said, you don't have access to the main program.
If you are looking to write a script that will span many screens, have a look at creating it as a script module. But as Henrik said, you don't have access to the main program.
Best Regards,
Beijer Electronics, Inc.
Skylar Walker | Applications Engineer
Beijer Electronics, Inc.
Skylar Walker | Applications Engineer
-
- Posts: 4
- Joined: Tue Mar 13, 2012 3:49 am
Re: Where to put delegate in Script?
Thanks Henrik and Skylar,
Actually, I want to create Timer in module script and this timer will be the tick to scan all event in program, and in Timer Event Handler, I will call function of each seperate screen. So, I don't know whether it's feasible to do that without delegate.
Mike
Actually, I want to create Timer in module script and this timer will be the tick to scan all event in program, and in Timer Event Handler, I will call function of each seperate screen. So, I don't know whether it's feasible to do that without delegate.
Mike
Re: Where to put delegate in Script?
Mike,
What exactly are you trying to accomplish with this? Perhaps I could suggest a different solution. The issue you are going to have with updating screens from a module is that screens which aren't displayed don't exist for all intents and purposes. Each time a screen is displayed, a new instance of that screen is created. If you want to manipulate data across all screens, you will want to use tags to store your variables.
What exactly are you trying to accomplish with this? Perhaps I could suggest a different solution. The issue you are going to have with updating screens from a module is that screens which aren't displayed don't exist for all intents and purposes. Each time a screen is displayed, a new instance of that screen is created. If you want to manipulate data across all screens, you will want to use tags to store your variables.
Best Regards,
Beijer Electronics, Inc.
Skylar Walker | Applications Engineer
Beijer Electronics, Inc.
Skylar Walker | Applications Engineer
-
- Posts: 4
- Joined: Tue Mar 13, 2012 3:49 am
Re: Where to put delegate in Script?
Skylar,
Just for the sake of argument, every screen requires a timer with same interval, but each screen has a different task. And, I declare a delegate:
That Timer would run through the process. Therefore, I create TimerProcess script module:
This would point to any method/function by every Screen Opened event:
That’s what I thought currently. Is it possible to do it?
Just for the sake of argument, every screen requires a timer with same interval, but each screen has a different task. And, I declare a delegate:
Code: Select all
public delegate void TimerHandle();
Code: Select all
public partial class TimerProcess
{
private static Timer timer;
private static int temp;
static TimerProcess()
{
timer = new Timer();
timer.Interval = 500;
timer.Tick += new EventHandler(TimerProcessHandler);
}
public void Start()
{
timer.Enabled = true;
}
public void Stop()
{
timer.Enabled = false;
}
public void Method1()
{
//task for Screen1 in here
}
private static void TimerProcessHandler(Object send, EventArgs e)
{
//handle each screen task in here
}
}
Code: Select all
void Screen1(System.Object sender, System.EventArgs e)
{
TimerHandle = Globals.TimerProcess.Method1();
}
Re: Where to put delegate in Script?
Mike,
I'm not completely clear on what you are trying to accomplish from the pseudo code that you sent. Have you seen this excellent example of how to use timers?
http://ixtalk.beijerelectronics.com/vie ... hp?f=9&t=5
I'm not completely clear on what you are trying to accomplish from the pseudo code that you sent. Have you seen this excellent example of how to use timers?
http://ixtalk.beijerelectronics.com/vie ... hp?f=9&t=5
Best Regards,
Beijer Electronics, Inc.
Skylar Walker | Applications Engineer
Beijer Electronics, Inc.
Skylar Walker | Applications Engineer
Re: Where to put delegate in Script?
It sounds like you want to add a delegate function to an event when a screen is opened and remove the handler when the screen is closed. You may want to review the C# documentation on using events and delegates here:
http://msdn.microsoft.com/en-us/library ... s.71).aspx
I've also attached an example where I had to do something similar.
http://msdn.microsoft.com/en-us/library ... s.71).aspx
I've also attached an example where I had to do something similar.
- Attachments
-
- DynamicComboBoxStrings.zip
- (34.77 KiB) Downloaded 962 times
Best Regards,
Beijer Electronics, Inc.
Ron Lloyd | Applications Engineer
Beijer Electronics, Inc.
Ron Lloyd | Applications Engineer
-
- Posts: 4
- Joined: Tue Mar 13, 2012 3:49 am
Re: Where to put delegate in Script?
Thanks Skylar and Ron for your help, I'm still working on it!
Mike
Mike