FabyaVisionUser Manual
/

Script examples

5 min readScripts

A topic map of the sample code gallery, an annotated listing of the scripts in the Tanitim_Tesisi project, and the same task written in four languages.

Sample sources

Samples are available from two places: the Sample code gallery of Studio and the ready-made scripts in the Tanitim_Tesisi sample project. The gallery samples are tested by actually running them in Live; each sample must give the expected result with its own scenario.

Gallery: topic map

Open the gallery with Sample code… in the toolbar of the Sample code… table (usage: Script editor). The number of examples by language and topic is as follows:

Topic groupVBSJavaScriptCPython
Tag read / write4146
Condition and loop5445
Calculation and scaling3344
Date, time, waiting3234
Report record1001
Screen and objects4146
Operator interaction2234
Database, file, program4037
Script structure and diagnostics4477
Python language and library———7
Total30173251

Sample names are prefixed according to the language: JavaScript samples start with Js_…, C samples with C_…, Python samples with Py_…; VBS samples have no prefix (Tag_Oku_Yaz, Onay_Alarak_Yaz, Veritabani_Sorgu …). The gallery search box searches the name, description and code.

Scripts in Tanitim_Tesisi

The sample project binds all the scripts through Scheduled tasks. Open the Scripts and Scheduled tasks sections together to see which task runs each script.

The scheduled tasks to which scripts are bound in Tanitim_Tesisi: the trigger and script-to-run columns.12
The scheduled tasks to which scripts are bound in Tanitim_Tesisi: the trigger and script-to-run columns.
  1. Trigger — cyclic, on tag change, timed …
  2. Script to run — the script the task runs.
ScriptLanguage / typeFrom which taskWhat it does
Pompa_Ariza_EsleJavaScript, Function (deger)Pompa_Ariza_Esle: when the P103_Calisiyor tag changesSets the P103_Ariza bit when P-103 stops and clears it when it runs.
Tank_Seviye_DenetimiVBS, ModuleTank_Seviye_Denetimi: cyclic, 1 sSets the T101_Uyari bit when T101_Seviye drops below 40 or rises above 88.
Aroma_Dozaj_DenetimiC, Project functionsAroma_Dozaj_Denetimi: cyclic, 5 sSets the Aroma_Dusuk bit when Aroma_Seviye drops below 42.
Birim_Enerji_HesaplaVBS, ModuleBirim_Enerji_Hesapla: cyclic, 5 sCalculates the specific energy (kWh / 1000 bottles) from the panel power and the line speed.
Vardiya_BelirleJavaScript, FunctionVardiya_Belirle: cyclic, 10 sDetermines the active shift according to the time of day (06 – 14 first, 14 – 22 second, 22 – 06 third).
Parti_IlerletJavaScript, Function (deger)Parti_Numarasi_Ilerlet: when the Parti_Bitti tag changesWhen the batch ends, increments the batch number by one and updates the shift batch counter.
Vardiya_BaslatJavaScript, FunctionVardiya_Baslangici (weekly, 06:00), Gunluk_Parti_Sayaci_Sifirla (every day 00:00), Kapanis_Kaydi (when Live shuts down)Resets the shift batch counter. A script can be bound to more than one task.
Acilis_HazirlikJavaScript, FunctionCalisma_Acilis (when Live starts)Prepares the shift batch counter.
Bakim_HatirlatJavaScript, FunctionWeekly, monthly and yearly reminder tasksWrites the maintenance note to the Bakim_Notu tag.
Filtre_Uyarisi, Kabin_Sicaklik_UyarisiJavaScript, FunctionTag-conditional tasks: KS1_Filtre_Fark > 230, Firin_Sicaklik > 93Clears the relevant warning bit.

Writing one task in four languages

The following four scripts do the same task: when the tag P103_Calisiyor changes, they write the inverse value to the bit P103_Ariza. All of them run in a task triggered by On tag change; the new value of the tag arrives as the first parameter of the script.

VBS (Module; a Bool value arrives as the binary value 1 / 0):

Sub Pompa_Ariza_Esle(deger)
    SmartTags("P103_Ariza") = Not deger
End Sub

JavaScript (Function; Parameters column deger):

Tag.yaz('P103_Ariza', !deger);

C (Project functions):

#include "apdefap.h"

void Pompa_Ariza_Esle(int deger)
{
    SetTagBit("P103_Ariza", (short)!deger);
}

Python (Module):

def Pompa_Ariza_Esle(deger):
    scada.write("P103_Ariza", not deger)

Steps for binding the sample

  1. Add the example

    Select the example from the gallery and click Add to project. The script is added to the Scripts table.

  2. Compile

    F9: the syntax and the tag, screen, and object names in the project are checked. Resolve the warnings or change the code to use your own names.

  3. Trigger it

    Following the sample's How to bind it text, add a task in Scheduled tasks (cyclic, On tag change, timed …) or select the Run script function in the event of an object. For a VBS module, a C project function and a Python module, select Procedure / function if needed.

  4. Test

    Open it in Live with Start Live. If the script produces an error, a betik line appears in the event log (Log files).

Limitations and points to note

  • For the database, file and program examples to work, Script permissions must be enabled. The gallery asks when you add an example that requires a permission; it does not enable the permission by itself.
  • The DSN names, file paths and report names in the samples are for illustration only (Uretim_VT, C:\Veri, Uretim_Raporu); change them to suit your own environment.
  • The database, file and program execution examples have been tested with a test bridge, not with a real database and file system; at the first trial in the field, with the permission enabled, try them in your own environment.

Related topics

FabyaVision 0.1.0 User Manual · 18 October 2026© Fabyatek Yazılım Bilişim Teknolojileri Ltd. Şti.