Basic 集成开发环境 (IDE)

定义 Basic IDE (集成开发环境) 的设置, 以帮助在 Basic 中编辑宏。

warning

This feature is experimental and may produce errors or behave unexpectedly. To enable it anyway, choose - LibreOffice - Advanced and select Enable experimental features checkbox.


要访问此命令...

选择「 - LibreOffice - Basic IDE」。


代码补全

此功能可帮助 Basic 程序员完成代码, 节省大量输入, 并有助于减少编码错误。

启用代码补全

Display methods of a Basic object. Code completion will display the methods of a Basic object, provided the object is a UNO extended type, and the option "Use extended types" is also on. It does not work on a generic Object or Variant Basic types.

当变量为 UNO 接口或结构时, 在变量名称后面按小数点时, 会出现一个列表框 (如「某变量. [出现列表框]」)。列表框中会列出它的方法和变量, 如下图所示。您可以使用方向键浏览方法和变量建议。要插入选中条目, 请按「回车」键或用鼠标双击它。要取消显示列表框, 请按「Esc」键。

输入方法的名称, 并按一下「Tab」键, 选中的条目将被补全。再次按下「Tab」键可循环查看最长前缀匹配的项目。例如, 当输入「aVar.aMeth」时, 它将循环「aMeth1, aMethod2, aMethod3」等条目,其他条目不隐藏。

示例:


    Dim aPicker As com.sun.star.ui.dialogs.XFilePicker
  

是有效的变量定义, 其方法可以通过点 (「.」) 运算符访问:


    aPicker.getDisplayDirectory()
  

代码提示

这些是适合 Basic 程序员的代码辅助程序。

自动更正

输入时纠正 Basic 变量和关键字的大小写。LibreOffice Basic IDE 将修改输入代码中 Basic 语句和 Basic 变量的大小写, 以改进编码风格和可读性。代码的修改基于程序的变量声明和解析的 LibreOffice Basic 命令。

示例:


    Dim intVar as Integer
  

输入「Intvar」时,会被更正为「intVar」,与已经定义的「intVar」的大小写相匹配。

Basic 关键词也会自动更正 (关键词列表由解析器提供)。

示例:

Integer, String, ReDim, ElseIf, etc...

自动闭合引号

自动闭合未闭合的引号。每次输入左引号时, LibreOffice Basic IDE 都会添加右引号。方便在 Basic 代码中插入字符串。

自动闭合括号

自动闭合未闭合的括号。每次输入左括号「(」时, LibreOffice Basic IDE 都会添加一个右括号「)」。

自动闭合过程

自动插入过程的结束语句。LibreOffice Basic IDE 会在您输入「Sub」或「Function」语句并按「回车」键时添加「End Sub」或「End Function」语句。

语言特性

使用扩展类型

Allow UNO object types as valid Basic types. This feature extends the Basic programming language standard types with the LibreOffice UNO types. This allows the programmer to define variables with the right UNO type and is necessary for the code completion feature.

示例:


    Sub Some_Calc_UNO_Types
    REM A spreadsheet object
        Dim oSheet As com.sun.star.sheet.XSpreadsheet
        oSheet = ThisComponent.getSheets().getByIndex(0)
    REM A cell object
        Dim oCell As com.sun.star.table.XCell
        oCell = oSheet.getCellByPosition(0,0)
    End Sub
  
警告图标

在 Basic 程序中使用「UNO 扩展类型」可能会影响在其他办公套件中执行程序的互通性。


请支持我们!