-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This section provides an overview of the usage and syntax of the HTpy programming language.
In HeavenToPython (HTpy) programming, it is crucial to adhere to the Allman coding style to ensure code readability and avoid errors. The Allman style dictates placing curly braces on their own lines, and failure to follow this style may result in errors during execution.
nameOfFunc(a, b)
{
return a + b
}
- MUST: Use the Allman style consistently throughout your HTpy code.
- WILL: Failure to use the Allman style may lead to errors during execution.
Adhering to the Allman coding style not only helps maintain clean and organized code but also ensures compatibility and error-free execution in HTpy programming.
In HeavenToPython (HTpy), the coding style follows the Allman style, where curly braces are placed on their own lines. Additionally, comments are denoted by a semicolon ;
for single-line comments and by using semicolon ;
for each line in multi-line comments. There are no block comments.
In HTpy, variables are declared and assigned using the Allman style, and variable names follow the same conventions as in AutoHotkey. Here's how you declare and assign variables:
myNumber := 42
myString := "Hello, World!"
isFlagSet := true
; Assigns the value 5 to the variable 'num'
num := 5
; Dynamic variable names in HTpy, like var%num%, allow you to construct variable names
; based on runtime values stored in other variables. This flexibility is particularly
; useful when you need to access or assign values to variables dynamically during script execution.
; Assigns the string "hello" to the variable 'var5'.
var%num% := "hello"
; Displays the value of 'var5' in a message box.
MsgBox, % var5
; Regular string literal
; This is a regular string literal
regular_string := "Hello`nWorld!"
; In regular strings, `n is interpreted as a newline character
; Therefore, regular_string will output:
; Hello
; World!
; Raw string literal
; This is a raw string literal
raw_string := r"Hello`nWorld!"
; In raw strings, `n is treated as literal characters ` and n
; Therefore, raw_string will output:
; Hello`nWorld!
; Print both strings
MsgBox, Regular String:
MsgBox, % regular_string
MsgBox, Raw String:
MsgBox, % raw_string
HTpy supports various data types, including numeric, string, and boolean types.
Control structures in HTpy, including conditional statements and loops, follow the Allman style as well.
if (condition)
{
; Code block executed if condition is true
}
else
{
; Code block executed if condition is false
}
Loop
{
; Code block to be repeated
}
Functions in HTpy are declared using the Allman style, and return statements are in lowercase. Here's how you declare and define functions:
nameOfFunc(a, b)
{
return a + b
}
Functions in HTpy must be declared at the top of the script following the rules of Python.
Comments in HTpy are denoted by a semicolon ;
for single-line comments and are placed on their own lines for multi-line comments.
; This is a single-line comment
"""
This is
a multi-line comment
"""
HTpy is designed for simplicity and ease of use, following the Allman coding style throughout the language. It is suitable for various applications, including web development, scripting, and learning programming concepts.
Here's an example demonstrating the usage of variables, control structures, and functions in HTpy:
nameOfFunc(num1, num2)
{
return num1 + num2
}
myNumber := 42
myString := "Hello, World!"
if (myNumber > 0)
{
MsgBox, % "Number is positive: " . str(myNumber)
}
else
{
MsgBox, % "Number is non-positive: " . str(myNumber)
}
nameOfFunc := nameOfFunc(3, 4)
MsgBox, % "Result of nameOfFunc: " . str(nameOfFunc)
WARNING: NEVER NAME A VARIABLE THE SAME NAME AS A FUNCTION NAME
HTpy follows the Allman coding style for consistency and readability. Its simplicity and versatility make it suitable for various programming tasks.
Explore the various features offered by the HTpy programming language in this section.
- Functions
- If, else, else if
- Random
- Sleep
- Msgbox
- FileRead
- FileAppend
- SetTimer
- Labels
- Gosub
- Return/return
- Loop
- Loop, Parse
- Variables
- RunCMD and ExitApp
- Comments
- Sort
- Endpoint
- getDataFromAPI and getDataFromJSON
- Math Functions
- Build-in Functions
- Build-in Variables
In HeavenToPython (HTpy), functions are indispensable for organizing and structuring code efficiently. By encapsulating reusable blocks of code, functions enhance modularity, readability, and maintainability. Adhering to the Allman Style coding convention is crucial for defining functions in HTpy, ensuring clarity and consistency in code formatting.
nameOfFunc(param1, param2, ...)
{
; Function body
return result
}
Ensure that the opening curly brace {
is placed on a new line when defining functions in HeavenToPython (HTpy). Failure to adhere to this convention will result in errors, and the function will not be recognized.
Functions in HTpy must be declared at the top of the script following the rules of Python.
-
nameOfFunc
: The name of the function, following the Allman Style convention. -
param1
,param2
, ...: Parameters that the function accepts for processing.
sum(a, b)
{
return a + b
}
- Consistent indentation and spacing within the function body enhance code readability.
- All functions in HTpy are similar to Python's scope.
- You can't declare function inside a function
Functions serve various purposes, such as mathematical calculations, data processing, and executing specific actions based on input parameters. Consider the following example illustrating the usage of a function to calculate the sum of two numbers:
; Define the sum function
sum(a, b)
{
return a + b
}
; Call the sum function with arguments
result := str(sum(5, 10))
; Display the result
MsgBox, The sum is: %result%
In this example, the sum
function takes two parameters a
and b
, adds them together, and returns the result. The function is called with arguments 5
and 10
, and the returned result is displayed using a message box.
Functions in HTpy empower developers to structure code effectively and promote code reuse. By following the Allman Style convention and leveraging global function scope, developers can create well-organized and maintainable scripts in HeavenToPython.
The If
, else
, and else if
statements in HeavenToPython (HTpy) are fundamental control structures used for making decisions and executing different blocks of code based on specified conditions. These statements provide the ability to create branching logic within scripts, enabling developers to implement conditional behavior.
if (condition)
{
; Code to execute if the condition is true
}
else if (anotherCondition)
{
; Code to execute if the first condition is false and this condition is true
}
else
{
; Code to execute if all preceding conditions are false
}
-
condition
: A Boolean expression that evaluates to either true or false. -
anotherCondition
: An additional Boolean expression used inelse if
statements.
; Example demonstrating the usage of if, else if, and else statements
x := 10
if (x > 10)
{
MsgBox, x is greater than 10
}
else if (x < 10)
{
MsgBox, x is less than 10
}
else
{
MsgBox, x is equal to 10
}
In addition to simple comparisons, HTpy supports various logical operators such as &&
(logical AND), ||
(logical OR), and
, or
, and negation !
(logical NOT). These operators can be combined to form complex conditional expressions.
; Example demonstrating the usage of logical operators in conditional expressions
var1 := 3
var2 := 5
if (var1 = 3) && (var2 = 5) or (var2 != 6)
{
MsgBox, Condition is true
}
else
{
MsgBox, Condition is false
}
Additionally, functions can be used within conditional statements to evaluate conditions dynamically. The !
operator can be used to negate the result of a function call.
; Example demonstrating the usage of function calls and negation in conditional statements
if !(collision())
{
MsgBox, No collision detected
}
else
{
MsgBox, Collision detected
}
In this example, the collision
function is called within the if
statement, and its return value is negated using the !
operator. If the result of the collision
function is false (indicating no collision), the message "No collision detected" is displayed. Otherwise, if a collision is detected, the message "Collision detected" is displayed.
- It's important to properly use parentheses to ensure the desired evaluation order when combining logical operators.
- Functions can be called within conditional statements to evaluate conditions dynamically, providing flexibility in script behavior.
The If
, else if
, and else
statements, along with logical operators, provide powerful tools for implementing conditional logic in HeavenToPython (HTpy) scripts. By combining these features, developers can create dynamic and responsive applications capable of handling various scenarios and user inputs effectively.
The Random
feature in HeavenToPython (HTpy) enables developers to generate random numbers within specified ranges. This functionality is particularly useful for scenarios where randomness is required, such as in game development, simulations, or randomized algorithms.
Random, OutputVar, Min, Max
-
OutputVar
: The variable to store the generated random number. -
Min
: The minimum value of the range (inclusive). -
Max
: The maximum value of the range (inclusive).
; Generate a random number between 1 and 100
Random, randomNumber, 1, 100
; Display the generated random number
MsgBox, % "Random number: " . str(randomNumber)
or
var1 := 1
var2 := 100
Random, OutputVar, %var1%, %var2%
; Display the generated random number
MsgBox, % "Random number: " . str(OutputVar)
The Random
feature provides a simple yet effective way to introduce randomness into HTpy scripts. Whether it's for generating random numbers for game mechanics, simulating probabilistic events, or implementing randomized algorithms, the Random
function offers flexibility and versatility in handling randomization requirements.
With the Random
feature in HeavenToPython (HTpy), developers can easily incorporate randomness into their scripts, adding an element of unpredictability and dynamism to their applications. Whether it's for game development, simulations, or other scenarios requiring randomness, the Random
function offers a straightforward solution for generating random numbers within specified ranges.
The Sleep
feature in HeavenToPython (HTpy) allows developers to introduce delays or pauses in their scripts, which can be useful for various purposes such as controlling the timing of actions, implementing animations, or simulating real-time behavior.
This feature does NOT work on the web HTpy playground.
Sleep, Delay
-
Delay
: The duration of the pause in milliseconds. This can be an integer or a variable containing the desired delay duration.
; Pause script execution for 2 seconds (2000 milliseconds)
Sleep, 2000
The Sleep
function is commonly used when precise timing is required between consecutive actions in a script. By specifying the desired delay duration, developers can control the pace of script execution, ensuring that actions occur at the intended times.
; Example of using Sleep in a script
; This script waits for 3 seconds, then displays a message box
Sleep, 3000
MsgBox, Three seconds have passed!
In this example, the Sleep
function is used to pause the script execution for 3000 milliseconds (3 seconds) before displaying a message box.
- Be mindful of using excessive
Sleep
statements, as they can introduce unnecessary delays and impact script performance.
The Sleep
function in HeavenToPython (HTpy) provides a simple yet effective way to introduce pauses or delays in scripts, allowing developers to control the timing of actions and create more dynamic and interactive applications. Whether it's for controlling animations, simulating real-time behavior, or implementing precise timing in script execution, the Sleep
function offers versatility and flexibility in managing script flow and timing.
The MsgBox
function in HeavenToPython (HTpy) displays a small window containing text and one or more buttons, allowing developers to interact with users and present information effectively.
MsgBox, Text
-
Text
: The text displayed inside the message box to instruct the user or present information.
- The
MsgBox
function allows developers to create informative and interactive message boxes, providing users with necessary instructions or information.
; Display a simple message box with text "Hello, World!"
MsgBox, Hello, World!
; display varables
var1 := "hello man"
MsgBox, % var1
; display varables + text
var1 := "hello man"
MsgBox, % var1 . " how are you"
; you can also do
var1 := "hello"
MsgBox, %var1%
; and
var1 := "hello"
var2 := "whats up"
MsgBox, %var1% %var2%
; or even
var1 := "man"
MsgBox, hello %var1% whats up!
By combining values from these groups, developers can customize the appearance and behavior of message boxes to suit their specific requirements.
The MsgBox
function in HeavenToPython (HTpy) provides developers with a versatile tool for creating informative and interactive message boxes, enhancing user experience and facilitating communication between the script and the user. The MsgBox
function offers flexibility and convenience in implementing various messaging scenarios within HTpy scripts.
The FileRead
feature in HeavenToPython (HTpy) allows you to read the contents of a file into a variable within your script.
This feature does NOT work on the web HTpy playground.
FileRead, OutputVar, FileName
-
OutputVar
: The variable to store the contents of the file. -
FileName
: The name of the file to read. This can be specified as a literal string or using variables directly in the filename argument.
; Read text content from the specified file if it's in the same folder as the script
FileRead, FileContent, FileName.txt
; Display the content of the file
MsgBox, % FileContent
; To use a file path, we need to put it in a string like this
FileName := r"C:\path\to\the\file.extension"
FileRead, FileContent, % FileName
; Display the content of the file
MsgBox, % FileContent
- The contents of the file are read into the specified variable (
OutputVar
), allowing you to manipulate or display the file contents as needed within your script.
By following these guidelines, you can effectively use the FileRead
feature in HeavenToPython (HTpy) to read text content from external files and incorporate it into your script.
The FileAppend
feature in HeavenToPython (HTpy) enables you to append text content to a file.
This feature does NOT work on the web HTpy playground.
FileAppend, %TextToAppend%, FileName
-
TextToAppend
: The text content to append to the file. -
FileName
: The name of the file to which the text will be appended. This can be specified as a literal string or using variables directly in the filename argument.
; Append text content to the specified file
text := "hello man"
FileAppend, %text%, FileName.txt
- The specified
TextToAppend
will be appended to the end of the file specified byFileName
.
In HeavenToPython (HTpy), the SetTimer
command is used to create and control timers within the script. Timers allow developers to execute specific actions or functions at regular intervals, providing a mechanism for scheduling tasks and automating processes.
This feature does NOT work on the web HTpy playground.
SetTimer, LabelName, Option
-
LabelName
: The name of the label or subroutine to be executed when the timer elapses. -
Option
: Specifies the interval and state of the timer. It can take one of the following values:-
Interval
: Specifies the interval in milliseconds at which the timer should elapse and trigger the execution of the specified label or subroutine. -
On
: Starts or enables the timer. -
Off
: Stops or disables the timer.
-
; Define a label to be executed by the timer
TimerLabel:
; Perform actions or execute code here
MsgBox, Timer elapsed! This is a recurring message.
Return
; Start the timer with an interval of 2000 milliseconds (2 seconds)
SetTimer, TimerLabel, 2000
; After some time or based on certain conditions, turn off the timer
; Wait for 10 seconds
Sleep, 10000
; Stop the timer
SetTimer, TimerLabel, Off
; Define a label to be executed by the timer
TimerLabel:
; Perform actions or execute code here
MsgBox, Timer elapsed! This is a recurring message.
Return
; Start the timer with an interval of 2000 milliseconds (2 seconds)
SetTimer, TimerLabel, 2000
; After some time or based on certain conditions, turn off the timer
; Wait for 5 seconds
Sleep, 5000
; Stop the timer
SetTimer, TimerLabel, Off
MsgBox, Timer is Off!
; Later, based on other conditions or user interaction, turn the timer back on
; Wait for 5 seconds
Sleep, 5000
; Restart the timer
SetTimer, TimerLabel, On
MsgBox, Timer is back On!
; Wait for 5 seconds
Sleep, 5000
; terminate the script
MsgBox, Exiting...
ExitApp
- Timers in HTpy typically involve setting up a label or subroutine to be executed at specified intervals using the
SetTimer
command. - The
Option
parameter determines the behavior of the timer:- When
Interval
is specified, the timer will elapse at the specified interval and trigger the execution of the specified label or subroutine. - When
On
is specified, the timer is started or enabled, allowing it to trigger at the specified interval. - When
Off
is specified, the timer is stopped or disabled, preventing it from triggering until it is re-enabled using theOn
option.
- When
Timers are commonly used in scripts to perform periodic tasks, such as checking for updates, refreshing data, or triggering specific actions at regular intervals. By utilizing timers, developers can automate repetitive tasks and improve the efficiency and responsiveness of their scripts and applications.
- When using timers, ensure that the specified label or subroutine is defined and contains the necessary code to be executed when the timer elapses.
- Use caution when enabling or disabling timers dynamically during script execution to avoid unintended behavior or conflicts with other script logic.
The SetTimer
command in HTpy provides a flexible and powerful way to incorporate timed events and automation into scripts, enabling developers to create more dynamic and responsive applications. By leveraging timers, developers can enhance the functionality and usability of their scripts by scheduling tasks and executing actions at specified intervals.
Labels in HeavenToPython (HTpy) serve as markers within the script to designate specific sections of code for execution. They are commonly used in conjunction with Gosub
commands to redirect the script flow to the labeled sections.
Labels are defined using a colon :
followed by the label name.
Example:
LabelName:
; Code to be executed within the label
Labels are typically used in conjunction with Gosub
commands to direct the script flow to the labeled section. The Gosub
command is used to call a subroutine defined by a label.
Label1:
MsgBox, We are in Label1
; Use uppercase Return to end the label
Return
; We will go to the label
gosub, Label1
In this example, the script invokes the Gosub
command to execute the code within the Label1
section. Once the execution of the labeled code is complete, the script continues execution after the Gosub
command.
- Labels provide a means to organize and structure the script flow, making it easier to manage and maintain complex scripts.
- Always use an uppercase
Return
at the end of a label to signify its termination, ensuring proper script execution. - Labels are often utilized in combination with conditional statements and loops to control the flow of the script based on certain conditions or criteria.
For more information on Return
, refer to Return/return.
In HeavenToPython (HTpy), the Gosub
command is used to call a subroutine defined by a label within the script. Subroutines are sections of code marked by labels, and the Gosub
command redirects the script flow to execute the code within the specified subroutine.
Gosub, Target
-
Target
: The name of the label marking the subroutine to be executed.
The Gosub
command is commonly used to organize code into manageable sections and facilitate code reuse by invoking specific subroutines as needed.
Consider the following example demonstrating the usage of the Gosub
command:
; Define a label marking the start of the subroutine
Subroutine1:
MsgBox, This is Subroutine 1
Return
; Define another label marking the start of another subroutine
Subroutine2:
MsgBox, This is Subroutine 2
Return
; Main script execution begins here
MsgBox, Main script execution started
; Call Subroutine1 using Gosub
Gosub, Subroutine1
; Continue main script execution after Subroutine1
MsgBox, Back to main script execution
; Call Subroutine2 using Gosub
Gosub, Subroutine2
; Continue main script execution after Subroutine2
MsgBox, Script execution completed
Main script execution started
This is Subroutine 1
Back to main script execution
This is Subroutine 2
Script execution completed
In this example, the Gosub
command is used to call two different subroutines (Subroutine1
and Subroutine2
) defined by labels within the script. The script flow is redirected to execute the code within each subroutine, and after the execution of each subroutine, the script continues execution from where the Gosub
command was called.
- Subroutines defined by labels provide a way to organize code into logical sections and improve code readability and maintainability.
- Always use an uppercase
Return
at the end of a subroutine to signify its termination, ensuring proper script execution. - The
Gosub
command is typically used within conditional statements, loops, or other control structures to direct the script flow based on certain conditions or criteria.
The Return
command in HeavenToPython (HTpy) serves distinct purposes based on its context within the script. It's crucial to differentiate between the uppercase Return
and lowercase return
to ensure proper script functionality and execution control.
When concluding a label or subroutine, use the uppercase Return
at the end to signify its termination. This ensures clarity in script structure and prevents unexpected behavior.
Example:
Label1:
; Code for Label1
if (var1 = 5)
{
; Use lowercase return to stop label execution any further
return
}
; Use uppercase Return to end the label
Return
Place lowercase return
anywhere in the script to halt code execution after its occurrence. This is particularly useful when you want to prevent the script from proceeding further under certain conditions.
Example:
If (condition)
{
; Code to be executed if the condition is met
; Use lowercase return to stop code execution
return
}
; Code that should only run if the condition is not met
Inside functions, utilize lowercase return
to exit the function and return a value if necessary. This maintains consistency in coding style within the context of functions.
Example:
sum(a, b)
{
; Function body
return a + b
}
By understanding and applying these conventions, developers can manage script flow effectively, ensure proper termination of blocks, and enhance code readability in HeavenToPython scripts.
The Loop
feature in HeavenToPython (HTpy) provides a mechanism for repeating a block of code a specified number of times or until a certain condition is met. This functionality is essential for automating repetitive tasks, iterating over data structures, and implementing various control flow structures within scripts.
Loop, Count
{
; Code block to be repeated
}
or
Loop
{
; Code block to be repeated until a condition is met
if (condition)
{
; Code to execute if the condition is true
break
}
}
-
Count
: Optional. Specifies the number of iterations to execute the loop. If omitted, the loop will continue indefinitely until abreak
statement or other termination condition is encountered.
; Loop 5 times and display a message
Loop, 5
{
MsgBox, % "Iteration " . str(A_Index)
}
Iteration 1
Iteration 2
Iteration 3
Iteration 4
Iteration 5
; Loop until a condition is met
Loop
{
; Code block to be repeated
if (A_Index >= 5)
{
; Exit the loop if the condition is true
break
}
}
In this example, the loop continues indefinitely until the condition A_Index >= 5
is met. Once the condition is true, the loop terminates using the break
statement.
- The loop variable
A_Index
contains the current iteration index within the loop. - The
break
statement can be used to exit the loop prematurely based on a specific condition. - The
Loop
feature provides flexibility in controlling the flow of execution within scripts, allowing for both fixed iteration counts and dynamic termination conditions.
The Loop
feature in HeavenToPython (HTpy) offers a versatile mechanism for iterating over code blocks, enabling developers to automate repetitive tasks and implement various control flow structures within their scripts.
The Loop, Parse
feature in HeavenToPython (HTpy) facilitates the parsing of strings into separate elements based on a specified delimiter. This functionality is particularly useful for breaking down and processing data stored in delimited formats.
Loop, Parse, InputString, Delimiters, OmitChars
{
; Action to be performed for each parsed element
; A_Index contains the current loop iteration index
; A_LoopField contains the current parsed element
}
-
InputString
: The string to be parsed. -
Delimiters
: A string containing one or more characters used as delimiters for parsing. By default, if no delimiters are specified, each character in the input string will be treated as a separate element. -
OmitChars
: Optional. A string containing one or more characters to be omitted during parsing.
; Example input string
inputString := "Hello World"
; Parse the input string character by character
Loop, Parse, inputString
{
; A_LoopField contains the current parsed character
MsgBox, % "Character " . str(A_Index) . ": " . A_LoopField
}
Character 1: H
Character 2: e
Character 3: l
Character 4: l
Character 5: o
Character 6:
Character 7: W
Character 8: o
Character 9: r
Character 10: l
Character 11: d
; Example input string with newline and carriage return
inputString := "Line 1`nLine 2`rLine 3"
; Parse the input string using `n` and `r` as delimiters
Loop, Parse, inputString, `n, `r
{
; A_LoopField contains the current parsed line
MsgBox, % "Line " . str(A_Index) . ": " . A_LoopField
}
Line 1: Line 1
Line 2: Line 2
Line 3: Line 3
; Example input string with commas
var1 := "Apple,Orange,Banana"
; Parse the input string using commas as delimiters
Loop, Parse, var1, `,
{
; A_LoopField contains the current parsed element
MsgBox, % "Fruit " . str(A_Index) . ": " . A_LoopField
}
Fruit 1: Apple
Fruit 2: Orange
Fruit 3: Banana
; Example input string with pipes
var2 := "Alpha|Beta|Gamma"
; Parse the input string using pipes as delimiters
Loop, Parse, var2, "|"
{
; A_LoopField contains the current parsed element
MsgBox, % "Value " . str(A_Index) . ": " . A_LoopField
}
Value 1: Alpha
Value 2: Beta
Value 3: Gamma
In these examples, the Loop, Parse
feature is utilized to parse the input strings into separate elements based on the specified delimiters. Each example demonstrates parsing the input string using different delimiters (n
, r
, ,
, |
) to extract individual elements. The loop variable A_LoopField
contains the current parsed element during each iteration, andA_Index
contains the current loop iteration index.
The Loop, Parse
feature in HTpy provides a convenient and efficient way to process delimited strings, making it easier to work with structured data in various applications. Whether dealing with configuration settings, text processing, or other delimited data formats, the Loop, Parse
functionality offers a powerful tool for data manipulation and extraction within HeavenToPython scripts.
Variables in HeavenToPython (HTpy) are used to store and manipulate data values within scripts. They provide a means of storing information that can be referenced and modified throughout the script.
Variables in HTpy are dynamically typed, meaning they can hold values of any data type without requiring explicit declaration. To assign a value to a variable, use the variable name followed by the assignment operator :=
. For example:
myNumber := 42
myString := "Hello, World!"
isFlagSet := true
HTpy supports various data types for variables, including:
- Numeric: Integers, decimals, and floating-point numbers.
- String: Textual data enclosed in double quotes.
- Boolean: True or false values.
Variable names in HTpy are case-insensitive and can consist of letters, digits, and underscores. However, they must begin with a letter. Descriptive names are recommended to reflect the purpose or content of the variable for better code readability. Don't declare variables with names like let, var, or const since this will result in an error upon execution.
WARNING: NEVER NAME A VARIABLE THE SAME NAME AS A FUNCTION NAME
Variables in HTpy have the same scope rules as Python, as HTpy transpiles to Python. This means:
- Global Scope: Variables declared outside of any function or block have global scope and can be accessed from anywhere within the script.
- Local Scope: Variables declared inside a function or block have local scope and are accessible only within that function or block.
; Declare and assign variables
myNumber := 42
myString := "Hello, World!"
myFloat := 3.14
isFlagSet := true
; Display variable values
MsgBox, % "Number: " . str(myNumber) . "`nString: " . myString . "`nFloat: " . str(myFloat) . "`nFlag: " . str(isFlagSet)
Variables in HeavenToPython (HTpy) can be utilized in various features to enhance flexibility and customization. Here's how to use variables in different contexts, ensuring to follow the specified methods:
In normal usage, variables are concatenated with other strings or values using the .
operator. Here is all the places you MUST use it.
- In MsgBox:
Specifically, in a MsgBox, we need to start with
%
just like down below. Make sure there is a space both before and after%
:
MsgBox, % "var1 is " . var1
- In declaring varibales ALL varibales are declares in this way but no need like in Msgbox to have
%
before it here is an exmpale:
; numbers
var1 := 56
; string
var2 := "this is a string"
; pass varibales
var2 := var4
; concatenated
var3 := var%numOfVar%
; concatenated this way
var%numOfVar% := 6
; more
var4 := "the var1 is = to " . var1
; or
var4 := "the var1 is = to " . var%numOfVar%
; you can also do more
var8 := var7 . " was the number of tries and we have " . %var1% . "made it and so far we have " . var%numOfVar%
In single usage, variables are enclosed within %
symbols and directly inserted into the script. For example:
Random, ran, %num1%, %num2%
In this usage, variables are concatenated with other strings or values using the .
operator, but the variable value is used only once. For example:
Random, ran, hello%var1%, hello%var3%
In this usage, variables are embedded within %
symbols directly within a string to include their values. For example:
MsgBox, text and var1 is %var1%
Please note: In these examples, ensure to follow the specified methods and refrain from using other types of variable usage for consistency and compatibility within HeavenToPython (HTpy).
- Variable names are case-insensitive.
- Avoid using reserved keywords as variable names to prevent conflicts.
- Ensure descriptive variable names for clarity and maintainability.
- Initialize variables before using them to avoid unexpected behavior.
Variables play a crucial role in storing and manipulating data within HeavenToPython (HTpy) scripts, providing developers with the flexibility to create dynamic and interactive applications.
The RunCMD
function in HeavenToPython (HTpy) allows developers to execute a system command or script from within the current HTpy script. This can be particularly useful for integrating external processes or automating tasks that require command-line operations. It works on both Windows and Linux-like systems.
This feature does NOT work on the web HTpy playground.
RunCMD(Command)
- Command: The system command or script to be executed. This should be a string.
; run a simple command and display the output in a message box
output := RunCMD("echo Hello, World!")
MsgBox, %output%
This function will execute the specified system command or script and display the output in a message box.
- The
RunCMD
function is used to run system commands or external scripts from within the HTpy script. - It works on both Windows and Linux-like systems.
The ExitApp
feature in HeavenToPython (HTpy) allows developers to terminate the currently active script. This functionality is particularly useful for terminating script execution programmatically.
This feature does NOT work on the web HTpy playground.
ExitApp
; terminate the currently active script
ExitApp
This command will terminate the script execution.
- The
ExitApp
command is used to terminate script execution.
In HeavenToPython (HTpy), comments play a vital role in enhancing code readability and providing additional context for developers.
; This is a single-line comment in HeavenToPython (HTpy)
"""
This is a block comment
This is a block comment
This is a block comment
"""
Single-line comments are prefixed with a semicolon ;
and are typically placed on separate lines to ensure clarity and readability. They are used to add explanatory notes, document code behavior, or temporarily disable code segments without removing them entirely.
; Define variables
var1 := 5
; Initialize var1 with value 5
var2 := 10
; Initialize var2 with value 10
; Calculate the sum of var1 and var2
result := var1 + var2
; Store the result in the result variable
; Display the result
MsgBox, % "The sum is: " . str(result)
; Show the sum in a message box
In this example, single-line comments are placed on separate lines to document variable initialization, calculation, and message display steps, providing clarity and context to the code.
Do not add comments on the same line as code statements in HeavenToPython (HTpy). Placing comments inline with code is not supported.
DO NOT place comments on the same line as code statements in HeavenToPython (HTpy).
- Single-line comments should be concise and focused, providing relevant information to aid in code understanding.
Comments in HeavenToPython (HTpy) are invaluable tools for improving code comprehension and facilitating collaboration among developers. By leveraging single-line comments effectively, developers can create well-documented and maintainable scripts in HeavenToPython.
The Sort
command in HTpy arranges the contents of a variable in alphabetical, numerical, or random order, and optionally removes duplicates.
Sort, VarName , Options
-
VarName: The name of the variable whose contents will be sorted. This cannot be an expression.
-
Options: A string of one or more options (in any order, with optional spaces in between) from the Options section below.
-
C: Case-sensitive sort (ignored if the
N
option is also present). If bothC
andCL
are omitted, uppercase letters A-Z are considered identical to their lowercase counterparts for sorting purposes. -
Dx: Specifies
x
as the delimiter character forVarName
. Default delimiter is linefeed (`n). -
N: Numeric sort. Treats each item as a number rather than a string for sorting purposes.
-
R: Sorts in reverse order (alphabetically or numerically depending on other options).
-
Random: Sorts in random order. Overrides other options except
D
,Z
, andU
. -
U: Removes duplicate items from the list so that every item is unique.
; Example 1: Sort alphabetically (default) with linefeed delimiter
MyVar := "apple`norange`nbanana`ngrape`napple`nbanana"
Sort, MyVar
MsgBox, % "Sorted Alphabetically:`n" . MyVar
; Example 2: Sort alphabetically case-insensitively with removal of duplicates
MyVar := "Apple`nOrange`nbanana`nGRAPE`nApple`nBanana"
Sort, MyVar, CU
MsgBox, % "Sorted Case-Insensitive with Unique:`n" . MyVar
; Example 3: Sort numerically
MyVar := "10`n2`n30`n4`n25`n1"
Sort, MyVar, N
MsgBox, % "Sorted Numerically:`n" . MyVar
; Example 4: Sort in reverse alphabetical order
MyVar := "apple`norange`nbanana`ngrape"
Sort, MyVar, R
MsgBox, % "Sorted Reverse Alphabetically:`n" . MyVar
; Example 5: Sort alphabetically with a custom delimiter (comma)
MyVar := "apple,orange,banana,grape"
Sort, MyVar, D,
MsgBox, % "Sorted with Custom Delimiter (comma):`n" . MyVar
; Example 6: Sort randomly and remove duplicates case-insensitively
MyVar := "apple`norange`nbanana`norange`napple`ngrape"
Sort, MyVar, Random
MsgBox, % "Sorted Randomly with Unique:`n" . MyVar
; Example 7: Sort numerically in reverse order with case-sensitive removal of duplicates
MyVar := "10`n2`n30`n2`n25`n1"
Sort, MyVar, NRUC
MsgBox, % "Sorted Numerically in Reverse with Unique and Case-Sensitive:`n" . MyVar
- This command is primarily used to sort a variable containing a list of lines, typically separated by linefeed (`n) characters.
- To populate a variable with lines from a file, use
FileRead
to load the entire file content intoVarName
.
- Ensure proper understanding of sorting behavior based on chosen options (
C
,CL
,N
, etc.) to achieve desired sorting results. - Consider performance implications, especially when using
CL
option due to locale-based sorting.
The Endpoint
command in HeavenToPython (HTpy) is used to define and execute communication Endpoints within a script. This functionality allows developers to specify points of interaction or data exchange, ensuring structured and modular script design.
This feature does NOT work on the web HTpy playground.
Endpoint, outVar, endpointName
{
return "the output is: " . str(outVar)
}
- outVar: The variable that will store the output or result from the endpoint interaction.
- endpointName: The specific identifier or name of the endpoint where data retrieval or interaction will occur.
; Define endpoint 1 for mathematical operation and return the result
Endpoint, result, MathOperation_Add
{
; Perform addition operation using the provided outVar
result := result + 5
return "Result after addition: " . str(result)
}
; Define endpoint 2 for string manipulation and return the modified string
Endpoint, modified_string, StringManipulation_Uppercase
{
; Append text to the modified_string using the provided outVar
modified_string := str(modified_string) . " additional text"
return "Modified string: " . str(modified_string)
}
This command sets up endpoints for communication and ensures that the provided outVar
variable is used and returned in the endpoint's logic to modify or manipulate data dynamically.
- The
Endpoint
command defines communication points within HTpy scripts. - It allows integration with external services, APIs, or local endpoints.
- Ensure that the provided
outVar
is utilized within the endpoint's logic to perform operations and return meaningful output based on the processed data.
For efficient use of the Endpoint
command in HTpy, it's recommended to utilize the getDataFromEndpoint
function from HeavenToHell (HTH) as described in the HTH documentation. This function simplifies retrieving data from endpoints and handling responses.
To run Flask-based functionalities with HTpy:
-
Ensure Flask is installed in your Python environment using the command:
pip install Flask
-
If not specified using the
Port, <port_number>
command at the top of your HTpy script, the default port for serving theindex.html
file and defining endpoints is 8000. -
You can customize the port by using the
Port, <port_number>
command before defining any endpoints or serving theindex.html
.
; Example setting port to 9000
Port, 9000
; Define endpoints below
; Define endpoint 1 for mathematical operation and return the result
Endpoint, result, MathOperation_Add
{
; Perform addition operation using the provided outVar
result := result + 5
return "Result after addition: " . str(result)
}
; Define endpoint 2 for string manipulation and return the modified string
Endpoint, modified_string, StringManipulation_Uppercase
{
; Append text to the modified_string using the provided outVar
modified_string := str(modified_string) . " additional text"
return "Modified string: " . str(modified_string)
}
This allows flexibility in specifying the port number according to your requirements. If the Port, <port_number>
command is not present, the default port 8000 will be used automatically.
To see the HTML file you are serving, navigate to localhost:8000
or the specified port in your web browser. This is where your HTpy script will serve the index.html
file and any associated endpoints.
The getDataFromAPI
function in HeavenToPython (HTpy) performs an HTTP GET request to retrieve data from an external API endpoint and processes the response asynchronously.
This feature does NOT work on the web HTpy playground.
getDataFromAPI(url)
-
url
: The URL of the API endpoint to request data from.
jsonOutput := getDataFromAPI("https://api.example.com/data")
- The
getDataFromAPI
function initiates an HTTP GET request to the specified API endpoint.
The getDataFromJSON
function in HeavenToPython (HTpy) retrieves specific data from a JSON string using a path-like syntax to navigate nested objects and arrays.
This feature does NOT work on the web HTpy playground.
getDataFromJSON(jsonString, path)
-
jsonString
: The JSON string containing the data to parse. -
path
: The path specifying the location of the desired data within the JSON structure.
- The value retrieved from the specified path within the JSON structure.
; Example usage:
jsonData := getDataFromAPI("https://jsonplaceholder.typicode.com/users")
; Define JSON paths to retrieve specific data
path1 := "[0].name"
path2 := "[0].username"
path3 := "[0].email"
MsgBox, % getDataFromJSON(jsonData, path1)
MsgBox, % getDataFromJSON(jsonData, path2)
MsgBox, % getDataFromJSON(jsonData, path3)
You can open the API URL in your web browser, then copy the JSON response from the API. Next, go to jsonpathfinder.com and paste the JSON. Then find your paths. Make sure not to copy the x.
at the beginning of the string from the JSON path.
- The
getDataFromJSON
function enables navigation through nested JSON objects using a path-like syntax. - This function simplifies data extraction from complex JSON responses retrieved from APIs or other sources.
A collection of mathematical functions available in HTpy.
Abs: Returns the absolute value of a number.
result := Abs(number)
- number: The number for which you want to find the absolute value.
- Returns the absolute value of the input number.
absValue := Abs(-5)
MsgBox, % "The absolute value of -5 is " . str(absValue)
ACos: Returns the arccosine (in radians) of a number.
result := ACos(number)
- number: The number for which you want to find the arccosine.
- Returns the arccosine of the input number in radians.
arcCos := ACos(0.5)
MsgBox, % "The arccosine of 0.5 is " . str(arcCos)
ASin: Returns the arcsine (in radians) of a number.
result := ASin(number)
- number: The number for which you want to find the arcsine.
- Returns the arcsine of the input number in radians.
arcSin := ASin(0.5)
MsgBox, % "The arcsine of 0.5 is " . str(arcSin)
ATan: Returns the arctangent (in radians) of a number.
result := ATan(number)
- number: The number for which you want to find the arctangent.
- Returns the arctangent of the input number in radians.
arcTan := ATan(0.5)
MsgBox, % "The arctangent of 0.5 is " . str(arcTan)
Ceil: Returns the smallest integer greater than or equal to a number.
result := Ceil(number)
- number: The number for which you want to find the smallest integer greater than or equal to.
- Returns the smallest integer greater than or equal to the input number.
ceiled := Ceil(4.3)
MsgBox, % "The smallest integer greater than or equal to 4.3 is " . str(ceiled)
Cos: Returns the cosine of an angle (in radians).
result := Cos(angle)
- angle: The angle (in radians) for which you want to find the cosine.
- Returns the cosine of the input angle.
cosValue := Cos(0)
MsgBox, % "The cosine of 0 radians is " . str(cosValue)
Exp: Returns the value of E raised to the power of a number.
result := Exp(number)
- number: The exponent to which E is raised.
- Returns E raised to the power of the input number.
expValue := Exp(2)
MsgBox, % "E raised to the power of 2 is " . str(expValue)
Floor: Returns the largest integer less than or equal to a number.
result := Floor(number)
- number: The number for which you want to find the largest integer less than or equal to.
- Returns the largest integer less than or equal to the input number.
floored := Floor(4.9)
MsgBox, % "The largest integer less than or equal to 4.9 is " . str(floored)
Ln: Returns the natural logarithm of a number.
result := Ln(number)
- number: The number for which you want to find the natural logarithm.
- Returns the natural logarithm of the input number.
lnValue := Ln(2.71828)
MsgBox, % "The natural logarithm of 2.71828 is " . str(lnValue)
Log: Returns the logarithm of a number to a specified base.
result := Log(number)
- number: The number for which you want to find the natural logarithm.
- Returns the natural logarithm of the input number.
logValue := Log(100)
MsgBox, % "The natural logarithm of 100 is " . str(logValue)
Round: Returns the nearest integer to a number.
result := Round(number)
- number: The number to be rounded.
- Returns the nearest integer to the input number.
rounded := Round(4.6)
MsgBox, % "The nearest integer to 4.6 is " . str(rounded)
Sin: Returns the sine of an angle (in radians).
result := Sin(angle)
- angle: The angle (in radians) for which you want to find the sine.
- Returns the sine of the input angle.
sinValue := Sin(0)
MsgBox, % "The sine of 0 radians is " . str(sinValue)
Sqrt: Returns the square root of a number.
result := Sqrt(number)
- number: The number for which you want to find the square root.
- Returns the square root of the input number.
sqrtValue := Sqrt(9)
MsgBox, % "The square root of 9 is " . str(sqrtValue)
Tan: Returns the tangent of an angle (in radians).
result := Tan(angle)
- angle: The angle (in radians) for which you want to find the tangent.
- Returns the tangent of the input angle.
tanValue := Tan(0)
MsgBox, % "The tangent of 0 radians is " . str(tanValue)
A collection of Build-in Function available in HTpy.
- str
- int
- float
- input
- Chr
- InStr
- RegExMatch
- RegExReplace
- StrLen
- SubStr
- Trim
- StrReplace
- Mod
- Asc
- StrLower
str: Converts a value into its string representation.
result := str(value)
- value: The value to convert into a string representation.
- Returns a string representation of the input value.
number := 42
strNumber := str(number)
MsgBox, % "The string representation of " . str(number) . " is " . strNumber
The str
function converts a value into its string representation. In HTpy, you cannot concatenate strings directly with numbers. You need to use str()
to convert numbers to strings for concatenation or other string operations.
In Example 1:
-
str(number)
converts the number42
into the string"42"
. - The variable
strNumber
now holds the string representation ofnumber
. - The
MsgBox
command displays a message box showing: "The string representation of 42 is 42".
age := 30
MsgBox, % "Your current age is " . str(age)
In Example 2:
-
str(age)
converts the number30
into the string"30"
. - The
MsgBox
command concatenates the string"Your current age is "
with the result ofstr(age)
, resulting in the message box displaying: "Your current age is 30".
This function is essential for converting numbers or other non-string values into strings when performing operations like concatenation, displaying messages, or storing textual data in variables.
int: Converts a value into an integer.
result := int(value)
- value: The value to convert into an integer.
- Returns the integer representation of the input value.
numberAsString := "42"
intValue := int(numberAsString)
MsgBox, % "The integer value of " . str(numberAsString) . " is " . str(intValue)
The int
function converts a string representation of a number into an integer. In HTpy, this is particularly useful when dealing with numeric input that is initially in string format, such as data from user input or external sources.
In Example 1:
-
int(numberAsString)
converts the string"42"
into the integer42
. - The variable
intValue
now holds the integer representation ofnumberAsString
. - The
MsgBox
command displays a message box showing: "The integer value of 42 is 42".
decimalNumber := 3.14
truncatedInt := int(decimalNumber)
MsgBox, % "The integer part of " . str(decimalNumber) . " is " . str(truncatedInt)
In Example 2:
-
int(decimalNumber)
converts the floating-point number3.14
into the integer3
by truncating the decimal part. - The
MsgBox
command concatenates strings to display: "The integer part of 3.14 is 3".
This function is essential for converting string representations of numbers or floating-point numbers into integers when performing calculations, comparisons, or storing numeric data in variables.
float: Converts a value into a floating-point number.
result = float(value)
- value: The value to convert into a floating-point number.
- Returns the floating-point representation of the input value.
integerNumber := 42
floatValue := float(integerNumber)
MsgBox, % "The floating-point value of " . str(integerNumber) . " is " . str(floatValue)
The float
function converts an integer or string representation of a number into a floating-point number in HTpy. This is useful when dealing with numeric input that requires decimal precision.
In Example 1:
-
float(integer_number)
converts the integer42
into the floating-point number42.0
. - The variable
float_value
now holds the floating-point representation ofinteger_number
. - The
MsgBox
function displays a message box showing: "The floating-point value of 42 is 42.0".
strNumber := "3.14"
parsedFloat := float(strNumber)
MsgBox, % "The floating-point value of " . strNumber . " is " . str(parsedFloat)
In Example 2:
-
float(str_number)
converts the string"3.14"
into the floating-point number3.14
. - The
MsgBox
function formats a message to display: "The floating-point value of 3.14 is 3.14".
This function is essential for converting integer values, string representations of numbers, or other non-floating-point values into floating-point numbers when performing calculations, handling decimal data, or storing numeric data in variables in HTpy.
input: Prompts the user for input and returns the user's response.
userInput = input(prompt)
- prompt: The text message to display to the user when asking for input.
- Returns the text entered by the user as a string.
userName := input("Please enter your name: ")
MsgBox, % "Hello, " . userName . "!"
The input
function displays a prompt to the user and captures their input as a string. This is useful for gathering user input in a script, such as names, preferences, or other data.
In Example 1:
-
input("Please enter your name: ")
shows a prompt asking the user to enter their name. - The variable
userName
captures the user's input. -
MsgBox
then displays a greeting message: "Hello, [userName]!"
userAge := input("Enter your age: ")
MsgBox, % "You are " . userAge . " years old."
In Example 2:
-
input("Enter your age: ")
prompts the user to enter their age. - The variable
userAge
stores the input as a string. -
MsgBox
displays a message: "You are [userAge] years old."
The input
function is essential for creating interactive scripts that require user feedback or data. It enables the script to capture and use user-provided information in various applications.
Chr: Returns the character corresponding to a specified ASCII code.
result := Chr(asciiCode)
- asciiCode: The ASCII code for which you want to retrieve the corresponding character.
- Returns the character corresponding to the input ASCII code.
character := Chr(65)
MsgBox, The character corresponding to ASCII code 65 is %character%
InStr: Returns true if a substring is found within a string; otherwise, returns false.
InStr(haystack, needle)
- haystack: The string in which you want to search for the substring.
- needle: The substring you want to find within the haystack.
- Returns true if the substring is found within the string; otherwise, returns false.
var1 := "Hello World"
if (InStr(var1, "World"))
{
MsgBox, We found `"World`" in %var1%
}
RegExMatch: Searches a string using a regular expression pattern and returns the position and length of the match.
result := RegExMatch(subject, regexPattern, outputArray)
- subject: The string you want to search using the regular expression pattern.
- regexPattern: The regular expression pattern to match against the string.
- outputArray: (Optional) An array to store the position and length of the match.
- Returns the position of the match within the string. If outputArray is provided, it also stores the position and length of the match in the specified array.
; Example
var1 := "Hello World"
regex := "World"
matchPosition := RegExMatch(var1, regex)
if (matchPosition > 0)
{
MsgBox, % "Found " . "'" . regex . "'" . " at position " . str(matchPosition)
}
else
{
MsgBox, No match found.
}
-
Explanation:
-
var1 := "Hello World"
: Defines a stringvar1
containing "Hello World". -
regex := "World"
: Specifies a regular expression pattern to search for the substring "World". -
matchPosition := RegExMatch(var1, regex)
: Calls theRegExMatch
function to find the position of the substring defined byregex
withinvar1
. -
if (matchPosition > 0)
: Checks if a match was found (matchPosition
greater than 0). -
MsgBox, Found '%regex%' at position %matchPosition%
: Displays a message box indicating the position where the match was found ifregex
matchesvar1
. -
else
: Executes if no match is found, displaying "No match found."
-
These examples demonstrate the usage of the RegExMatch
function in HTpy, using the provided implementation to perform regex matches and handle output as specified. Each example illustrates different scenarios where RegExMatch
is used to find matches within strings using regular expressions in HTpy.
RegExReplace: Searches for and replaces occurrences of a regular expression pattern within a string.
result := RegExReplace(subject, regexPattern, replacement)
- subject: The string in which to search for replacements using the regular expression pattern.
- regexPattern: The regular expression pattern to search for within the string.
- replacement: The replacement string to substitute in place of matches found.
- Returns the modified string with replacements performed. If outputVar is provided, the modified string is stored in outputVar.
modifiedString := RegExReplace("Hello World", "World", "Universe")
MsgBox, %modifiedString%
original := "The quick brown fox jumps over the lazy dog."
modified := RegExReplace(original, "\\b\\w{4}\\b", "****")
MsgBox, Original: %original% Modified: %modified%
In these examples:
- Example 1 replaces "World" with "Universe" in the string "Hello World".
- Example 2 replaces all 4-letter words with "****" in a given string.
Each example demonstrates different uses of the RegExReplace
function to manipulate strings based on regular expression patterns.
StrLen: Returns the length of a string.
result := StrLen(string)
- string: The string for which you want to find the length.
- Returns the length of the input string.
length := StrLen("Hello World")
MsgBox, % "The length of the string is " . str(length)
SubStr: Returns a substring from a string.
result := SubStr(string, startPos, length)
- string: The string from which you want to extract a substring.
- startPos: The starting position of the substring.
- length: (Optional) The length of the substring to extract.
- Returns the extracted substring.
substring := SubStr("Hello World", 7)
MsgBox, The substring is %substring%
substring := SubStr("Hello World", 1, 5)
MsgBox, The first 5 characters are %substring%
Trim: Removes leading and trailing whitespace from a string.
result := Trim(string)
- string: The string from which you want to remove leading and trailing whitespace.
- Returns the string with leading and trailing whitespace removed.
trimmedString := Trim(" Hello World ")
MsgBox, The trimmed string is %trimmedString%
StrReplace: Replaces occurrences of a substring within a string.
result := StrReplace(string, find, replace)
- string: The string in which you want to replace occurrences of a substring.
- find: The substring you want to replace.
- replace: The replacement string.
- Returns the modified string with occurrences of the substring replaced.
str1 := "Hello World"
modifiedString := StrReplace(str1, "World", "Universe")
MsgBox, The modified string is %modifiedString%
Mod: Returns the remainder of a division operation.
result := Mod(dividend, divisor)
- dividend: The number to be divided.
- divisor: The number by which to divide the dividend.
- Returns the remainder of the division operation.
; Define a string with a list of numbers separated by commas
numbers := "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 33, 34, 20, 61, 100"
; Start a loop to parse each number from the string
Loop, Parse, numbers, ", "
{
; Convert the current loop field (A_LoopField) to an integer and check if it's even
if (!Mod(int(A_LoopField), 2))
{
; If the number is even, display a message box with the even number
MsgBox, % "The number " . A_LoopField . " is even"
}
else
{
; If the number is odd, display a message box with the odd number
MsgBox, The number %A_LoopField% is odd
}
}
Asc: Returns the ASCII code of a character.
result := Asc(character)
- character: The character for which you want to retrieve the ASCII code.
- Returns the ASCII code of the input character.
asciiCode := Asc("A")
MsgBox, % "The ASCII code of 'A' is " . str(asciiCode)
StrLower: Converts a string to lowercase.
result := StrLower(string)
- string: The string to convert to lowercase.
- Returns the lowercase version of the input string.
var1 := "Hello World"
lowercase := StrLower(var1)
MsgBox, The lowercase version of %var1% is %lowercase%
This modified section explains the usage and purpose of StrLower()
in HTpy, demonstrating how to use it with an example. You can use this format to provide clear documentation for the StrLower()
function.
Build-in Variables provided by HTpy for various purposes.
- A_Index
- A_LoopField
- A_TickCount
- A_Now
- A_YYYY
- A_MM
- A_DD
- A_MMMM
- A_MMM
- A_DDDD
- A_DDD
- A_Hour
- A_Min
- A_Sec
- A_Space
- A_Tab
A_Index: Contains the number of the current loop iteration in a loop.
Loop, 5
{
MsgBox, % "Loop iteration: " . str(A_Index)
}
A_LoopField: Contains the contents of the current field (column) in a loop that is iterating over a delimited file or string.
var1 := "apple,banana,orange"
Loop, Parse, var1, `,
{
MsgBox, Current field: %A_LoopField%
}
A_TickCount: Contains the number of milliseconds elapsed since the program started.
StartTime := A_TickCount
; code here
Sleep, 1500
ElapsedTime := A_TickCount - StartTime
ms := ElapsedTime
; Calculate the components
hours := Floor(ms / 3600000)
ms := Mod(ms, 3600000)
minutes := Floor(ms / 60000)
ms := Mod(ms, 60000)
seconds := Floor(ms / 1000)
milliseconds := Mod(ms, 1000)
; Display the result
ElapsedTime123 := ""
ElapsedTime123 .= str(hours) . "h " . str(minutes) . "m " . str(seconds) . "s " . str(milliseconds) . "ms"
MsgBox, % ElapsedTime123
A_Now: Contains the current local time in "Month/Day/Year, Hour:Minute:Second AM/PM" format.
MsgBox, Current local time: %A_Now%
A_YYYY: Contains the current year in four digits.
MsgBox, Current year: %A_YYYY%
A_MM: Contains the current month in two digits.
MsgBox, Current month: %A_MM%
A_DD: Contains the current day of the month in two digits.
MsgBox, Current day: %A_DD%
A_MMMM: Contains the full name of the current month.
MsgBox, Full name of current month: %A_MMMM%
A_MMM: Contains the abbreviated name of the current month.
MsgBox, Abbreviated name of current month: %A_MMM%
A_DDDD: Contains the full name of the current day of the week.
MsgBox, Full name of current day: %A_DDDD%
A_DDD: Contains the abbreviated name of the current day of the week.
MsgBox, Abbreviated name of current day: %A_DDD%
A_Hour: Contains the current hour in two digits (24-hour format).
MsgBox, Current hour: %A_Hour%
A_Min: Contains the current minute in two digits.
MsgBox, Current minute: %A_Min%
A_Sec: Contains the current second in two digits.
MsgBox, Current second: %A_Sec%
A_Space: Represents the space key.
MsgBox, Hello%A_Space%man
A_Tab: Represents the tab key.
MsgBox, |%A_Tab%Hello man|
Discover the recommended code editor for working with the HTpy programming language.
Check out the best editor for HTpy at https://github.com/TheMaster1127/SciTE4HTH
View a showcase of programs created using the HTpy programming language, demonstrating its capabilities.
Check this simple code at https://github.com/TheMaster1127/HTpy/blob/main/test.htpy