From 69073be69350efd4f9d4fffe9a05110fea8b0b5a Mon Sep 17 00:00:00 2001 From: flywire Date: Wed, 23 Mar 2022 13:03:34 +0100 Subject: Cleanup ScriptForge examples Done these cleanups on ScriptForge examples: * Consistent ScriptForge examples variable names * Fix wrong link * Add missing text * Remove extra text Change-Id: I49f7e70268c9a9c576e6fb479559bc5c222f86ca Reviewed-on: https://gerrit.libreoffice.org/c/help/+/131868 Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure --- source/text/sbasic/shared/03/sf_database.xhp | 2 +- source/text/sbasic/shared/03/sf_filesystem.xhp | 78 ++++++++++++------------- source/text/sbasic/shared/03/sf_formcontrol.xhp | 4 +- source/text/sbasic/shared/03/sf_textstream.xhp | 12 ++-- source/text/sbasic/shared/03/sf_ui.xhp | 14 ++--- 5 files changed, 55 insertions(+), 55 deletions(-) (limited to 'source/text') diff --git a/source/text/sbasic/shared/03/sf_database.xhp b/source/text/sbasic/shared/03/sf_database.xhp index dc76976d86..468f83b580 100644 --- a/source/text/sbasic/shared/03/sf_database.xhp +++ b/source/text/sbasic/shared/03/sf_database.xhp @@ -100,7 +100,7 @@ myDatabase.CloseDatabase() doc.CloseDocument() - The GetDatabase method used in the example above is part of ScriptForge's Base service. + The GetDatabase method used in the example above is part of ScriptForge's Base service. Database Service;Queries diff --git a/source/text/sbasic/shared/03/sf_filesystem.xhp b/source/text/sbasic/shared/03/sf_filesystem.xhp index a8aa44775e..9461b7604c 100644 --- a/source/text/sbasic/shared/03/sf_filesystem.xhp +++ b/source/text/sbasic/shared/03/sf_filesystem.xhp @@ -123,8 +123,8 @@ from scriptforge import CreateScriptService - fso = CreateScriptService("FileSystem") - fso.BuildPath(...) + fs = CreateScriptService("FileSystem") + fs.BuildPath(...) @@ -353,9 +353,9 @@ - fso = CreateScriptService("FileSystem") - fso.FileNaming = "URL" - aFileName = fso.BuildPath("file:///home/user", "sample file.odt") + fs = CreateScriptService("FileSystem") + fs.FileNaming = "URL" + aFileName = fs.BuildPath("file:///home/user", "sample file.odt") # file:///home/user/sample%20file.odt @@ -385,8 +385,8 @@ - fso.FileNaming = "SYS" - if fso.CompareFiles(r"C:\myFile1.txt", r"C:\myFile2.txt", comparecontents = False): + fs.FileNaming = "SYS" + if fs.CompareFiles(r"C:\myFile1.txt", r"C:\myFile2.txt", comparecontents = False): # ... @@ -425,8 +425,8 @@ - fso.CopyFile(r"C:\Documents\my_file.odt", r"C:\Temp\copied_file.odt") - fso.CopyFile(r"C:\Documents\*.*", r"C:\Temp", overwrite = False) + fs.CopyFile(r"C:\Documents\my_file.odt", r"C:\Temp\copied_file.odt") + fs.CopyFile(r"C:\Documents\*.*", r"C:\Temp", overwrite = False) Beware that subfolders and their contents are not copied when wildcards are used in the source argument. @@ -464,7 +464,7 @@ # Python - fso.CopyFolder(r"C:\Documents\*", r"C:\Temp", overwrite = False) + fs.CopyFolder(r"C:\Documents\*", r"C:\Temp", overwrite = False) @@ -489,7 +489,7 @@ # Python - fso.CreateFolder(r"C:\NewFolder") + fs.CreateFolder(r"C:\NewFolder") @@ -518,8 +518,8 @@ - fso.FileNaming = "SYS" - myFile = fso.CreateTextFile(r"C:\Temp\ThisFile.txt", overwrite = True) + fs.FileNaming = "SYS" + myFile = fs.CreateTextFile(r"C:\Temp\ThisFile.txt", overwrite = True) To learn more about the names of character sets, visit IANA's Character Set page. Beware that %PRODUCTNAME does not implement all existing character sets. @@ -548,7 +548,7 @@ # Python - fso.DeleteFile(r"C:\Temp\*.docx") + fs.DeleteFile(r"C:\Temp\*.docx") @@ -576,7 +576,7 @@ # Python - fso.DeleteFolder(r"C:\Temp\*") + fs.DeleteFolder(r"C:\Temp\*") @@ -604,7 +604,7 @@ # Python - sFolder = fso.ExtensionFolder("apso.python.script.organizer") + sFolder = fs.ExtensionFolder("apso.python.script.organizer") @@ -632,8 +632,8 @@ - fso.FileNaming = "SYS" - if fso.FileExists(r"C:\Documents\my_file.odt"): + fs.FileNaming = "SYS" + if fs.FileExists(r"C:\Documents\my_file.odt"): # ... @@ -666,8 +666,8 @@ - fso.FileNaming = "SYS" - filesList = fso.Files("/home/user/", "*.txt") + fs.FileNaming = "SYS" + filesList = fs.Files("/home/user/", "*.txt") for file in fileList: # ... @@ -697,8 +697,8 @@ - fso.FileNaming = "SYS" - if fso.FolderExists(r"C:\Documents\Thesis") + fs.FileNaming = "SYS" + if fs.FolderExists(r"C:\Documents\Thesis") # ... @@ -727,8 +727,8 @@ bas = CreateScriptService("Basic") - bas.MsgBox(fso.GetBaseName("/home/user/Documents")) # "Documents" - bas.MsgBox(fso.GetBaseName("/home/user/Documents/my_file.ods")) # "my_file" + bas.MsgBox(fs.GetBaseName("/home/user/Documents")) # "Documents" + bas.MsgBox(fs.GetBaseName("/home/user/Documents/my_file.ods")) # "my_file" @@ -754,7 +754,7 @@ # Python - ext = fso.GetExtension(r"C:\Windows\Notepad.exe") # "exe" + ext = fs.GetExtension(r"C:\Windows\Notepad.exe") # "exe" @@ -781,8 +781,8 @@ - fso.FileNaming = "SYS" - fLen = fso.GetFileLen(r"C:\pagefile.sys") + fs.FileNaming = "SYS" + fLen = fs.GetFileLen(r"C:\pagefile.sys") @@ -808,7 +808,7 @@ - fso.FileNaming = "SYS" + fs.FileNaming = "SYS" aDate = FSO.GetFileModified(r"C:\Documents\my_file.odt") @@ -834,7 +834,7 @@ # Python - a = fso.GetName(r"C:\Windows\Notepad.exe") # Notepad.exe + a = fs.GetName(r"C:\Windows\Notepad.exe") # Notepad.exe @@ -859,7 +859,7 @@ # Python - a = fso.GetParentFolderName(r"C:\Windows\Notepad.exe") # C:\Windows\ + a = fs.GetParentFolderName(r"C:\Windows\Notepad.exe") # C:\Windows\ @@ -886,7 +886,7 @@ - fso.FileNaming = "SYS" + fs.FileNaming = "SYS" fName = FSO.GetTempName() + ".txt" # "/tmp/SF_574068.txt" @@ -946,7 +946,7 @@ # Python - fso.MoveFile(r"C:\Temp1\*.*", r"C:\Temp2") + fs.MoveFile(r"C:\Temp1\*.*", r"C:\Temp2") @@ -975,7 +975,7 @@ # Python - fso.MoveFolder(r"C:\Temp1\*", r"C:\Temp2") + fs.MoveFolder(r"C:\Temp1\*", r"C:\Temp2") @@ -1017,8 +1017,8 @@ - fso.FileNaming = "SYS" - myFile = fso.OpenTextFile(r"C:\Temp\ThisFile.txt", fso.ForReading) + fs.FileNaming = "SYS" + myFile = fs.OpenTextFile(r"C:\Temp\ThisFile.txt", fs.ForReading) if myFile is not None: # ... @@ -1056,7 +1056,7 @@ # Python - aFile = fso.PickFile(r"C:\Documents", "OPEN", "txt") + aFile = fs.PickFile(r"C:\Documents", "OPEN", "txt") @@ -1081,7 +1081,7 @@ # Python - aFolder = fso.PickFolder(r"C:\Documents", "Choose a folder or press Cancel") + aFolder = fs.PickFolder(r"C:\Documents", "Choose a folder or press Cancel") @@ -1112,8 +1112,8 @@ - fso.FileNaming = "SYS" - folderList = fso.SubFolders("/home/user/") + fs.FileNaming = "SYS" + folderList = fs.SubFolders("/home/user/") for folder in folderList: # ... diff --git a/source/text/sbasic/shared/03/sf_formcontrol.xhp b/source/text/sbasic/shared/03/sf_formcontrol.xhp index c1f673946d..448fc99c80 100644 --- a/source/text/sbasic/shared/03/sf_formcontrol.xhp +++ b/source/text/sbasic/shared/03/sf_formcontrol.xhp @@ -62,8 +62,8 @@ from scriptforge import CreateScriptService from time import localtime, strftime - svc = CreateScriptService('ScriptForge.Basic') - doc = CreateScriptService('SFDocuments.Document', svc.ThisDatabaseDocument) + bas = CreateScriptService('ScriptForge.Basic') + doc = CreateScriptService('SFDocuments.Document', bas.ThisDatabaseDocument) form = doc.Forms('formDocumentName', 'formName') # SFDocuments.Form control = form.Controls('myTextBox') # SFDocuments.FormControl control.Value = 'Current Time = ' + strftime("%a, %d %b %Y %H:%M:%S", localtime()) diff --git a/source/text/sbasic/shared/03/sf_textstream.xhp b/source/text/sbasic/shared/03/sf_textstream.xhp index 96b393539e..7505f09c28 100644 --- a/source/text/sbasic/shared/03/sf_textstream.xhp +++ b/source/text/sbasic/shared/03/sf_textstream.xhp @@ -54,8 +54,8 @@ from scriptforge import CreateScriptService - fso = CreateScriptService("FileSystem") - myFile = fso.OpenTextFile(r"C:\Temp\ThisFile.txt", fso.ForReading) + fs = CreateScriptService("FileSystem") + myFile = fs.OpenTextFile(r"C:\Temp\ThisFile.txt", fs.ForReading) # ... myFile.CloseFile() myFile = myFile.Dispose() @@ -251,8 +251,8 @@ - fso = CreateScriptService("FileSystem") - inputFile = fso.OpenTextFile("/home/user/Documents/Students.txt") + fs = CreateScriptService("FileSystem") + inputFile = fs.OpenTextFile("/home/user/Documents/Students.txt") allData = inputFile.ReadAll() arrNames = allData.split(inputFile.NewLine) # ... @@ -356,8 +356,8 @@ def squared_values_file(lastValue): - fso = CreateScriptService("FileSystem") - myFile = fso.CreateTextFile("/home/user/Documents/squares.csv") + fs = CreateScriptService("FileSystem") + myFile = fs.CreateTextFile("/home/user/Documents/squares.csv") myFile.WriteLine("Value;Value Squared") for value in range(1, lastValue + 1): myFile.WriteLine("{};{}".format(value, value ** 2)) diff --git a/source/text/sbasic/shared/03/sf_ui.xhp b/source/text/sbasic/shared/03/sf_ui.xhp index 1c012cfae8..c01122a6e2 100644 --- a/source/text/sbasic/shared/03/sf_ui.xhp +++ b/source/text/sbasic/shared/03/sf_ui.xhp @@ -73,7 +73,7 @@ The window name is case-sensitive.

Document object

- The methods CreateDocument, CreateBaseDocument, GetDocument and OpenDocument, described below, generate document objects. When a window contains a document, an instance of the Document class represents that document. A counterexample the Basic IDE is not a document but is a window in our terminology. Additionally a document has a type: Calc, Impress, Writer, ... + The methods CreateDocument, CreateBaseDocument, GetDocument, OpenBaseDocument and OpenDocument, described below, generate document objects. When a window contains a document, an instance of the Document class represents that document. A counterexample the Basic IDE is not a document but is a window in our terminology. Additionally a document has a type: Calc, Impress, Writer, ... The specific properties and methods applicable on documents are implemented in a document class. The implementation of the document objects class is done in the SFDocuments associated library. See its "Document" service. @@ -321,8 +321,8 @@ myDoc1 = ui.CreateDocument("Calc") - FSO = CreateScriptService("FileSystem") - myDoc2 = ui.CreateDocument(templatefile = FSO.BuildPath(FSO.TemplatesFolder, "personal/CV.ott")) + fs = CreateScriptService("FileSystem") + myDoc2 = ui.CreateDocument(templatefile = fs.BuildPath(fs.TemplatesFolder, "personal/CV.ott")) @@ -348,10 +348,10 @@ - myDoc = ui.GetDocument(r"C:\Documents\My file.odt") from scriptforge import CreateScriptService - bridge = CreateScriptService("Basic") - myDoc = ui.GetDocument(bridge.ThisComponent) + bas = CreateScriptService("Basic") + myDoc = ui.GetDocument(r"C:\Documents\My file.odt") + myDoc = ui.GetDocument(bas.ThisComponent) To access the name of the currently active window, refer to the ActiveWindow property. @@ -416,7 +416,7 @@ svc.OpenBaseDocument(filename: str = '', registrationname: str = '', macroexecution: int = 0): svc - filename: Identifies the file to open. It must follow the SF_FileSystem.FileNaming notation. If the file already exists, it is overwritten without warning + filename: Identifies the file to open. It must follow the SF_FileSystem.FileNaming notation. registrationname: The name to use to find the database in the databases register. It is ignored if FileName <> "". macroexecution: 0 = behaviour is defined by the user configuration, 1 = macros are not executable, 2 = macros are executable. -- cgit