summaryrefslogtreecommitdiffstats
path: root/helpcontent2/source/text/sbasic/shared/03/sf_platform.xhp
blob: c9283925b6d0e23533565e7e8c6300d83bea8e6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<?xml version="1.0" encoding="UTF-8"?>
<helpdocument version="1.0">
<!--
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
-->
<meta>
  <topic id="SF_Platform" indexer="include" status="PUBLISH">
    <title id="tit" xml-lang="en-US">ScriptForge.Platform service</title>
    <filename>/text/sbasic/shared/03/sf_platform.xhp</filename>
  </topic>
  </meta>
<body>
<section id="ScriptForge-sf_platform">
    <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id501600788076381">
        <bookmark_value>Platform service</bookmark_value>
    </bookmark>
</section>
<section id="abstract">
    <h1 id="bm_id681600788076499"><variable id="PlatformService"><link href="text/sbasic/shared/03/sf_platform.xhp" name="Platform service"><literal>ScriptForge</literal>.<literal>Platform</literal> service</link></variable></h1>
  <paragraph role="paragraph" id="par_id181600788076612">The <literal>Platform</literal> service provides a collection of properties about the current execution environment and context, such as:</paragraph>
  <list type="unordered">
      <listitem>
          <paragraph id="par_id301600788076785" role="listitem">The hardware platform (architecture, CPU count, machine type, etc)</paragraph>
      </listitem>
      <listitem>
          <paragraph id="par_id1001600788076848" role="listitem">Operating system information (OS type, release, version, etc)</paragraph>
      </listitem>
      <listitem>
          <paragraph id="par_id67160078807676" role="listitem">The %PRODUCTNAME version</paragraph>
      </listitem>
      <listitem>
          <paragraph id="par_id671600788076855" role="listitem">The current user name</paragraph>
      </listitem>
  </list>
</section>
  <note id="par_id951614903258253">All properties of the <literal>Platform</literal> service are read-only.</note>
    <h2 id="hd_id281600788076359">Service invocation</h2>
    <paragraph role="paragraph" id="par_id141609955500101">Before using the <literal>Platform</literal> service the <literal>ScriptForge</literal> library needs to be loaded or imported:</paragraph>
    <embed href="text/sbasic/shared/03/lib_ScriptForge.xhp#importLibs"/>

    <paragraph role="paragraph" id="par_id321614902851541">The examples below in Basic and Python instantiate the <literal>Platform</literal> service and access the <literal>Architecture</literal> property.</paragraph>
    <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
    <bascode>
      <paragraph role="bascode" localize="false" id="bas_id851600788076202">GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id1001600788076254">Dim platform As Variant</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id721600788076288">platform = CreateScriptService("Platform")</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id791600788431935">MsgBox platform.Architecture</paragraph>
    </bascode>
    <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
    <pycode>
      <paragraph role="pycode" localize="false" id="pyc_id631626695710139">from scriptforge import CreateScriptService</paragraph>
      <paragraph role="pycode" localize="false" id="pyc_id981626695710433">svc = CreateScriptService("Platform")</paragraph>
      <paragraph role="pycode" localize="false" id="pyc_id311626695710851">bas = CreateScriptService("Basic")</paragraph>
      <paragraph role="pycode" localize="false" id="pyc_id391626695711082">bas.MsgBox(svc.Architecture)</paragraph>
    </pycode>
    <bookmark xml-lang="en-US" branch="index" localize="false" id="bm_id111614901524769">
      <bookmark_value>Platform service;Architecture</bookmark_value>
      <bookmark_value>Platform service;ComputerName</bookmark_value>
      <bookmark_value>Platform service;CPUCount</bookmark_value>
      <bookmark_value>Platform service;CurrentUser</bookmark_value>
      <bookmark_value>Platform service;Extensions</bookmark_value>
      <bookmark_value>Platform service;Fonts</bookmark_value>
      <bookmark_value>Platform service;FormatLocale</bookmark_value>
      <bookmark_value>Platform service;Locale</bookmark_value>
      <bookmark_value>Platform service;Machine</bookmark_value>
      <bookmark_value>Platform service;OfficeLocale</bookmark_value>
      <bookmark_value>Platform service;OfficeVersion</bookmark_value>
      <bookmark_value>Platform service;OSName</bookmark_value>
      <bookmark_value>Platform service;OSPlatform</bookmark_value>
      <bookmark_value>Platform service;OSRelease</bookmark_value>
      <bookmark_value>Platform service;OSVersion</bookmark_value>
      <bookmark_value>Platform service;Printers</bookmark_value>
      <bookmark_value>Platform service;Processor</bookmark_value>
      <bookmark_value>Platform service;PythonVersion</bookmark_value>
      <bookmark_value>Platform service;SystemLocale</bookmark_value>
    </bookmark>
    <h2 id="hd_id711600788076834">Properties</h2>
    <table id="tab_id701600788076583">
        <tablerow>
            <tablecell>
                <paragraph id="par_id461600788076917" role="tablehead">Name</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id221600788076591" role="tablehead">Readonly</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id761600788076328" role="tablehead">Type</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id67160078807636" role="tablehead">Description</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id491600788076621" role="tablecontent" localize="false">Architecture</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id311600788076756" role="tablecontent">Yes</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id831600788076785" role="tablecontent" localize="false">String</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id441600788076826" role="tablecontent">The hardware bit architecture. Example: '<literal>32bit</literal>' or '<literal>64bit</literal>'</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id941600788076595" role="tablecontent" localize="false">ComputerName</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id49160078807654" role="tablecontent">Yes</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id961600788076376" role="tablecontent" localize="false">String</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id81600788076419" role="tablecontent">The computer's network name.</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id721600788076638" role="tablecontent" localize="false">CPUCount</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id711600788076534" role="tablecontent">Yes</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id911600788076842" role="tablecontent" localize="false">Integer</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id541600788076645" role="tablecontent">The number of central processing units.</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id961600788076890" role="tablecontent" localize="false">CurrentUser</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id891600788076190" role="tablecontent">Yes</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id761600788076562" role="tablecontent" localize="false">String</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id91600788076674" role="tablecontent">The name of the currently logged user.</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
               <paragraph id="par_id831633021719246" localize="false" role="tablecontent">Extensions</paragraph>
            </tablecell>
           <tablecell>
               <paragraph id="par_id561633021747014" role="tablecontent">Yes</paragraph>
           </tablecell>
           <tablecell>
               <paragraph id="par_id201633021748566" role="tablecontent">String array</paragraph>
           </tablecell>
           <tablecell>
               <paragraph id="par_id831633021749125" role="tablecontent">Returns a zero-based array of strings containing the internal IDs of all installed extensions.</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id831633021716585" localize="false" role="tablecontent">FilterNames</paragraph>
            </tablecell>
           <tablecell>
               <paragraph id="par_id561633021747209" role="tablecontent">Yes</paragraph>
           </tablecell>
           <tablecell>
               <paragraph id="par_id201633021748322" role="tablecontent">String array</paragraph>
           </tablecell>
           <tablecell>
               <paragraph id="par_id831633021749118" role="tablecontent">Returns a zero-based unsorted array of strings containing the available document import and export filter names.</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id831633021719135" localize="false" role="tablecontent">Fonts</paragraph>
            </tablecell>
           <tablecell>
               <paragraph id="par_id561633021747903" role="tablecontent">Yes</paragraph>
           </tablecell>
           <tablecell>
               <paragraph id="par_id201633021748455" role="tablecontent">String array</paragraph>
           </tablecell>
           <tablecell>
               <paragraph id="par_id831633021749007" role="tablecontent">Returns a zero-based array of strings containing the names of all available fonts.</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
               <paragraph id="par_id831633021710186" localize="false" role="tablecontent">FormatLocale</paragraph>
            </tablecell>
           <tablecell>
               <paragraph id="par_id561633021748013" role="tablecontent">Yes</paragraph>
           </tablecell>
           <tablecell>
               <paragraph id="par_id201633021749655" localize="false" role="tablecontent">String</paragraph>
           </tablecell>
           <tablecell>
               <paragraph id="par_id831633021749297" role="tablecontent">Returns the locale used for numbers and dates as a string in the format "la-CO" (language-COUNTRY).</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id831633021719022" localize="false" role="tablecontent">Locale</paragraph>
            </tablecell>
           <tablecell>
               <paragraph id="par_id561633021743188" role="tablecontent">Yes</paragraph>
           </tablecell>
           <tablecell>
               <paragraph id="par_id201633021743058" localize="false" role="tablecontent">String</paragraph>
           </tablecell>
           <tablecell>
               <paragraph id="par_id831633021749018" role="tablecontent">Returns the locale of the operating system as a string in the format "la-CO" (language-COUNTRY). This is equivalent to the <literal>SystemLocale</literal> property.</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id951600788076443" role="tablecontent" localize="false">Machine</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id391600788076253" role="tablecontent">Yes</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id381600788076799" role="tablecontent" localize="false">String</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id21600788076541" role="tablecontent">The machine type. Examples are: '<literal>i386</literal>' or '<literal>x86_64</literal>'.</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
               <paragraph id="par_id831633021710156" localize="false" role="tablecontent">OfficeLocale</paragraph>
            </tablecell>
           <tablecell>
               <paragraph id="par_id561633021706513" role="tablecontent">Yes</paragraph>
           </tablecell>
           <tablecell>
               <paragraph id="par_id201633021746335" localize="false" role="tablecontent">String</paragraph>
           </tablecell>
           <tablecell>
               <paragraph id="par_id831633021741117" role="tablecontent">Returns the locale of the user interface as a string in the format "la-CO" (language-COUNTRY).</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id41600788076936" role="tablecontent" localize="false">OfficeVersion</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id211600788076138" role="tablecontent">Yes</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id221600788076518" role="tablecontent" localize="false">String</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id521600788076371" role="tablecontent">The actual %PRODUCTNAME version expressed as<br />' <literal>%PRODUCTNAME w.x.y.z (The Document Foundation)</literal>'.</paragraph>
                <paragraph role="paragraph" id="par_id621614902220807">Example: '<literal>LibreOffice 7.4.1.2 (The Document Foundation, Debian and Ubuntu)</literal>'</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id161600788076362" role="tablecontent" localize="false">OSName</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id21600788076758" role="tablecontent">Yes</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id871600788076196" role="tablecontent" localize="false">String</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id781600788076694" role="tablecontent">The operating system type. Example: '<literal>Darwin</literal>, <literal>Linux</literal>' or '<literal>Windows</literal>'.</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id471600788076885" role="tablecontent" localize="false">OSPlatform</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id261600788076841" role="tablecontent">Yes</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id661600788076636" role="tablecontent" localize="false">String</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id11600788076757" role="tablecontent">A single string identifying the underlying platform with as much useful and human-readable information as possible.</paragraph>
                <paragraph role="paragraph" id="par_id501614902381381">Example: '<literal>Linux-5.8.0-44-generic-x86_64-with-glibc2.32</literal>'</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id221600789141781" role="tablecontent" localize="false">OSRelease</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id531600789141795" role="tablecontent">Yes</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id561600789141282" role="tablecontent" localize="false">String</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id301600789141619" role="tablecontent">The operating system's release. Example: '<literal>5.8.0-44-generic</literal>'</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id821600789286339" role="tablecontent" localize="false">OSVersion</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id541600789286532" role="tablecontent">Yes</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id181600789286889" role="tablecontent" localize="false">String</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id701600789286280" role="tablecontent">The operating system's build or version.</paragraph>
                <paragraph role="paragraph" id="par_id351614902520555">Example: '<literal>#50-Ubuntu SMP Tue Feb 9 06:29:41 UTC 2021</literal>'</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id31600789752717" role="tablecontent" localize="false">Printers</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id941608709527698" role="tablecontent">Yes</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id100100678952791" role="tablecontent" localize="false">String<br/>array</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id661300789527859" role="tablecontent">The list of available printers as a zero-based array.</paragraph>
                <paragraph role="paragraph" id="par_id111614952098396">The default printer is put in the first position of the list (index = 0).</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id31600789527717" role="tablecontent" localize="false">Processor</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id941600789527698" role="tablecontent">Yes</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id100160078952791" role="tablecontent" localize="false">String</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id631600789527859" role="tablecontent">The real processor name. Example: '<literal>amdk6</literal>'.</paragraph>
                <paragraph role="paragraph" id="par_id111614902598396">This property may return the same value as the <literal>Machine</literal> property.</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
                <paragraph id="par_id31600789752228" role="tablecontent" localize="false">PythonVersion</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id941608709527036" role="tablecontent">Yes</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id100100678952208" role="tablecontent" localize="false">String</paragraph>
            </tablecell>
            <tablecell>
                <paragraph id="par_id661300789527994" role="tablecontent">Returns the version of the Python interpreter being used as a string in the format "Python major.minor.patchlevel" (ex: "Python 3.9.7").</paragraph>
            </tablecell>
        </tablerow>
        <tablerow>
            <tablecell>
               <paragraph id="par_id83163302112358" localize="false" role="tablecontent">SystemLocale</paragraph>
            </tablecell>
           <tablecell>
               <paragraph id="par_id561633021708547" role="tablecontent">Yes</paragraph>
           </tablecell>
           <tablecell>
               <paragraph id="par_id201633021746229" localize="false" role="tablecontent">String</paragraph>
           </tablecell>
           <tablecell>
               <paragraph id="par_id831633021741336" role="tablecontent">Returns the locale of the operating system as a string in the format "la-CO" (language-COUNTRY). This is equivalent to the <literal>Locale</literal> property.</paragraph>
            </tablecell>
        </tablerow>
    </table>
    <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
    <paragraph role="paragraph" id="par_id311633022159446">The following examples in Basic and Python illustrate how to use the <literal>Fonts</literal> property to write the names of all available fonts to the current Calc sheet starting at cell "A1":</paragraph>
    <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
    <bascode>
      <paragraph role="bascode" localize="false" id="bas_id671633022413022">Dim oDoc as Object</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id721633022413266">Dim allFonts as Object</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id691633022413526">Dim svcPlatform as Object</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id41633022413831">Set oDoc = CreateScriptService("Calc")</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id541633022414069">Set svcPlatform = CreateScriptService("Platform")</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id641633022414366">allFonts = svcPlatform.Fonts</paragraph>
      <paragraph role="bascode" localize="false" id="bas_id651633022414637">oDoc.setArray("~.A1", allFonts)</paragraph>
    </bascode>
    <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
    <pycode>
      <paragraph role="pycode" localize="false" id="pyc_id701633022704347">from scriptforge import CreateScriptService</paragraph>
      <paragraph role="pycode" localize="false" id="pyc_id841633022704586">svc_platform = CreateScriptService("Platform")</paragraph>
      <paragraph role="pycode" localize="false" id="pyc_id281633022704771">doc = CreateScriptService("Calc")</paragraph>
      <paragraph role="pycode" localize="false" id="pyc_id211633022704988">all_fonts = svc_platform.Fonts</paragraph>
      <paragraph role="pycode" localize="false" id="pyc_id941633022705212">doc.setArray("~.A1", all_fonts)</paragraph>
    </pycode>
    <embed href="text/sbasic/shared/03/lib_ScriptForge.xhp#SF_InternalUse"/>
    <section id="relatedtopics">
      <embed href="text/sbasic/python/python_platform.xhp#pythonplatform"/>
      <paragraph role="paragraph" id="par_id301613065794148"><link href="text/scalc/01/04060104.xhp#bm_id3691824" name="Calc_Info">Platform information with INFO("system") Calc formula</link></paragraph>
      <embed href="text/sbasic/shared/03132100.xhp#getguitype2"/>
      <embed href="text/sbasic/shared/03/lib_tools.xhp#tools_lib"/>
    </section>
</body>
</helpdocument>