diff --git a/docs/Reference/Categories.md b/docs/Reference/Categories.md index a4ecb6e..375466b 100644 --- a/docs/Reference/Categories.md +++ b/docs/Reference/Categories.md @@ -190,6 +190,18 @@ Procedures: * [MonthName](../tB/Modules/Strings/MonthName) - returns the name of the specified month * [WeekdayName](../tB/Modules/Strings/WeekdayName) - returns the name of the specified day of the week +## Introspection + +Procedures: + +* [CurrentProjectName](../tB/Modules/Compilation/CurrentProjectName) - returns the name of the current project +* [CurrentComponentName](../tB/Modules/Compilation/CurrentComponentName) - returns the name of the current component (module or class) +* [CurrentComponentCLSID](../tB/Modules/Compilation/CurrentComponentCLSID) - returns the Class ID (CLSID) of the current class +* [CurrentProcedureName](../tB/Modules/Compilation/CurrentProcedureName) - returns the name of the procedure in which the function is called +* [CurrentSourceFile](../tB/Modules/Compilation/CurrentSourceFile) - returns the full path of the current source file +* [ProcessorArchitecture](../tB/Modules/Compilation/ProcessorArchitecture) - returns the processor architecture of the running application +* [CompilerVersion](../tB/Modules/Compilation/CompilerVersion) - returns the twinBASIC compiler version number + ## Financial Procedures: diff --git a/docs/Reference/Modules/Compilation/CompilerVersion.md b/docs/Reference/Modules/Compilation/CompilerVersion.md new file mode 100644 index 0000000..87d34df --- /dev/null +++ b/docs/Reference/Modules/Compilation/CompilerVersion.md @@ -0,0 +1,23 @@ +--- +title: CompilerVersion +parent: Compilation Module +permalink: /tB/Modules/Compilation/CompilerVersion +--- +# CompilerVersion +{: .no_toc } + +Returns the twinBASIC compiler version number. + +Syntax: **CompilerVersion** [ **()** ] + +The return value is a **Long** identifying the compiler that produced the running code. + +### Example + +```tb +Debug.Print "Built with twinBASIC compiler build #" & CompilerVersion() +``` + +### See Also + +- [ProcessorArchitecture](ProcessorArchitecture) function diff --git a/docs/Reference/Modules/Compilation/CurrentComponentCLSID.md b/docs/Reference/Modules/Compilation/CurrentComponentCLSID.md new file mode 100644 index 0000000..a51bda9 --- /dev/null +++ b/docs/Reference/Modules/Compilation/CurrentComponentCLSID.md @@ -0,0 +1,32 @@ +--- +title: CurrentComponentCLSID +parent: Compilation Module +permalink: /tB/Modules/Compilation/CurrentComponentCLSID +--- +# CurrentComponentCLSID +{: .no_toc } + +Returns the Class ID (CLSID) of the current class as a **String**. + +Syntax: **CurrentComponentCLSID** [ **()** ] + +The value is the GUID assigned to the enclosing class by its [`[ClassId(...)]`](../../Core/Attributes#classid) attribute. If no **ClassId** is set, the function returns the all-zero GUID. + +> [!NOTE] +> **CurrentComponentCLSID** is a compile-time intrinsic — the CLSID is read from the class's attributes when the source is compiled, not looked up from the COM registry at run time. It uses special internal bindings and may not behave like an ordinary function. + +### Example + +```tb +[ClassId("12345678-1234-1234-1234-123456789ABC")] +Class CFoo + Public Sub PrintId() + Debug.Print CurrentComponentCLSID() + End Sub +End Class +``` + +### See Also + +- [CurrentComponentName](CurrentComponentName) function +- [ClassId](../../Core/Attributes#classid) attribute diff --git a/docs/Reference/Modules/Compilation/CurrentComponentName.md b/docs/Reference/Modules/Compilation/CurrentComponentName.md new file mode 100644 index 0000000..ef1ae8a --- /dev/null +++ b/docs/Reference/Modules/Compilation/CurrentComponentName.md @@ -0,0 +1,31 @@ +--- +title: CurrentComponentName +parent: Compilation Module +permalink: /tB/Modules/Compilation/CurrentComponentName +--- +# CurrentComponentName +{: .no_toc } + +Returns the name of the current component (module or class) as a literal **String**. + +Syntax: **CurrentComponentName** [ **()** ] + +The value identifies the source unit — the **Module**, **Class**, **Form**, or other component — that lexically contains the call site. + +> [!NOTE] +> **CurrentComponentName** is a compile-time intrinsic: the literal string is baked into the compiled code at the point of the call. It does not change at run time, even when the call is reached through a forwarded or inherited member. + +### Example + +```tb +Public Sub Log(Message As String) + Debug.Print CurrentComponentName() & ": " & Message +End Sub +``` + +### See Also + +- [CurrentComponentCLSID](CurrentComponentCLSID) function +- [CurrentProcedureName](CurrentProcedureName) function +- [CurrentProjectName](CurrentProjectName) function +- [CurrentSourceFile](CurrentSourceFile) function diff --git a/docs/Reference/Modules/Compilation/CurrentProcedureName.md b/docs/Reference/Modules/Compilation/CurrentProcedureName.md new file mode 100644 index 0000000..0473f93 --- /dev/null +++ b/docs/Reference/Modules/Compilation/CurrentProcedureName.md @@ -0,0 +1,30 @@ +--- +title: CurrentProcedureName +parent: Compilation Module +permalink: /tB/Modules/Compilation/CurrentProcedureName +--- +# CurrentProcedureName +{: .no_toc } + +Returns the name of the procedure in which the function is called, as a literal **String**. + +Syntax: **CurrentProcedureName** [ **()** ] + +The value is the name of the **Sub**, **Function**, or **Property** that lexically contains the call. + +> [!NOTE] +> **CurrentProcedureName** is a compile-time intrinsic: the literal string is determined when the source is compiled, from the procedure that surrounds the call. It is not derived from the runtime call stack — wrapping the call in a helper records the helper's name, not the original caller's. + +### Example + +```tb +Public Sub DoWork() + Debug.Print CurrentProcedureName() ' Prints "DoWork" +End Sub +``` + +### See Also + +- [CurrentComponentName](CurrentComponentName) function +- [CurrentProjectName](CurrentProjectName) function +- [CurrentSourceFile](CurrentSourceFile) function diff --git a/docs/Reference/Modules/Compilation/CurrentProjectName.md b/docs/Reference/Modules/Compilation/CurrentProjectName.md new file mode 100644 index 0000000..9b28965 --- /dev/null +++ b/docs/Reference/Modules/Compilation/CurrentProjectName.md @@ -0,0 +1,30 @@ +--- +title: CurrentProjectName +parent: Compilation Module +permalink: /tB/Modules/Compilation/CurrentProjectName +--- +# CurrentProjectName +{: .no_toc } + +Returns the name of the current project as a literal **String**. + +Syntax: **CurrentProjectName** [ **()** ] + +The value is the name of the project (executable or library) that owns the call site. + +> [!NOTE] +> **CurrentProjectName** is a compile-time intrinsic — the literal string is baked into the compiled code from the project's metadata at the point of the call. + +### Example + +```tb +Dim ProjectName As String +ProjectName = CurrentProjectName() +Debug.Print "Running in project: " & ProjectName +``` + +### See Also + +- [CurrentComponentName](CurrentComponentName) function +- [CurrentProcedureName](CurrentProcedureName) function +- [CurrentSourceFile](CurrentSourceFile) function diff --git a/docs/Reference/Modules/Compilation/CurrentSourceFile.md b/docs/Reference/Modules/Compilation/CurrentSourceFile.md new file mode 100644 index 0000000..eaa9811 --- /dev/null +++ b/docs/Reference/Modules/Compilation/CurrentSourceFile.md @@ -0,0 +1,30 @@ +--- +title: CurrentSourceFile +parent: Compilation Module +permalink: /tB/Modules/Compilation/CurrentSourceFile +--- +# CurrentSourceFile +{: .no_toc } + +Returns the full path of the source file in which the function is called, as a **String**. + +Syntax: **CurrentSourceFile** [ **()** ] + +The value is the absolute path of the source file that lexically contains the call. + +> [!NOTE] +> **CurrentSourceFile** is a compile-time intrinsic: the path is captured when the source is compiled. It reflects where the file lived on the build machine and may not correspond to any path that exists at run time. + +### Example + +```tb +Public Sub TraceHere() + Debug.Print "Trace from " & CurrentSourceFile() & " in " & CurrentProcedureName() +End Sub +``` + +### See Also + +- [CurrentComponentName](CurrentComponentName) function +- [CurrentProcedureName](CurrentProcedureName) function +- [CurrentProjectName](CurrentProjectName) function diff --git a/docs/Reference/Modules/Compilation/ProcessorArchitecture.md b/docs/Reference/Modules/Compilation/ProcessorArchitecture.md new file mode 100644 index 0000000..22bfd3a --- /dev/null +++ b/docs/Reference/Modules/Compilation/ProcessorArchitecture.md @@ -0,0 +1,27 @@ +--- +title: ProcessorArchitecture +parent: Compilation Module +permalink: /tB/Modules/Compilation/ProcessorArchitecture +--- +# ProcessorArchitecture +{: .no_toc } + +Returns the processor architecture for which the running application was built. + +Syntax: **ProcessorArchitecture** [ **()** ] + +The return value is a **VbArchitecture** constant: **vbArchWin32** for a 32-bit build, or **vbArchWin64** for a 64-bit build. + +### Example + +```tb +If ProcessorArchitecture() = vbArchWin64 Then + Debug.Print "Running as 64-bit" +Else + Debug.Print "Running as 32-bit" +End If +``` + +### See Also + +- [CompilerVersion](CompilerVersion) function diff --git a/docs/Reference/Modules/Compilation/index.md b/docs/Reference/Modules/Compilation/index.md new file mode 100644 index 0000000..4c8cf9d --- /dev/null +++ b/docs/Reference/Modules/Compilation/index.md @@ -0,0 +1,16 @@ +--- +title: Compilation Module +parent: Modules +permalink: /tB/Modules/Compilation/ +has_toc: false +--- + +# Compilation module + +- [CompilerVersion](CompilerVersion) -- returns the twinBASIC compiler version number +- [CurrentComponentCLSID](CurrentComponentCLSID) -- returns the Class ID (CLSID) of the current class +- [CurrentComponentName](CurrentComponentName) -- returns the name of the current component (module or class) +- [CurrentProcedureName](CurrentProcedureName) -- returns the name of the procedure in which the function is called +- [CurrentProjectName](CurrentProjectName) -- returns the name of the current project +- [CurrentSourceFile](CurrentSourceFile) -- returns the full path of the current source file +- [ProcessorArchitecture](ProcessorArchitecture) -- returns the processor architecture of the running application diff --git a/docs/Reference/Modules/todo.md b/docs/Reference/Modules/todo.md index cfdde0b..f6489d5 100644 --- a/docs/Reference/Modules/todo.md +++ b/docs/Reference/Modules/todo.md @@ -2,7 +2,6 @@ title: General TODO List for /tB/Modules/ nav_exclude: true redirect_from: - - /tB/Modules/Compilation - /tB/Modules/Constants - /tB/Modules/Conversion - /tB/Modules/ErrObject diff --git a/docs/Reference/Procedures and Functions.md b/docs/Reference/Procedures and Functions.md index 4bd9bf2..0da4432 100644 --- a/docs/Reference/Procedures and Functions.md +++ b/docs/Reference/Procedures and Functions.md @@ -28,7 +28,13 @@ permalink: /Reference/Procedures-and-Functions - [ChDrive](../tB/Core/ChDrive) -- changes the current drive - [CurDir](../tB/Core/CurDir) -- returns the current path - [Chr$, Chr, ChrB$, ChrB, ChrW$, ChrW](../tB/Modules/Strings/Chr) -- returns the character associated with a given character code +- [CompilerVersion](../tB/Modules/Compilation/CompilerVersion) -- returns the twinBASIC compiler version number - [Cos](../tB/Modules/Math/Cos) -- returns the cosine of an angle +- [CurrentComponentCLSID](../tB/Modules/Compilation/CurrentComponentCLSID) -- returns the Class ID (CLSID) of the current class +- [CurrentComponentName](../tB/Modules/Compilation/CurrentComponentName) -- returns the name of the current component (module or class) +- [CurrentProcedureName](../tB/Modules/Compilation/CurrentProcedureName) -- returns the name of the procedure in which the function is called +- [CurrentProjectName](../tB/Modules/Compilation/CurrentProjectName) -- returns the name of the current project +- [CurrentSourceFile](../tB/Modules/Compilation/CurrentSourceFile) -- returns the full path of the current source file ## D @@ -118,6 +124,7 @@ permalink: /Reference/Procedures-and-Functions - [Pmt](../tB/Modules/Financial/Pmt) -- returns the payment for an annuity based on periodic fixed payments and a fixed interest rate - [PPmt](../tB/Modules/Financial/PPmt) -- returns the principal payment for a given period of an annuity +- [ProcessorArchitecture](../tB/Modules/Compilation/ProcessorArchitecture) -- returns the processor architecture of the running application - [PV](../tB/Modules/Financial/PV) -- returns the present value of an annuity based on periodic fixed payments and a fixed interest rate ## Q