ScriptForge.Session zerbitzua

Session zerbitzuak xede orokorreko zenbait metodo biltzen ditu, honakoei lotutakoak:

Zerbitzuari deitzea


     GlobalScope.BasicLibraries.loadLibrary("ScriptForge")
     Dim session As Variant
     session = CreateScriptService("Session")
    
note

Zerbitzu hau erabat onartuta dago bai Basic bai Python lengoaietan. Adibide guztiak Basic programazio-lengoaian eman dira, baina erraz bihurtu daitezke Python lengoaiara.


Konstanteak

Below is a list of constants available to ease the designation of the library containing a Basic or Python script to invoke.
Use them as session.CONSTANT.

CONSTANT

Balioa

Non dago liburutegia?

Aplikagarria

SCRIPTISEMBEDDED

"document"

dokumentuan

Basic + Python

SCRIPTISAPPLICATION

"application"

partekatutako edozein liburutegitan

Basic

SCRIPTISPERSONAL

"user"

Nire makroetan

Python

SCRIPTISPERSOXT

"user:uno_packages"

uneko erabiltzailearentzako instalatutako hedapen batean

Python

SCRIPTISSHARED

"share"

LibreOffice makroetan

Python

SCRIPTISSHAROXT

"share:uno_packages"

erabiltzaile guztientzat instalatutako hedapen batean

Python

SCRIPTISOXT

"uno_packages"

instalazio-parametro ezezagunak dituen hedapen batean

Python


Session zerbitzuaren metodoen zerrenda

ExecuteBasicScript
ExecuteCalcFunction
ExecutePythonScript
HasUnoMethod

HasUnoProperty
OpenURLInBrowser
RunApplication
SendMail

UnoMethods
UnoProperties
UnoObjectType
WebService


tip

Session service methods behave as follows:
Arguments are passed by value. Updates performed by the called function are not sent back to the calling script.
A single value or an array of values is returned to the calling script.


ExecuteBasicScript

Exekutatu Basic scripta izena eta kokalekua emanda, eta atzitu emaitza, halakorik badago.

Scripta aurkitzen ez bada edo ezer ez bada itzultzen, itzulitako balioa Empty izango da.

Sintaxia:


      session.ExecuteBasicScript([Scope As String], Script As String[, arg0 As Variant, ...]) As Variant
   

Parametroak:

Scope: "document" or "application" or one of the applicable session.CONSTANTS.

Script: "library.module.method" as a case-sensitive string.
The library is loaded in memory if necessary.
The module must not be a class module.
The method may be a Sub or a Function.

arg0, ...: The arguments to provide to the called script.

Adibidea:


      session.ExecuteBasicScript(, "XrayTool._Main.Xray", CreateUnoService("com.sun.star.util.TextSearch"))
      ' Xray returns no value
   

ExecuteCalcFunction

Execute a Calc function using its English name and based on the given arguments.
If the arguments are arrays, the function is executed as an array formula.

Sintaxia:


      session.ExecuteCalcFunction(CalcFunction As String, arg0, ...) As Variant
   

Parametroak:

CalcFunction: Exekutatuko den funtzioaren ingelesezko izena.

arg0, ...: The arguments to provide to the called Calc function. Each argument must be either a string, a numeric value or an array of arrays combining those types.

Adibidea:


      session.ExecuteCalcFunction("AVERAGE", 1, 5, 3, 7) ' 4
      session.ExecuteCalcFunction("ABS", Array(Array(-1,2,3),Array(4,-5,6),Array(7,8,-9)))(2)(2) ' 9
      session.ExecuteCalcFunction("LN", -3)
      ' Errore bat sortzen du.
   

ExecutePythonScript

Execute the Python script given its location and name, fetch its result if any. Result can be a single value or an array of values.

Scripta aurkitzen ez bada edo ezer ez bada itzultzen, itzulitako balioa Empty izango da.

LibreOffice Application Programming Interface (API) scriptgintzako lan-markoak lengoaien arteko scripten exekuzioa onartzen du Python eta Basic lengoaien kasuan, baina baita onartutako beste edozein programazio-lengoaiaren kasuan ere. Argumentuak atzera eta aurrera pasatu daitezke deietan, bi lengoaiek ezagutzen dituzten jatorrizko datu motak ordezkatzen badituzte, eta scriptgintzako lan-markoak haiek modu egokian bihurtuko dituztela onartuta.

Sintaxia:


      session.ExecutePythonScript([Scope] As String, Script As String[, arg0 As Variant, ...]) As Variant
   

Parametroak:

Scope: One of the applicable session.CONSTANTS. Default = session.SCRIPTISSHARED.

Script: Either "library/module.py$method" or "module.py$method" or "myExtension.oxt|myScript|module.py$method" as a case-sensitive string.

arg0, ...: The arguments to provide to the called script.

Adibidea:


      session.ExecutePythonScript(session.SCRIPTISSHARED, "Capitalise.py$getNewString", "Abc") ' "abc"
   

HasUnoMethod

Returns True if an UNO object contains the given method. Returns False when the method is not found or when an argument is invalid.

Sintaxia:


      session.HasUnoMethod(UnoObject As Object, MethodName As String) As Boolean
   

Parametroak:

UnoObject: The object to inspect.

MethodName: the method as a case-sensitive string

Adibidea:


      Dim a As Variant
      a = CreateUnoService("com.sun.star.sheet.FunctionAccess")
      MsgBox session.HasUnoMethod(a, "callFunction")
   

HasUnoProperty

Returns True if a UNO object has the given property. Returns False when the property is not found or when an argument is invalid.

Sintaxia:


      session.HasUnoProperty(UnoObject As Object, PropertyName As String) As Boolean
   

Parametroak:

UnoObject: The object to inspect.

PropertyName: the property as a case-sensitive string

Adibidea:


      Dim svc As Variant
      svc = CreateUnoService("com.sun.star.sheet.FunctionAccess")
      MsgBox session.HasUnoProperty(svc, "Wildcards")
   

OpenURLInBrowser

Open a Uniform Resource Locator (URL) in the default browser.

Sintaxia:


      session.OpenURLInBrowser(URL As String)
   

Parametroak:

URL: The URL to open.

Adibidea:


      session.OpenURLInBrowser("https://docs.python.org/3/library/webbrowser.html")
   

RunApplication

Executes an arbitrary system command and returns True if it was launched successfully.

Sintaxia:


      session.RunApplication(Command As String, Parameters As String) As Boolean
   

Parametroak:

Command: The command to execute. This may be an executable file or a document which is registered with an application so that the system knows what application to launch for that document. The command must be expressed in the current SF_FileSystem.FileNaming notation.

Parameters: A list of space separated parameters as a single string. The method does not validate the given parameters, but only passes them to the specified command.

Adibidea:


      session.RunApplication("Notepad.exe")
      session.RunApplication("C:\myFolder\myDocument.odt")
      session.RunApplication("kate", "/home/me/install.txt") ' GNU/Linux
   

SendMail

Send a message - with optional attachments - to recipients from the user's mail client. The message may be edited by the user before sending or, alternatively, be sent immediately.

Sintaxia:


      session.SendMail(Recipient As String, [Cc As String], [Bcc As String], [Subject As String], [Body As String], [FileNames As String], [EditMessage As Boolean])
   

Parametroak:

Recipient: An email address (the "To" recipient).

Cc: A comma-separated list of email addresses (the "carbon copy" recipients).

Bcc: A comma-separated list of email addresses (the "blind carbon copy" recipients).

Subject: the header of the message.

Body: The content of the message as an unformatted text.

FileNames: a comma-separated list of file names. Each file name must respect the SF_FileSystem.FileNaming notation.

EditMessage: When True (default), the message is edited before being sent.

Adibidea:


      session.SendMail("a@example.com" _
          , Cc := "b@other.fr, c@other.be" _
          , FileNames := "C:\myFile1.txt, C:\myFile2.txt" _
          )
   

UnoMethods

Returns a list of the methods callable from an UNO object. The list is a zero-based array of strings and may be empty.

Sintaxia:


      session.UnoMethods(UnoObject As Object) As Variant
   

Parametroak:

UnoObject: The object to inspect.

Adibidea:


      Dim a As Variant
      a = CreateUnoService("com.sun.star.sheet.FunctionAccess")
      MsgBox SF_Array.Contains(session.UnoMethods(a), "callFunction")
   

UnoProperties

Returns a list of the properties of an UNO object. The list is a zero-based array of strings and may be empty.

Sintaxia:


      session.UnoProperties(UnoObject As Object) As Variant
   

Parametroak:

UnoObject: The object to inspect.

Adibidea:


      Dim svc As Variant
      svc = CreateUnoService("com.sun.star.sheet.FunctionAccess")
      MsgBox SF_Array.Contains(session.UnoProperties(svc), "Wildcards")
   

UnoObjectType

Identify the type of a UNO object as a string.

Sintaxia:


      session.UnoObjectType(UnoObject As Object) As String
   

Parametroak:

UnoObject: The object to identify.

Adibidea:


      Dim svc As Variant, txt As String
      svc = CreateUnoService("com.sun.star.system.SystemShellExecute")
      txt = session.UnoObjectType(svc) ' "com.sun.star.comp.system.SystemShellExecute"
      svc = CreateUnoStruct("com.sun.star.beans.Property")
      txt = session.UnoObjectType(svc) ' "com.sun.star.beans.Property"
   

WebService

Get some web content from a URI.

Sintaxia:


      session.WebService(URI As String) As String
   

Parametroak:

URI: URI text of the web service.

Adibidea:


      session.WebService("wiki.documentfoundation.org/api.php?" _
          & "hidebots=1&days=7&limit=50&action=feedrecentchanges&feedformat=rss")
   
warning

Aurrizki gisa azpimarra bat ("_") duten ScriptForge Basic errutina edo identifikatzaile guztiak barneko erabilerarako erreserbatuta daude. Ez daude Basic makroetan erabiltzeko pentsatuta.