Category:S-lang: Difference between revisions
Content added Content deleted
mNo edit summary |
No edit summary |
||
Line 16: | Line 16: | ||
function. This is not part of S-Lang per se, but is normally |
function. This is not part of S-Lang per se, but is normally |
||
included in the S-Lang shell "slsh". If it is missing, or you're |
included in the S-Lang shell "slsh". If it is missing, or you're |
||
using some other S-Lang environment, options include |
using some other S-Lang environment, options include C-like fputs(), |
||
sprintf() and printf(). Their format and parameters work about |
sprintf() and printf(). Their format and parameters work about |
||
like you'd expect in a C-inspired interpreted language. |
like you'd expect in a C-inspired interpreted language. |
||
Line 22: | Line 22: | ||
<code>sprintf(f, d..)</code> [f=string format, d..=zero or more data items] |
<code>sprintf(f, d..)</code> [f=string format, d..=zero or more data items] |
||
returns a string. <code>printf(f, d..)</code> prints to "stdout" and returns |
returns a string. <code>printf(f, d..)</code> prints to "stdout" and returns |
||
the number of items formatted |
the number of items formatted. <code>fputs(s, fp)</code> prints string s to the |
||
file-pointer fp and returns the string length or -1 on error. Remember S-Lang is a "stack |
|||
language", so even if you don't care about |
language", so even if you don't care about the return value, your code |
||
should "eat" it: |
should "eat" it: |
||
() = printf("S-Lang: %d tasks and counting!\n", 17); |
() = printf("S-Lang: %d tasks and counting!\n", 17); |
||
() = fputs("foo\n", stdout); |
|||
S-Lang is the extension language for the lightweight Emacs-like |
S-Lang is the extension language for the lightweight Emacs-like |
||
[http://www.jedsoft.org/jed/ programmer's editor Jed]. There, the |
[http://www.jedsoft.org/jed/ programmer's editor Jed]. There, the |