Working with Modules
iRidiumScript has strict rules for creation of modules:
1) All initialization has to be performed in the block IR.AddListener(IR.EVENT_START,0,function(){body});
IR.AddListener(IR.EVENT_START, 0, function() //Actions are performed at starting the project { var popup = IR.GetPopup("Browser") //Activate the popup var button = popup.GetItem("UpFolder"); //Activate the button // Create an UPNP device upnpControl = IR.CreateDevice(IR.DEVICE_UPNP_CONTROL, "UpnpControl"); //Activate the creation of the device upnpControl.Connect(); //Activate the connection of the device IR.AddListener(IR.EVENT_ITEM_PRESS, playButton, function() //Activate actions on pressings { if(playButton.Value == 0) player.InvokeAction("Play", "urn:schemas-upnp-org:service:AVTransport:1", {InstanceID: 0, Speed: 1} ); else player.InvokeAction("Pause", "urn:schemas-upnp-org:service:AVTransport:1", {InstanceID: 0} ); });
2) Modules are loaded in order, i.е. it is incorrect if you perform actions with the variable in the upper module and its activation is performed in the lower module. BE CAREFUL!
3) iRidiumScript is devided into modules for the convenience of users. When uploading all modules unite in one area, i.e. if you activate variales with the same name in different modules or create different functions with one name in different modules then when uploading these variables and functions unite in one area and the variable/function to be used is the one which is uploaded last (from the lower module).