.. highlightlang:: us .. _uniscript-as-a-stand-alone-program: UniScript as a Stand-Alone Program ================================== The UniScript interpreter can be used as a stand alone program with UniPlot 3.3.0. .. _usage-us-standalone: Usage ----- Open a Windows command window :file:`cmd.exe`. .. image:: S:/uniplot-obj/images/cmd.* Start UniScript. Type in the command :file:`us` and press :kbd:`Enter` to start the program :file:`us.exe` located in the :file:`c:\\Program Files\\UniPlot\\Program` directory. UniScript displays a prompt with an asterisk and is ready for input. You can use UniScript as a powerful pocket calculator. To quit UniScript, use the :kbd:`Ctrl+C` key. You can also write programs with UniScript. The following program :file:`ncdir.ice` displays the channel names of all NC files found in the given directory. Example: ``us ncdir.ice d:\*.nc``. Under Windows 2000 the function can be called like this: ``ncdir d:\*.nc`` :: // ncdir.ice def ncdir(sv) { nold = nc_seterror_options(0); for (i in 1:len(sv)) { ncid = nc_open(sv[i], NC_NOWRITE); if (ncid == -1) continue; print sv[i]; nvars = nc_inquire_nvars(ncid) if (nvars == 0) continue; for (j in 0:nvars-1) { print "\t" + nc_varinq_name(ncid, j); } nc_close(ncid); } nc_seterror_options(nold); } args = getargs(); if (len(args) >= 3) { loadlib("rs_ncdf.dll"); for (i in 1:len(args)-2) { sv = GetDirectory(args[i+2]) ncdir(sv) } } else { print "usage: ncdir filename(s)"; } .. _uniscript-as-an-activex-server: .. _uniscript-com-server: UniScript as an COM-Server ------------------------------ The program :file:`usserv32.exe` located in the :file:`c:\\Program Files\\UniPlot\\Program` directory can be used as an COM-Server. Example (VBA-Program in Excel):: Public Sub Test() Set us = CreateObject("UniScript32") MsgBox us.Call2("sin", 1) End Sub The UniScript-Server provides the following functions: :ref:`UniScript.Call`, :ref:`UniScript.Call2`, :ref:`UniScript.Load`. It can be used by UniPlot as well. .. _annotation-uniscript-stand-alone: Annotation ---------- * During the UniScript start a startup file will be loaded. The file names of the startup files are :file:`usstart.ic` for :file:`us.exe` and :file:`usserv.ic` for :file:`usserv.exe`. In the startup files DLLs, UniScript files (*.ic) and UniScript libraries (*.icl) are loaded:: loadlib("rs_lib.dll"); loadlib("rs_lib2.dll"); loadlib("rs_obj.dll"); loadlib("rs_auto.dll"); loadlib("rs_map.dll"); loadlib("rs_date.dll"); load(GetRootDirectory() + "script\alias.ic"); load(GetRootDirectory() + "script\Register.ic"); loadiclib(GetRootDirectory() + "Program\rs_sl.icl"); * Not all functions available in UniPlot can be used. All functions which access UniPlot objects (Documents, Layers, datasets etc.) are not available. * If the script files have the extension :file:`.ice`, they can be started by just typing the file name in the Windows command window. :sub:`id-1936455`