Skip to content

Latest commit

 

History

History
150 lines (108 loc) · 3.24 KB

advanced.md

File metadata and controls

150 lines (108 loc) · 3.24 KB

😉 Advanced

Advanced Commands

woah! you made it here! alright let's start.

Imports

as you've learned in the basics, Import-Module is the default powershell cmdlet to import functions and variables from other scripts, to that in dotlang, simply:

import ".\anotherfile.ps1";
# or,
import(".\anotherfile.ps1");

simple ain't it?

Encrypting and Decrypting data

yeah, we have this in dotlang :)

$key = dotaes; # you can just use `$key = "YOUR_KEY_HERE"`
$key; # optional, displays encrypting key
$unencryptedString = "blahblahblah";
# Encrypting
$encryptedString = EncryptData $key $unencryptedString;
# Decrypting
$backToPlainText = DecryptData $key $encryptedString;

output:

image

Asynchronous Command Execution

for short, async!

very easy, To make an async job:

$jobID = dotasync("Long_Running_Command");
function isCompleted {
if (dotasync_check($jobID)) {
printTxt("Job Finished!");
printTxt("Job Returned:");
dotasync_get($jobID);
} else {
isCompleted
}
}
isCompleted

Output: image

that was pretty advanced, ain't it?

Executing Commands on an other PC

yeah.. it doesn't support dotlang commands, only powershell (sorry)..

dotremote "ComputerName or Address" "Powershell command";

Monitoring Processes

MonitorProcess "ProccessName" {
# action on proccess start goes here
};

Run As Admin/User

Invoke-InContext Admin "Write-Host hii" # run command as admin in another window
Invoke-InContext User "Write-Host hii" # run command as a user (not admin)

Output: image

Schedule commands

yep. and it's easy.

dotschedule "Command" "Time";

image

Get Current OS

$currentOS = Get-OS;
printTxt("You're running a $currentOS machine!"); # 'windows' for Windows, 'mac' for MacOS, 'gnu' for GNU/Linux

image

Amazing TUIs

hello TUIs dev. it's now MUCH easier to make TUIs with dotlang! here's an example:

$inp = dotui "What do you use?" "Windows","GNU/Linux","MacOS";
printTxt("You've choosen the input $($inp+1)");

Usage: dotui "Title" "Input 0","Input 1","Input 3", etc...

Result: image

Sort Arrays

To sort arrays in dotlang,

$array = "[1, 6, 7, 2, 3]" # in JSON format
# in v2
$sortedArray = dotsort($array);
# in v3
$sortedArray = sort($array);

$sortedArray = @(1,2,3,6,7) cool?

Get User Input Key

$key = dotkey;
printTxt 'You Pressed "$key"';

Output: You Pressed "w"

dotsharp

dotsharp is used to integrate C# with dotlang. to add a C# script:

dotsharp_add @"
// your C# script
"@

and to use it:

dotsharp("CLASS.FUNCTION(PARAMS,GOES,HERE)");