"Sputnik" help  
Sputnik Help
-<flags> <expr>


Tests an operand variable is a number of different things.



The type of test to carry each each test is defined by a single charactor.

! = Negates the return value if it is a boolean so -!u would be same as !IsUndef()
c = Return operand count() ie string/array/binary length
O = Return operand clone() r = Return file ref of operand E = Test if operand IsEmpty())
n = Test if operand IsNull()) u = Test if operand IsUndef())
Z = Test if operand IsZero())
t = Test if operand IsTrue())
N = Test if operand IsNumericOnly()) p = Test if operand IsFloatOnly()) i = Test if operand IsSignedIntegerOnly()) I = Test if operand IsUnsignedIntegerOnly()) U = Test if operand IsIntegerOnly())
S = Test if operand IsString())
C = Test if operand IsCallable())
A = Test if operand IsClass())
a = Test if operand IsArray())
o = Test if operand IsObject())
R = Test if operand IsRef())
e = Test if operand exists f = Test if operand is file F = Test if operand is file ref d = Test if operand is directory D = Test if operand is directory ref T = Test if operand is a text file B = Test if operand is a binary file x = Test if operand has a file extension (does not check if it is a file however) Z = Test if operand file has zero size (File not existing counts as zero size...) S = Test if operand file non-zero size (returns size).

You can use multiple flags at once.

Default: None of the test flags are enabled by default.

<expr> A variable of expression to evaluate.

Return Value

Depends on what the flags test for and what the input expression is.




The Test Operator in Sputnik provides a convenient and flexible way to perform various tests on operand variables. With a single character flag, you can easily check different conditions or properties of the expression being evaluated.

This feature offers a wide range of tests that can be performed on the operand. Whether you need to determine the length of a string, check if a file exists, validate if the operand is a number, or verify if it is a specific data type, the -<flags> <expr> syntax simplifies the testing process.

By combining multiple flags, you can perform multiple tests simultaneously, enabling you to quickly and efficiently check for various conditions in a single statement.

The return value of the Test Operator expression depends on the specific flags used and the evaluation of the input expression. It allows for conditional logic based on the test results, enabling you to handle different scenarios based on the outcome of the tests.

Overall, the Test Operator enhances code readability and conciseness by providing a concise syntax for performing a wide range of tests on operand variables. It is a powerful tool for conditionally evaluating expressions and performing actions based on the test results.


Example of testing if a file exists and it is binary:

my $file = file "Sputnik.exe";
if (-FB $file)
    say "File exists and it is Binary";
    say "File does not exist or is it not binary";
// File exists and it is Binary

Example of testing if a file exists and it is text:

my $file = file "Main.spk";
if (-FT $file)
    say "File exists and it is Text";
    say "File does not exist or is it not Text";
// File exists and it is Text

Example of using the negate:

my $a = undef;
if (-u $a) // check if $a is not defined
    say "A is undefined";
    say "A is defined";
// A is undefined

my $b = "cat";
if (-!u $b) // check if $b is defined
    say "B is defined";
    say "B is undefined";
// B is defined


Cheryl (uberfox@hotmail.com)