Function
61 pages.
A function is where your app's logic lives — a top-level unit of work, written like a C# method, that runs on the server. It is transactional by…
A C-style cast converts between the numeric types. It truncates toward zero, and it is checked — a value the target type cannot hold fails loudly…
Increment or decrement a numeric variable or property by one. In statement position (i++;) and as a for increment the pre- and post-forms are…
An array literal [a, b, c] is a value: a list you can return, assign, pass as an argument, or supply as a UI prop. Its element type is inferred from…
How to build a duration and read it back. Construct one with new TimeSpan(...) or a TimeSpan.FromX factory (including TimeSpan.FromMilliseconds)…
Update a variable or property in place: x op= y is shorthand for x = x op y. Arithmetic forms need a numeric lvalue; ??= assigns only when the left…
Build a temporal value from its components. DateTime.New takes a date, optionally with a time (defaulting to midnight); DateOnly.New takes a calendar…
Tests whether a string contains, begins with, or ends with another string. The match is case-sensitive and literal — like C#'s String.Contains, the…
Explicit conversion between types — number to text, text to number, a Guid to its text form. Osy# will not convert silently where information could…
Encrypt and decrypt values under your app's key, which the platform mints, protects, and rotates for you. There is no key parameter — you never…
HMAC-SHA-256 authenticates a message under a shared key — proving it came from a key holder and was not altered, which a plain hash cannot do. Always…
MD5 of a string's UTF-8 bytes rendered as 32-character lowercase hex — the canonical C# fingerprint form. Deterministic, so it pushes down into SQL…
SHA-256 of a string's UTF-8 bytes as 64-character lowercase hex — the secure default hash. Deterministic, so it pushes down into SQL. Use it wherever…
Read the current instant. `DateTime.UtcNow`/`Today` (and the platform-idiomatic `DurableClock.Now`/…) return the current time from the platform's…
Move a DateTime forward or back. AddDays/AddHours/AddMinutes take a fractional amount and are exact. AddMonths and AddYears are CALENDAR-aware and…
Read the human-facing words of an enum value in code: its Label (the [Label] text, or the member name when there is none), its Description (the…
A sequence of consecutive integers, count of them, starting at start. It is how you iterate by index — including in a render block, which has foreach…
The C# Guid statics. `Guid.Empty` is the all-zero Guid constant, spelled without parens; `Guid.NewGuid()` mints a fresh unique Guid. Guid.Empty…
Sort a local List<T> in memory by a key selector, returning a NEW sorted List<T> (the source is untouched). Ascending or descending, stable, exactly…
Positional get/set on a List<T> by integer index, exactly like C#'s List<T>.this[int]. The index must be an integer; the result is the element type…
`LlmClient.Complete(prompt)` asks a model a question and gives you the finished text. Use it when your code wants the answer as a value — to store…
`LlmClient.Stream(prompt)` gives you a model's answer in the pieces it was produced in, so a reader sees it being written instead of waiting for it…
The numeric helpers, each returning the type C# says it returns. Abs, Min, Max and Clamp answer in the WIDEST of their arguments, so a decimal stays…
The platform numeric types are int, long, decimal, and double. Literals follow C# exactly, suffixes (L, m, d) included: a bare decimal-point literal…
Read a component off a DateTime — its year, month, day, hour, minute, second — or its day of the week (Sunday is 0), or truncate it to midnight with…
Matching, replacing and splitting with regular expressions. A pattern means the same thing wherever your code runs — the platform makes the browser…
Build a string from literal text and embedded expressions with $"…{expr}…". A hole may carry a .NET format specifier after a colon ({amount:F2})…
Formats a byte count as the words a person reads — "0 B", "1.5 KB", "2.7 MB". Binary units (1024) with the conventional KB/MB/GB labels. An ordinary…
Produce a new string from an old one: upper-case the first letter, replace every occurrence of a substring, repeat it, or take characters from one…
Joins a list of values into one string with NOTHING between the elements. It is Text.Join with no separator, and the same operation as string.Concat…
The C# string.IndexOf: the index of the FIRST ordinal occurrence of a substring, or -1 if absent. The 3-arg overload resumes the forward search at…
Joins a list of values into one string, placing the separator between each pair. It is the inverse of Text.Split, and the same operation as…
The C# string.LastIndexOf: the index of the LAST ordinal occurrence of a substring, or -1 if absent. The 3-arg overload starts the backward search at…
Ask a string a question without changing it: its length, whether it is empty or blank, and whether it contains, starts with, or ends with a piece of…
Matches a string against a wildcard pattern, where % stands for any run of characters and _ for exactly one. It is the only wildcard search in the…
The C# string.Split: breaks a string on a separator and returns the substrings as a List<string> — iterable with foreach and queryable with .Count /…
Capitalises the first letter of each word and lower-cases the rest, leaving a word that is already entirely upper-case untouched so acronyms survive…
Trim whitespace from one end of a string, or pad it out to a width with a fill string. Trimming uses the full Unicode whitespace set. Padding never…
Shorten a string to at most maxLength characters — INCLUDING the ellipsis — cutting back to the last word boundary rather than mid-word. The bound…
A function returns several values by declaring a tuple return type and returning a parenthesized list. The caller reads them by name (`t.ok`), or…
Locals can declare an explicit type instead of var; the declared type pins the binding. Literal initializers apply the C# constant conversion…
Every body accumulates its writes in a unit of work rather than sending them one at a time. UnitOfWork.Commit() makes everything accumulated so far…
Osy# has no async and no Task. A function that calls out to the world is written like any other function — the engine suspends and resumes it around…
break leaves the enclosing loop; continue skips the rest of this pass. Inside a switch, break leaves the SWITCH, not the loop around it — the one…
A value fixed at compile time and folded into the places it is used. Declare one at the TOP LEVEL to share it across the whole app, on a component…
Where a function runs. Osy# infers it from the body: a function that reads data runs on the server, a function that touches the router or the theme…
The C-style counting loop. Runs init once, then repeats the body while cond holds, running update after each pass. Any clause may be omitted; for…
Walks a collection — a query result, a list, or a parent's children. The normal way to iterate; reach for a for loop only when you need the index.
Formats a number to a string with a .NET format specifier — F2 for two decimal places, N0 for a grouped whole number, C for currency, P for a…
A function is a top-level unit of work, written like a C# method — a return type, a name, typed parameters, a body. It runs transactionally: the rows…
Conditional branching, exactly as in C#. The condition must be a bool — there is no truthiness, so a null or a number is not a condition.
The C# compile-time name fold: validates the symbol and folds to its simple-name string literal — the last identifier of the chain. Invalid symbols…
`Secret.Name` in a function body evaluates to the declared secret's value — the key itself, as a string, read at the moment it is used. It is how a…
Branch on a value against constant case labels. Only the matched section runs (no fall-through); a default section handles the rest. break exits the…
Choose a VALUE by matching a subject against patterns. Arms are tried in order and the first match wins. Patterns are a constant, a relational…
Raises a fault. It ends the function immediately, and the rows the function wrote are discarded rather than half-written. The exception types are a…
Handles a fault. C#'s syntax, including typed catches, catch filters and finally. The rows written inside a try block that throws are discarded — so…
Declares a local whose type is inferred from its initializer, exactly as in C#. The local is still statically typed — var is about not repeating the…
`@"…"` is a string where a backslash is just a backslash. Nothing inside is an escape, `""` writes a single quote, and the text may run across lines…
Repeats while a bool condition holds. Reach for it when the number of iterations is not known up front — otherwise a foreach or a for loop says more.
A `stream<T>` function produces its results one at a time instead of all at once, and a `live var` bound to one renders each item the moment it…