interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / drafts / rosettacode / empty-string.wiki

54 lines · 1177 bytes Raw Blame History
1=={{header|Omegese}}==
2{{works with|omc|sha256 2c824805, aien-dev/omega-mv e5b32567, Linux AArch64}}
3Omega has no imports, so the small output helpers (<code>emit</code> and friends) are part of the program.
4<syntaxhighlight lang="text">
5om2
6text nl "\n"
7text tempty "s is empty\n"
8text tfull "s is not empty: "
9text word "abc"
10note emit writes every byte of a to stdout; a short write is retried, an error exits 1
11fn emit a view uchar * to void
12o = ulong 0
13while lt o len a bound 4096
14k = write 1 a o sub len a o
15if le k 0
16exit 1
17end
18o = add o ulong k
19end
20end
21note copyto copies s into d at offset off and returns the offset after it (past the end traps 3)
22fn copyto d edit uchar * off ulong s view uchar * to ulong
23for i ulong len s
24put d add off i get s i
25end
26ret add off len s
27end
28note a string here is a buffer b and its length n; the empty string is length 0
29fn check b view uchar * to void
30if eq len b 0
31emit tempty
32else
33emit tfull
34emit b
35emit nl
36end
37end
38fn main to int
39b = new uchar 16 0
40n = ulong 0
41check part b 0 n
42n = copyto b 0 word
43check part b 0 n
44n = 0
45check part b 0 n
46ret 0
47end
48</syntaxhighlight>
49{{out}}
50<pre>
51s is empty
52s is not empty: abc
53s is empty
54</pre>