KB-28809: Setting Windows’ clock via E3 scripts
Question: How can I set Windows’ clock via E3 scripts? Solution: To do so, use DATE and TIME commands via DOS command line. It can be inserted in a script inside E3, for example, in a button’s Click event. Sub CommandButton1_Click() Set oShell = CreateObject("WSCript.shell") 'Changes date oShel ...
KB-28813: Report filter via scripts not working
Question: I have filtered the data in a report via a query’s SetVariableValue method, but when I try to export it, the filter does not work. How can I fix this? Solution: Probably, your script looked like this: dim DataIni, DataFim Set Report = Application.LoadReport("[Report1]") Report.Item(" ...
KB-12658: Reading/Writing TXT files with E3
Question: How can I read/write TXT files with E3? Solution: To do so, you must use the methods from FileSystemObject object. Examples: ** Script to create a TXT file ** Dim aux, aux1 Set aux = CreateObject("Scripting.FileSystemObject") Set aux1 = aux.CreateTextFile("C:\Temp\Test.txt", True) aux ...
KB-15838: Exporting data from E3Storage
Question: How can I export data from E3Storage to a TXT file? Solution:To do so, you must first create a report and configure the filters according to the information to be displayed. Then, use the report’s Export() method to export the data in TXT format.
KB-27932: Attributing values to multiple tags in a FOR-type script
Question: How can I attribute values to multiple tags (in sequence: InternalTag1, InternalTag2, InternalTag3) in a FOR-type script? Solution:To do so, you must concatenate the tag’s complete path, and leave only its last digit as the variable containing the number that completes tag name. Exampl ...
KB-27915: Reading data from a TXT file
Question: How can I read the data from a TXT file? Solution: To do so, you must use VBScript’s Read method. The script below runs in a button’s Click event: Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("c:\testfile.txt", 1) ReadTextFil ...
KB-15510: Changing pen's width in runtime
Question: How can I change a pen's width in runtime? Solution: To do so, you must change the pen's Width property via scripts. Example: Screen.Item("E3Chart1").Pens.Item("Pen1").Width = 20 Obs.: Attached is a sample application developed with E3 version 3.1 Build 270.
KB-15457: Pinging external devices
Question: How can I ping a device that is external to network running the application? Solution: To do so, you can use VBScripts commands. For example: dim oShell, strComputer set oShell = CreateObject("WScript.Shell") strComputer = InputBox("Type the IP address you want to ping:", "Ping") if st ...
KB-28981: Screen opened by an active alarm
Question: How can I have a screen be opened whenever there is an active alarm in the application? Solution: To do so, you must first insert an internal tag in the Viewer. Then, create an event in this object that is activated every time the alarm server's ActiveAlarms property is higher than zer ...
KB-16467: Loading a query's result into an internal tag
Question: How can I load a query's result into an internal tag? Solution: To do so, you must use query's GetADORecordset() method. In the script below, the query on the main screen is executed, and the values of "DemoTag1" to "DemoTag2" are loaded into "InternalTag1" to " InternalTag12" internal ...
KB-27081: Changing a screen’s Caption property from a button running a command to open it
Question: How can I change Screen1’s Caption property from the button running the command to open it from InitialScreen? Solution: To do so, you must pass the string to be placed in the Caption to the command to open the screen via Parameter field in Open Screen pick. In Screen1’s OnPreShow eve ...
KB-26508: Additional parameters for opening a screen
Question: How can I pass additional parameters for opening a screen via scripts? Solution: To do so, you can use Parameter field in Open Screen pick. In OnPreShow event of the screen to be opened, use Arg statement to check the parameters that have been passed. Example: MsgBox Arg.
KB-12286: Links between I/O tags and objects on the screen, in runtime
Question: How can I create links between I/O tags and objects already added to the screen, in runtime? Solution: To do so, use the object’s CreateLink method. Example: Screen.Item("Display").Links.CreateLink "Value", "Data. DemoTag1.Value"
KB-13184: Loading the names of the computers running E3 Server and E3 Viewer into a tag
Question: How can I load the name(s) of the computer(s) running E3 Server and E3 Viewer into an internal tag? Solution: To do so, you must use VBScript’s WshNetwork object. For further information, please refer to VBScript’s Reference Guide under “Computername”. Example: Add two internal tags ...
KB-17264: Playing sounds in E3
Question: How can I play sounds in E3? Solution: To do so, select a script and use Viewer's PlaySound method. Obs.: Attached is a sample application developed with E3 version 3.1 Build 270.
KB-28855: Writing multiple values at once in a block
Question: Can I write all the values in a block at once, instead of writing them individually in each element? Solution: Yes. One way to do so is to create a vector and populate it with the values to be written in the block elements. Dim vet(10) Vet(0) = 1 Vet(1) = 2 ... Vet(9)=10 Application.Ge ...
KB-18933: Passing values in date format to an SQL query
Question: How can I pass a value in date format to an SQL query? Solution: To do so, you must use Visual Basic's CDate function. For example: InitialDate = CDate(Screen.Item("InitialDateText").Value) Set Report1 = Application.LoadReport("Report1") Set Consulta = Report1.Item("Query1") Consulta.S ...
KB-13594: Retrieving RGB value from an absolute value
Question: How can I convert a rectangle’s absolute decimal value into its separate RGB values, in runtime? Solution:To do so, use this script. In the example below, the script has been added to a button: Dim AUX, AUX1, AUX2, AUX3 Dim R, G, B AUX = Screen.Item("Rectangle1").ForegroundColor B = A ...
KB-18878: Hiding/showing screen objects according to the type of user logged to the application
Question: How can I hide or show some screen objects according to the user logged to the application (for example, different visualization rights for administrators and non-administrators)? Solution: One possible solution is to create a script in Viewer's OnLogin event to pass the values an inte ...
KB-19380: Disabling the reading and writing of multiple tags
Question: How can I disable the writing and reading of all the tags in a folder inside an I/O driver? Solution: To do so, you must use Deactivate() method. Example: Application.GetObject("Driver1.Folder1").Deactivate()