</code></pre></div></div><p>The original command line option <codeclass="language-plaintext highlighter-rouge">-w</code> to turn on warnings no longer has an effect, since warnings are now on by default</p><h2id="additional-supported-syntax"><ahref="#additional-supported-syntax"class="anchor-heading"aria-labelledby="additional-supported-syntax"><svgviewBox="0 0 16 16"aria-hidden="true"><usexlink:href="#svg-link"></use></svg></a> Additional supported syntax </h2><p>Syntax which requires sfall for compiled scripts to be interpreted is marked by asterisk (*).</p><ul><li><p>Optional arguments in user-defined procedures. You can only use constants for default values. It basically puts those constants in place of omitted arguments.</p><ul><li>new: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>procedure test(variable x, variable y := 0, variable z := -1) begin
</code></pre></div></div></li><li>old: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>procedure test(variable x, variable y, variable z) begin
</code></pre></div></div></li></ul></li><li><p>New logical operators <codeclass="language-plaintext highlighter-rouge">AndAlso</code>, <codeclass="language-plaintext highlighter-rouge">OrElse</code> for short-circuit evaluation of logical expressions. Using these operators allow the right part of logical expressions not to be evaluated (executed, computed) if the result is already known. This can improve the performance of running scripts.</p><p>Example: <codeclass="language-plaintext highlighter-rouge">if (obj andAlso obj_pid(obj) == PID_STIMPAK) then ...</code></p><p>If <codeclass="language-plaintext highlighter-rouge">obj</code> is <codeclass="language-plaintext highlighter-rouge">null</code>, the second condition will not be checked and your script won’t fail with “obj is null” error in debug.log</p><p>This also has an effect that a value of last computed argument is returned as a result of whole expressions, instead of always <codeclass="language-plaintext highlighter-rouge">false</code> (0) or <codeclass="language-plaintext highlighter-rouge">true</code> (1):</p><divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>obj := false;
</code></pre></div></div><p>You can also use the <codeclass="language-plaintext highlighter-rouge">-s</code> option to enable short-circuit evaluation for all the <codeclass="language-plaintext highlighter-rouge">AND</code>, <codeclass="language-plaintext highlighter-rouge">OR</code> operators in the script.</p><p><strong>NOTE:</strong> Be aware that it may break some old scripts because operators behavior is changed slightly.</p></li><li>Conditional expressions (Python-inspired), also known as ternary operator: <ul><li>new: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>X := value1 if (condition) else value2
</code></pre></div></div></li><li>old: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>if (condition) then
</code></pre></div></div></li></ul></li><li>To assign values, you can use the alternative assignment operator from <strong>C/Java</strong> instead of <strong>Pascal</strong> syntax. <ul><li>new: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>x = 5;
</code></pre></div></div></li></ul></li><li>Multiple variable declaration: Multiple variables can be declared on one line, separated by commas. This is an alternative to the ugly begin/end block, or the bulky single variable per line style. <ul><li>new: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>variable a, b, c;
</code></pre></div></div></li><li>old: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>variable begin a; b; c; end
</code></pre></div></div></li></ul></li><li>Variable initialization with expressions: You can now initialize local variables with complex expressions instead of constants. <ul><li>new: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>variable tile := tile_num(dude_obj);
</code></pre></div></div><p><strong>NOTE:</strong> If your expression starts with a constant (eg. <codeclass="language-plaintext highlighter-rouge">2 + 2</code>), enclose it in parentheses, otherwise compiler will be confused and give you errors.</p></li></ul></li><li>Hexadecimal numerical constants: Simply prefix a number with <codeclass="language-plaintext highlighter-rouge">0x</code> to create a hexadecimal. The numbers 0 to 9 and letters A to F are allowed in the number. The number may not have a decimal point. <ul><li>new: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>a := 0x1000;
</code></pre></div></div></li></ul></li><li>Increment/decrement operators: <codeclass="language-plaintext highlighter-rouge">++</code> and <codeclass="language-plaintext highlighter-rouge">--</code> can be used as shorthand for <codeclass="language-plaintext highlighter-rouge">+= 1</code> and <codeclass="language-plaintext highlighter-rouge">-= 1</code> respectively. They are merely a syntactic shorthand to improve readability, and so their use is only allowed where <codeclass="language-plaintext highlighter-rouge">+= 1</code> would normally be allowed. <ul><li>new: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>a++;
</code></pre></div></div></li></ul></li><li><codeclass="language-plaintext highlighter-rouge">break</code>&<codeclass="language-plaintext highlighter-rouge">continue</code> statements: They work just like in most high-level languages. <codeclass="language-plaintext highlighter-rouge">break</code> jumps out of the loop. <codeclass="language-plaintext highlighter-rouge">continue</code> jumps right to the beginning of the next iteration (see <codeclass="language-plaintext highlighter-rouge">for</code> and <codeclass="language-plaintext highlighter-rouge">foreach</code> sections for additional details). <ul><li>new: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>while (i < N) begin
</code></pre></div></div></li><li>old: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>while (i < N and not(breakFlag)) begin
</code></pre></div></div></li><li>new: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>for (i := 0; i < N; i++) begin
</code></pre></div></div></li><li>old: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>for (i := 0; i < N; i++) begin
</code></pre></div></div></li></ul></li><li><codeclass="language-plaintext highlighter-rouge">for</code> loops: Another piece of syntactic shorthand, to shorten <codeclass="language-plaintext highlighter-rouge">while</code> loops in many cases. Parentheses around the loop statements are recommended but not required (when not using parentheses, a semicolon is required after the 3rd loop statement). <ul><li>new: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>for (i := 0; i < 5; i++) begin
</code></pre></div></div><p><strong>NOTE:</strong><codeclass="language-plaintext highlighter-rouge">continue</code> statement in a <codeclass="language-plaintext highlighter-rouge">for</code> loop will recognize increment statement (third statement in parentheses) and will execute it before jumping back to the beginning of loop. This way you will not get an endless loop.</p></li></ul></li><li><codeclass="language-plaintext highlighter-rouge">switch</code> statements: A shorthand way of writing big <codeclass="language-plaintext highlighter-rouge">if then else if...</code> blocks <ul><li>new: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>switch get_attack_type begin
</code></pre></div></div></li></ul></li><li>Procedure stringify operator <codeclass="language-plaintext highlighter-rouge">@</code>: Designed to make callback-procedures a better option and allow for basic functional programming. Basically it replaces procedure names preceded by <codeclass="language-plaintext highlighter-rouge">@</code> by a string constant. <ul><li>old: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>callbackVar := "Node000";
</code></pre></div></div><p>Not many people know that since vanilla Fallout you can call procedures by “calling a variable” containing it’s name as a string value. There was a couple of problems using this:</p></li><li>optimizer wasn’t aware that you are referencing a procedure, and could remove it, if you don’t call it explicitly (can be solved by adding making procedure <codeclass="language-plaintext highlighter-rouge">critical</code>)</li><li>you couldn’t see all references of a procedure from a Script Editor</li><li>it was completely not obvious that you could do such a thing, it was a confusing syntax</li></ul></li><li>(*) <strong>Arrays</strong>: In vanilla Fallout, arrays had to be constructed by reserving a block of global/map variables. Since sfall 2.7, specific array targeted functions have been available, but they are fairly messy and long winded to use. The compiler provides additional syntactic shorthand for accessing and setting array variables, as well as for array creation. When declaring an array variable, put a constant integer in <codeclass="language-plaintext highlighter-rouge">[]</code>` to give the number of elements in the array. (before sfall 3.4 you had to specify size in bytes for array elements, now it’s not required, see “Arrays” page for more information) <ul><li>new: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>procedure bingle begin
</code></pre></div></div></li><li>old: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>procedure bingle begin
</code></pre></div></div></li></ul></li><li>(*) <strong>Array expressions</strong>: Sometimes you need to construct an array of elements and you will probably want to do it in just one expression. This is now possible: <ul><li>new: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>list := ["A", "B", "C", "D"];
</code></pre></div></div><p>Syntax specific for associative arrays is also available. (see “Arrays” page for full introduction to this type of arrays).</p></li></ul></li><li>(*) <strong>Map array expressions</strong>: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>map := {5: "five", 10: "ten", 15: "fifteen", 20: "twelve"};
</code></pre></div></div></li><li>(*) The dot <codeclass="language-plaintext highlighter-rouge">.</code> syntax to access elements of associative arrays and allow to work with arrays like objects: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>trap.radius := 3;
</code></pre></div></div><p>You can chain dot and bracket syntax to access elements of multi-dimensional arrays:</p><divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>collectionList[5].objectList[5].name += " foo";
</code></pre></div></div><p><strong>NOTE:</strong> When using incremental operators like <codeclass="language-plaintext highlighter-rouge">+=</code>, <codeclass="language-plaintext highlighter-rouge">*=</code>, <codeclass="language-plaintext highlighter-rouge">++</code>, <codeclass="language-plaintext highlighter-rouge">--</code> compiler will use additional temp variable to get an array at penultimate level in order to avoid making the same chain of <codeclass="language-plaintext highlighter-rouge">get_array</code> calls twice.</p></li><li>(*) <codeclass="language-plaintext highlighter-rouge">foreach</code> loops: A shorthand method of looping over all elements in an array. Syntax is <codeclass="language-plaintext highlighter-rouge">foreach (<symbol> in <expression>)</code>. <ul><li>new: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>procedure bingle begin
</code></pre></div></div></li><li>old: <divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>procedure bingle begin
</code></pre></div></div></li></ul><p>If you want an index array element (or key for “maps”) at each iteration, use syntax: <codeclass="language-plaintext highlighter-rouge">foreach (<symbol>: <symbol> in <expression>)</code></p><divclass="language-plaintext highlighter-rouge"><divclass="highlight"><preclass="highlight"><code>foreach (pid: price in itemPriceMap) begin
</code></pre></div></div><p>If you want to add additional condition for continuing the loop, use syntax: <codeclass="language-plaintext highlighter-rouge">foreach (<symbol> in <expression> while <expression>)</code>. In this case loop will iterate over elements of an array until last element or until “while” expression is true (whatever comes first).</p><p><strong>NOTE:</strong> Just like <codeclass="language-plaintext highlighter-rouge">for</code> loop, <codeclass="language-plaintext highlighter-rouge">continue</code> statement will respect increments of a hidden counter variable, so you can safely use it inside <codeclass="language-plaintext highlighter-rouge">foreach</code>.</p></li></ul><h2id="fixes"><ahref="#fixes"class="anchor-heading"aria-labelledby="fixes"><svgviewBox="0 0 16 16"aria-hidden="true"><usexlink:href="#svg-link"></use></svg></a> Fixes </h2><ul><li><codeclass="language-plaintext highlighter-rouge">playmoviealpharect</code> was using the token for <codeclass="language-plaintext highlighter-rouge">playmoviealpha</code>, breaking both functions in the process.</li><li><codeclass="language-plaintext highlighter-rouge">addbuttonflag</code> had an entry in the token table, and could be parsed, but was missing an entry in the emit list. This resulted in the compiler accepting it as a valid function, but not outputting any code for it into the compiled script.</li><li>The function <codeclass="language-plaintext highlighter-rouge">tokenize</code> was missing an entry in the token table, and so would not be recognised by the compiler.</li><li>Fixed the check for the <codeclass="language-plaintext highlighter-rouge">call "foo"</code> syntax so that non-string constants will no longer be accepted.</li></ul><h2id="backward-compatibility"><ahref="#backward-compatibility"class="anchor-heading"aria-labelledby="backward-compatibility"><svgviewBox="0 0 16 16"aria-hidden="true"><usexlink:href="#svg-link"></use></svg></a> Backward compatibility </h2><p>There are several changes in this version of sslc which may result in problems for previously working scripts. A new command line option <codeclass="language-plaintext highlighter-rouge">-b</code> is available, which will turn off all new fixes and features which have the possibility of causing a previously compiling script to change its behaviour. (And only those features; anything which would not compile under the old sslc is not affected.) This includes the following:</p><ul><li>Since <codeclass="language-plaintext highlighter-rouge">for</code>, <codeclass="language-plaintext highlighter-rouge">foreach</code>, <codeclass="language-plaintext highlighter-rouge">break</code>, <codeclass="language-plaintext highlighter-rouge">continue</code>, <codeclass="language-plaintext highlighter-rouge">in</code> and <codeclass="language-plaintext highlighter-rouge">tokenize</code> are now hardcoded names, existing scripts that use any of them as a variable or procedure name will no longer compile.</li><li>Missing a semicolon after a variable declaration is now a hard error. (Originally sslc would check for the semicolon, but would not complain if it was missing.)</li><li>The function <codeclass="language-plaintext highlighter-rouge">addbuttonflag</code> used to be recognised by the compiler, but would not emit any code into the int file.</li><li>The function <codeclass="language-plaintext highlighter-rouge">playmoviealpharect</code> compiled as <codeclass="language-plaintext highlighter-rouge">playmoviealpha</code>.</li></ul><h2id="int2ssl-note"><ahref="#int2ssl-note"class="anchor-heading"aria-labelledby="int2ssl-note"><svgviewBox="0 0 16 16"aria-hidden="true"><usexlink:href="#svg-link"></use></svg></a> int2ssl note </h2><p><strong>int2ssl</strong> by Anchorite (TeamX) is included in sfall modderspack package. It was updated to support all additional opcodes of sfall, along with some syntax features. You can use it to decompile any sfall or non-sfall script.</p></main></div></div><divclass="sea