FileSys & O/S Hardcode Subroutine
_Valid_Path
The_Valid_Path
function ensures that a given path string ends with a backslash (`\`).If the input path does not end with a backslash, one is appended.
function _Valid_Path(Path: String): String;
Parameters
- Path: String; The input path to validate.
Return Value
Returns the corrected path string, ensuring it ends with a backslash (`\`).GetAppPath
TheGetAppPath
function retrieves the directory path where the application is running from.function GetAppPath: String;
Return Value
Returns the full path of the application directory.If retrieval fails, an empty string is returned.
ExtractFileExtW
TheExtractFileExtW
function extracts the file extension from a given filename.It returns the extension in lowercase and excludes the leading period (`.`).
function ExtractFileExtW(FileName: String): String;
Parameters
- FileName: String; The full filename including extension.
Return Value
Returns the extracted file extension in lowercase.If no extension is found, an empty string is returned.
ExtractFileNameW
TheExtractFileNameW
function extracts the filename from a given full file path.It optionally includes or excludes the file extension.
function ExtractFileNameW(CONST FileName: String; CONST Include_Ext: Boolean): String;
Parameters
- FileName: String; The full file path.
- Include_Ext: Boolean; If `True`, includes the file extension. If `False`, returns only the filename without extension.
Return Value
Returns the extracted filename, optionally with or without its extension.Returns an empty string if extraction fails.
ExtractFilePathW
TheExtractFilePathW
function extracts the directory path from a given filename.function ExtractFilePathW(FileName: String): String;
Parameters
- FileName: String; The full file path including the filename.
Return Value
Returns the extracted directory path.If no directory path is found, an empty string is returned.
ReplaceFileExtW
TheReplaceFileExtW
function replaces the file extension of a given filename while preserving the path.If no extension exists, the new extension is appended.
function ReplaceFileExtW(CONST FileName, NewExt: String): String;
Parameters
- FileName: String; The full file path.
- NewExt: String; The new file extension (without the leading `.`).
Return Value
Returns the filename with the updated extension.If no extension exists, the new extension is appended.
Play_Wave_ASync
ThePlay_Wave_ASync
procedure plays a WAV audio file asynchronously.It supports looping playback and ensures the file exists before attempting to play it.
procedure Play_Wave_ASync(FileName: String; ON_LOOP: Boolean = False);
Parameters
- FileName: String; The path to the WAV file to be played.
- ON_LOOP: Boolean; If `True`, the audio will loop continuously until stopped.
Stop_All_Waves
TheStop_All_Waves
procedure stops all currently playing WAV files asynchronously.If a specific file is provided, it stops only that file.
procedure Stop_All_Waves(FileName: String = '');
Parameters
- FileName: String; The specific WAV file to stop playback. If empty, all WAV files will be stopped.
Form_On_Monitor
TheForm_On_Monitor
procedure positions a form on a specific monitor.It adjusts the form's size and style to fit the selected monitor.
procedure Form_On_Monitor(Form: TForm; MonitorIndex: Byte; FormStyle: TFormStyle = FsStayOnTop);
Parameters
- Form: TForm; The form to position on the specified monitor.
- MonitorIndex: Byte; The index of the monitor to position the form on.
- FormStyle: TFormStyle; The form style to apply. Default is `FsStayOnTop`.
Init_Dialog_Form_Position
Initializes the screen position and layout of a dialog form according to optional layout rules.Can enforce maximum width or full maximization, with optional width limitation.
Procedure Init_Dialog_Form_Position(Form: TForm; Max_Width: Boolean = False; Maximized: Boolean = False; Max_Width_Limit: Word = 1600);
Parameters
- Form: TForm; the form whose position and size are to be initialized.
- Max_Width: Boolean; if True, restricts the form width to Max_Width_Limit.
- Maximized: Boolean; if True, sets the form window to maximized state.
- Max_Width_Limit: Word; the maximum width in pixels to apply when Max_Width is enabled.
GetParentFormFrame
TheGetParentFormFrame
function retrieves the nearest parent scrolling form or frame for a given control.It iterates through the control hierarchy to find the first `TScrollingWinControl`.
function GetParentFormFrame(Control: TControl): TScrollingWinControl;
Parameters
- Control: TControl; The control for which to find the parent form frame.
Return Value
Returns the nearest `TScrollingWinControl` found in the control hierarchy.If no parent frame is found, returns `NIL`.
GetParent_TOP_Frame
TheGetParent_TOP_Frame
function retrieves the topmost `TFrame` in the control hierarchy.It searches through parent controls until it finds the highest-level `TFrame`.
function GetParent_TOP_Frame(Control: TControl): TFrame;
Parameters
- Control: TControl; The control for which to find the topmost frame.
Return Value
Returns the highest-level `TFrame` found in the hierarchy.If no frame is found, returns `NIL`.
GetParent_TOP_Form
TheGetParent_TOP_Form
function retrieves the topmost `TForm` in the control hierarchy.It searches through parent controls until it finds the highest-level `TForm`.
function GetParent_TOP_Form(Control: TControl): TForm;
Parameters
- Control: TControl; The control for which to find the topmost form.
Return Value
Returns the highest-level `TForm` found in the hierarchy.If no form is found, returns `NIL`.
SetKeyboardLayout
TheSetKeyboardLayout
procedure sets the active keyboard layout for the application.procedure SetKeyboardLayout(CONST Local_Lang: Boolean);
Parameters
- Local_Lang: Boolean; If `True`, sets the keyboard layout to the local translation language. If `False`, switches to the English layout.
SetKeyboardLayout_Own
TheSetKeyboardLayout_Own
procedure allows setting either the default or a custom keyboard layout.procedure SetKeyboardLayout_Own(CONST Local_Lang, OwnEnabled: Boolean; CONST OwnLang: ThTranslation_Language);
Parameters
- Local_Lang: Boolean; If `True`, switches to the local translation language.
- OwnEnabled: Boolean; If `True`, applies the custom keyboard layout specified in `OwnLang`.
- OwnLang: ThTranslation_Language; The custom language layout to apply if `OwnEnabled` is `True`.
Lock_Thread_By_Token
TheLock_Thread_By_Token
function attempts to acquire a lock for thread synchronization.function Lock_Thread_By_Token(VAR Token: Boolean; Wait_Ms: Integer = 250): Boolean;
Parameters
- Token: Boolean; A shared boolean token used for synchronization.
- Wait_Ms: Integer; The maximum time in milliseconds to wait for the token. Default is `250`.
Return Value
Returns `True` if the token was successfully acquired.Returns `False` if the lock was not acquired within the wait period.
Wait_For_Thread_Token
TheWait_For_Thread_Token
function waits until a thread token becomes available.function Wait_For_Thread_Token(VAR Token: Boolean; Wait_Ms: Integer = 250): Boolean;
Parameters
- Token: Boolean; The shared synchronization token.
- Wait_Ms: Integer; The time in milliseconds to wait for the token. Minimum value is `5`.
Return Value
Returns `True` if the token is released within the wait time.Returns `False` if the token remains locked after the timeout period.
Free_And_NIL
TheFree_And_NIL
procedure safely frees an object and sets its reference to `NIL`.procedure Free_And_NIL(VAR Obj);
Parameters
- Obj: VAR; A reference to the object to be freed.
Sleep_And_App_PM
TheSleep_And_App_PM
procedure pauses execution for a given duration while also processing application messages.This ensures that the application remains responsive during the sleep period.
procedure Sleep_And_App_PM(MilliSeconds: Integer);
Parameters
- MilliSeconds: Integer; The number of milliseconds to sleep.
DebugMode
TheDebugMode
function checks whether the application is running in debug mode.It utilizes conditional compilation to determine the state of `DebugHook`.
function DebugMode: Boolean;
Return Value
Returns `True` if the application is running in debug mode (`DebugHook > 0`).Returns `False` otherwise.