In this article:
A scripting language based on C# that takes advantage of the full power of .NET. Please refer to
here for more information about the language.
- C# 10: ULogViewer 2.0
- C# 11: ULogViewer 3.0
- C# 12: ULogViewer 4.0
- C# 14: ULogViewer 2026.0
The following namespaces are imported by default:
There are 3 global variables in script runtime environment:
Allows scripts to access application-level functions. The following are members of
App:
-
-
Execute external command and get exit code of command.
action is a call-back function to let you send data to standard input and read data from standard output/error from process of command, for example:
App.ExecuteCommand("my_command", (process, cancellationToken) =>
{
var reader = process.StandardOutput;
var line = reader.ReadLine();
while (line is not null)
{
// Process the read line...
line = reader.ReadLine();
}
});
-
Find absolute path to the given command. Will returns null if command cannot be found.
-
Get format defined in application resources and generate formatted string with given arguments.
-
-
Get string resource with given key.
-
-
Get string resource with given key which makes sure that the string won't be null.
-
Check whether application is running in debug mode or not.
-
Check whether current thread is the main thread of application or not.
-
Get System.Threading.SynchronizationContext of main thread of application.
System.Threading.CancellationToken for checking whether cancellation of script running has been requested or not.
Allows accessing functions according to the purpose of the script. The actual instance of context is also determined by the purpose of the script. The following are basic members of
Context:
-
A dictionary which stores custom data. The data may be transferred across scripts if scripts belong to same set of same purpose.
-
-
Get the string with given key defined in context by calling
PrepareStrings(). Will fallback to string defined in application if it cannot be found in context, or fallback to
defaultString if string cannot be found in application either.
-
Allow writing log to log buffer and file of ULogViewer.
-
-
Setup string table for a specific culture. The format of cultureName is languagecode2-country/regioncode2. For example, en-US. You can also pass null to cultureName to define default string table.
preparation is a call-back function to setup string table. For example:
Context.PrepareStrings(null, table =>
{
table["Message"] = "Hello";
});
Context.PrepareStrings("zh-TW", table =>
{
table["Message"] = "εε";
});
String tables are dedicated for each context. Therefore, string tables setup through PrepareStrings() can only be accessed by its context.
-
ULogViewer 4.0+
-
ULogViewer 4.0+
Show dialog to let user select one or more items. The returned value is the list of indices of selected items.
-
ULogViewer 4.0+
-
ULogViewer 4.0+
Show dialog to let user select one item. The returned value is the index of selected item, or -1 if nothing is selected.
-
-
-
Shows message dialog and wait for result selected by user.
Values defined in
MessageDialogIcon:
Values defined in
MessageDialogButtons:
Values defined in
MessageDialogResult:
-
-
Shows text input dialog and wait for text input by user.
Checks whether cancellation of script execution has been requested. It is the same as checking
CancellationToken.IsCancellationRequested.
Write log with
Error level.
LogDebug(object? obj)
Write log with
Debug level.
LogInfo(object? obj)
Write log with
Information level.
LogTrace(object? obj)
Write log with
Trace level.
LogWarning(object? obj)
Write log with
Warning level.