a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <?xml version='1.0' encoding='utf-8'?>
<autodoc>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <namespace name='c'>
<docgroup homogen-name='IS_ZERO' homogen-type='method'>
<method name='IS_ZERO'/><doc placeholder='true'>
<text>
<p><tt>IS_ZERO</tt> - is this svalue considered 'false'</p>
<tt><p>#include <simulate.h><br/>
</p>
<p>int IS_ZERO(struct svalue *<i>s</i>);<br/>
</p>
</tt>
<p>IS_ZERO returns true if the svalue 's' is a zero. (or an object with
`! operator that returned true..)</p>
</text>
<group><note/><text>
<p>IS_ZERO is actually a macro</p>
svalue</text></group>
<group><seealso/><text>
<p><ref resolved='c::is_eq' to='is_eq'>is_eq</ref>, <ref resolved='c::is_equal' to='is_equal'>is_equal</ref> and <ref resolved='c::is_lt' to='is_lt'>is_lt</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='add_shared_strings' homogen-type='method'>
<method name='add_shared_strings'/><doc placeholder='true'>
<text>
<p><tt>add_shared_strings</tt> - add two pike strings</p>
<tt><p>#include "stralloc.h"<br/>
</p>
<p>struct pike_string *add_shared_strings(struct pike_string *a,<br/>
<dl><group><text>struct pike_string *b);<br/>
</text></group></dl></p>
</tt>
<p>This function builds the string a+b, that is the string a with the
string b appended to it. Note that the string returned will have
an extra reference.</p>
pike_string</text>
<group><seealso/><text>
<p><ref resolved='c::begin_shared_string' to='begin_shared_string'>begin_shared_string</ref> and <ref resolved='c::make_shared_string' to='make_shared_string'>make_shared_string</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='allocate_array' homogen-type='method'>
<method name='allocate_array'/><doc placeholder='true'>
<text>
<p><tt>allocate_array</tt> - allocate an array</p>
<tt><p>#include "array.h"<br/>
</p>
<p>struct array *allocate_array(INT32 <i>size</i>);<br/>
</p>
</tt>
<p>This function allocates an array of size 'size'. The returned
array will have 'size' struct svalues in the member 'item'.
The array can contain any svalue, and the type field will be
initalized to -1.</p>
</text>
<group><note/><text>
<p>When building arrays, it is recommended that you push the values
on the stack and call aggregate_array or f_aggregate instead of
allocating and filling in the values 'by hand'.</p>
array</text></group>
</doc>
</docgroup>
<docgroup homogen-name='array' homogen-type='method'>
<method name='array'/><doc placeholder='true'>
<text>
<p><tt>array</tt> - the internal representation of an array</p>
<p>A Pike array is represented as a 'struct array' with all the
needed svalues malloced in the same block. The relevant members
are:
</p>
<p><matrix>
<r><c> refs </c><c> reference count </c></r>
<r><c> size </c><c> the number of svalues in the array </c></r>
<r><c> malloced_size </c><c> the number of svalues that can fit in this block </c></r>
<r><c> type_field </c><c> a bitfield indicating what types the array contains </c></r>
<r><c> item </c><c> the array of svalues </c></r>
</matrix>
</p>
</text>
<group><seealso/><text>
<p><ref resolved='c::type_field' to='type_field'>type_field</ref></p>
internals</text></group>
</doc>
</docgroup>
<docgroup homogen-name='array_index' homogen-type='method'>
<method name='array_index'/><doc placeholder='true'>
<text>
<p><tt>array_index</tt> - get an index from an array</p>
<tt><p>#include "array.h"<br/>
</p>
<p>void array_index(struct svalue *<i>to</i>, struct array *<i>a</i>, INT32 <i>n</i>);<br/>
</p>
</tt>
<p>This function frees the contents of the svalue 'to' and replaces
it with a copy of the contents from index 'n' in the array 'a'.
Basically, what it does is:
</p>
<p><matrix>
<r><c> </c><c> assign_svalue(to, a->item + n); </c></r>
<r><c> </c></r>
</matrix>
</p>
<p>The only differance is that it adds some debug and safety
measures. Usually you don't really need to use this function.</p>
</text>
<group><note/><text>
<p>If n is out of bounds (n < 0 or n >= a->size) Pike will dump
core. If Pike was compiled with DEBUG, a message will be written
first stating what the problem was.</p>
</text></group>
<group><seealso/><text>
<p><ref resolved='c::assign_svalue' to='assign_svalue'>assign_svalue</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='assign_svalue' homogen-type='method'>
<method name='assign_svalue'/><doc placeholder='true'>
<text>
<p><tt>assign_svalue</tt> - copy svalues from one place to another</p>
<tt><p>#include <svalue.h><br/>
</p>
<p>void assign_svalue(struct svale *<i>to</i>, struct svalue *<i>from</i>);<br/>
</p>
</tt>
<p>This function copies an svalue from one struct svalue to another.
It frees the contents of 'to' first and updates the involved
refcounts.</p>
svalue</text>
<group><seealso/><text>
<p><ref resolved='c::free_svalue' to='free_svalue'>free_svalue</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='begin_shared_string' homogen-type='method'>
<method name='begin_shared_string'/><doc placeholder='true'>
<text>
<p><tt>begin_shared_string</tt> - allocate space for a shared string</p>
<tt><p>#include "stralloc.h"<br/>
</p>
<p>struct pike_string *begin_shared_string(INT32 <i>len</i>);<br/>
</p>
</tt>
<p>This function allocates space for a shared string of length 'len'.
You should then MEMCPY 'len' bytes into the s->str. (s being the
returned value) And then call end_shared_string.</p>
pike_string</text>
<group><seealso/><text>
<p><ref resolved='c::end_shared_string' to='end_shared_string'>end_shared_string</ref> and <ref resolved='c::make_shared_string' to='make_shared_string'>make_shared_string</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='binary_findstring' homogen-type='method'>
<method name='binary_findstring'/><doc placeholder='true'>
<text>
<p><tt>binary_findstring</tt> - find a string</p>
<tt><p>#include "stralloc.h"<br/>
</p>
<p>struct pike_string *binary_findstring(char *<i>str</i>, INT32 <i>length</i>);<br/>
</p>
</tt>
<p>This function looks for the 'str' with length 'len' in the
global hash table. It returns the shared string if found, otherwise
zero. It does not increase/decrease the references to the string.</p>
pike_string</text>
<group><seealso/><text>
<p><ref resolved='c::findstring' to='findstring'>findstring</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='copy_mapping' homogen-type='method'>
<method name='copy_mapping'/><doc placeholder='true'>
<text>
<p><tt>copy_mapping</tt> - copy a mapping</p>
<tt><p>#include "mapping.h"<br/>
</p>
<p>struct mapping *copy_mapping(struct mapping *m)<br/>
</p>
</tt>
<p>This function returns a copy of the mapping m. If you change the
contents of the new mapping the contents of the mapping m will not
change. Note that this function is not recursive.</p>
mapping</text>
</doc>
</docgroup>
<docgroup homogen-name='end_shared_string' homogen-type='method'>
<method name='end_shared_string'/><doc placeholder='true'>
<text>
<p><tt>end_shared_string</tt> - link a shared string into the hashtable</p>
<tt><p>#include "stralloc.h"<br/>
</p>
<p>struct pike_string *end_shared_string(struct pike_string *<i>p</i>);<br/>
</p>
</tt>
<p>This function the prepared output from a begin_shared_string and
links the string into the hash table. If an identical string is
already present in the hash table, p is freed and that string is
returned instead. The returned string will have one extra reference
added.</p>
</text>
<group><example/><text>
<tt><p>#include "global.h"<br/>
#include "stralloc.h"<br/>
</p>
<p>struct pike_string *mkcharstring(int ch)<br/>
{<br/>
<dl><group><text>struct pike_string *ret;<br/>
ret=begin_shared_string(1);<br/>
ret->str[0]=ch;<br/>
return end_shared_string(ret);<br/>
</text></group></dl>}<br/>
</p>
</tt>
pike_string</text></group>
<group><seealso/><text>
<p><ref resolved='c::begin_shared_string' to='begin_shared_string'>begin_shared_string</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='error' homogen-type='method'>
<method name='error'/><doc placeholder='true'>
<text>
<p><tt>error</tt> - throw an error</p>
<tt><p>#include "error.h"<br/>
</p>
<p>void error(char *<i>format_string</i>, ...);<br/>
</p>
</tt>
<p>This function takes the same kind of arguments as printf, puts it
all together to a string and throws this as an error message
togehter with a backtrace that tells the catcher where the error
was. Note that this function does _not_ return. Instead it calls
the C function lonjump and continues executing from the most
resent active catch() call.</p>
internals</text>
</doc>
</docgroup>
<docgroup homogen-name='fatal' homogen-type='method'>
<method name='fatal'/><doc placeholder='true'>
<text>
<p><tt>fatal</tt> - print a message and dump core</p>
<tt><p>#include "error.h"<br/>
</p>
<p>void fatal(char *<i>format_string</i>, ...);<br/>
</p>
</tt>
<p>This function takes the same type of argument as 'printf', and
prints these with any available debug information. (A trace of
the 512 last executed instructions if you compiled with DEBUG.)
Then it forces the driver to dump core so you can examine the
bug with a debugger. Use with extreme caution, an error() might
sometimes be a lot better...</p>
internal</text>
<group><seealso/><text>
<p><ref resolved='c::error' to='error'>error</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='findstring' homogen-type='method'>
<method name='findstring'/><doc placeholder='true'>
<text>
<p><tt>findstring</tt> - find a string</p>
<tt><p>#include "stralloc.h"<br/>
</p>
<p>struct pike_string *findstring(char *<i>str</i>);<br/>
</p>
</tt>
<p>This function looks for the null terminated C string 'str' in the
global hash table. It returns the shared string if found, otherwise
zero. It does not increase/decrease the references to the string.</p>
pike_string</text>
<group><seealso/><text>
<p><ref resolved='c::make_shared_string' to='make_shared_string'>make_shared_string</ref> and <ref resolved='c::binary_findstring' to='binary_findstring'>binary_findstring</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='frame' homogen-type='method'>
<method name='frame'/><doc placeholder='true'>
<text>
<p><tt>frame</tt> - the current frame of exectution</p>
<p>The frame pointer is called 'fp' and is of type 'struct frame'.
The frame pointer contains information about what function we
are executing in, what is the current object, the current program,
where the local variables are etc. It also contains a pointer to
the previous frame in the call stack. The most important members
of 'fp' are:
</p>
<p><matrix>
<r><c> current_object </c><c> same as the Pike function this_object() </c></r>
<r><c> context.program </c><c> the program in which this function resides </c></r>
<r><c> current_storage </c><c> a 'char *' pointer into the data area for this </c></r>
</matrix>
<dl><group><text><matrix>
<r><c> </c><c> object. This is the pointer to the area reserved </c></r>
<r><c> </c></r>
</matrix>
<dl><group><text><matrix>
<r><c> </c><c> for you if you have done add_storage() earlier. </c></r>
<r><c> </c></r>
</matrix>
</text></group></dl></text></group></dl></p>
internals</text>
</doc>
</docgroup>
<docgroup homogen-name='free_array' homogen-type='method'>
<method name='free_array'/><doc placeholder='true'>
<text>
<p><tt>free_array</tt> - free one reference to a array</p>
<tt><p>#include "array.h"<br/>
</p>
<p>void free_array(struct array *a)<br/>
</p>
</tt>
<p>This function frees one reference to the array a. If the reference
is the last reference to the array, it will free the memory used
by the array a.</p>
</text>
<group><note/><text>
<p>free_array is a macro</p>
array</text></group>
</doc>
</docgroup>
<docgroup homogen-name='free_mapping' homogen-type='method'>
<method name='free_mapping'/><doc placeholder='true'>
<text>
<p><tt>free_mapping</tt> - free one reference to a mapping</p>
<tt><p>#include "mapping.h"<br/>
</p>
<p>void free_mapping(struct mapping *m)<br/>
</p>
</tt>
<p>This function frees one reference to the mapping m. If the reference
is the last reference to the mapping, it will free the memory used
by the mapping m.</p>
</text>
<group><note/><text>
<p>free_mapping is a macro</p>
mapping</text></group>
</doc>
</docgroup>
<docgroup homogen-name='free_string' homogen-type='method'>
<method name='free_string'/><doc placeholder='true'>
<text>
<p><tt>free_string</tt> - free a pike string</p>
<tt><p>#include "stralloc.h"<br/>
</p>
<p>void free_string(struct pike_string *p)<br/>
</p>
</tt>
<p>This function frees the string 'p'. What it actually does is that it
decreases the reference count of 'p' and frees the memory reserved
for it if the refereneces reach zero.</p>
</text>
<group><note/><text>
<p>free_string is actually a macro</p>
pike_string</text></group>
</doc>
</docgroup>
<docgroup homogen-name='free_svalue' homogen-type='method'>
<method name='free_svalue'/><doc placeholder='true'>
<text>
<p><tt>free_svalue</tt> - free the contents of an svalue</p>
<tt><p>#include <svalue.h><br/>
</p>
<p>void free_svalue(struct svalue *<i>s</i>);<br/>
</p>
</tt>
<p>This function frees the contents of an svalue with respect to
ref counts. It does not however free the storage for svalue itself.
That is up to the caller to do.</p>
svalue</text>
<group><seealso/><text>
<p><ref resolved='c::assign_svalue' to='assign_svalue'>assign_svalue</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='is_eq' homogen-type='method'>
<method name='is_eq'/><doc placeholder='true'>
<text>
<p><tt>is_eq</tt> - compare two svalues</p>
<tt><p>#include <svalue.h><br/>
</p>
<p>int is_eq(struct svalue *<i>a</i>, struct svalue *<i>b</i>);<br/>
</p>
</tt>
<p>This is the equivialent of the Pike operator `==. It compares two
svalues and returns one if they are the same. Otherwise zero.</p>
svalue</text>
<group><seealso/><text>
<p><ref resolved='c::is_equal' to='is_equal'>is_equal</ref>, <ref resolved='c::is_lt' to='is_lt'>is_lt</ref> and <ref resolved='c::IS_ZERO' to='IS_ZERO'>IS_ZERO</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='is_equal' homogen-type='method'>
<method name='is_equal'/><doc placeholder='true'>
<text>
<p><tt>is_equal</tt> - compare two svalues recursively</p>
<tt><p>#include <svalue.h><br/>
</p>
<p>int is_equal(struct svalue *<i>a</i>, struct svalue *<i>b</i>);<br/>
</p>
</tt>
<p>This is the equivialent of the Pike function equal(), it compares
two svalues recursively and returns 1 if their contents are equal,
zero otherwise.</p>
svalue</text>
<group><seealso/><text>
<p><ref resolved='c::is_eq' to='is_eq'>is_eq</ref>, <ref resolved='c::is_lt' to='is_lt'>is_lt</ref> and <ref resolved='c::IS_ZERO' to='IS_ZERO'>IS_ZERO</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='is_lt' homogen-type='method'>
<method name='is_lt'/><doc placeholder='true'>
<text>
<p><tt>is_lt</tt> - compare two svalues</p>
<tt><p>#include <svalue.h><br/>
</p>
<p>int is_lt(struct svalue *<i>a</i>, struct svalue *<i>b</i>);<br/>
</p>
</tt>
<p>This is the equivialent of the Pike operator `<. It compares the
contents of two svalues and returns true if the 'a' is lesser than
'b'. It will give an error if the types are not comparable.</p>
</text>
<group><note/><text>
<p>is_gt, is_ge and is_le are also available. They are all macros that
call this function.</p>
svalue</text></group>
<group><seealso/><text>
<p><ref resolved='c::is_eq' to='is_eq'>is_eq</ref> and <ref resolved='c::is_equal' to='is_equal'>is_equal</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='low_mapping_lookup' homogen-type='method'>
<method name='low_mapping_lookup'/><doc placeholder='true'>
<text>
<p><tt>low_mapping_lookup</tt> - lookup a key in a mapping</p>
<tt><p>#include "mapping.h"<br/>
</p>
<p>struct svalue *low_mapping_lookup(struct mapping *m,<br/>
<dl><group><text>struct svalue *key);<br/>
</text></group></dl></p>
</tt>
<p>This function looks up the key-index pair that has the key 'key' in
the mapping 'm' and returns a pointer to the 'value'. If no such
key-index pair is found, zero is returned.</p>
</text>
<group><note/><text>
<p>Any call to an internal Pike function may re-allocate the mapping
'm', which means that the pointer returned from this call is only
valid until your next function call.</p>
</text></group>
<group><note/><text>
<p>This function is intended for _reading_ mappings, it is forbidden
to change the contents of the returned svalue.</p>
mapping</text></group>
<group><seealso/><text>
<p><ref to='map_insert'>map_insert</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='m_sizeof' homogen-type='method'>
<method name='m_sizeof'/><doc placeholder='true'>
<text>
<p><tt>m_sizeof</tt> - return the number of key-value pairs in a mapping</p>
<tt><p>#include "mapping.h"<br/>
</p>
<p>int m_sizeof(struct mapping *m)<br/>
</p>
</tt>
<p>This function returns the number of key-index pairs in the mapping,
just like the function sizeof() in Pike.</p>
</text>
<group><note/><text>
<p>m_sizeof is a macro</p>
mapping</text></group>
</doc>
</docgroup>
<docgroup homogen-name='make_shared_binary_string' homogen-type='method'>
<method name='make_shared_binary_string'/><doc placeholder='true'>
<text>
<p><tt>make_shared_binary_string</tt> - make a shared string</p>
<tt><p>#include "stralloc.h"<br/>
</p>
<p>struct pike_string *make_shared_binary_string(const char *<i>str</i>, int <i>len</i>);<br/>
</p>
</tt>
<p>This function makes a shared string from the memory area beginning
at 'str' and ends at str+len. The returned string will have one
extra reference.</p>
pike_string</text>
<group><seealso/><text>
<p><ref resolved='c::make_shared_string' to='make_shared_string'>make_shared_string</ref>, <ref resolved='c::begin_shared_string' to='begin_shared_string'>begin_shared_string</ref>, <ref resolved='c::push_string' to='push_string'>push_string</ref> and <ref resolved='c::free_string' to='free_string'>free_string</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='make_shared_string' homogen-type='method'>
<method name='make_shared_string'/><doc placeholder='true'>
<text>
<p><tt>make_shared_string</tt> - make a shared string</p>
<tt><p>#include "stralloc.h"<br/>
</p>
<p>struct pike_string *make_shared_string(const char *<i>str</i>);<br/>
</p>
</tt>
<p>This function does the same thing as make_shared_binary_string, but
expects a zero terminated string instead.</p>
pike_string</text>
<group><seealso/><text>
<p><ref resolved='c::make_shared_binary_string' to='make_shared_binary_string'>make_shared_binary_string</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='map_delete' homogen-type='method'>
<method name='map_delete'/><doc placeholder='true'>
<text>
<p><tt>map_delete</tt> - delete an item from a mapping</p>
<tt><p>#include "mapping.h"<br/>
</p>
<p>void map_delete(struct mapping *<i>m</i>, struct svalue *<i>key</i>);<br/>
</p>
</tt>
<p>This function removes the key-index pair that has they key 'key'
from the mapping. If there is no such key-index pair in the mapping
nothing will be done.</p>
mapping</text>
<group><seealso/><text>
<p><ref resolved='c::mapping_insert' to='mapping_insert'>mapping_insert</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='mapping' homogen-type='method'>
<method name='mapping'/><doc placeholder='true'>
<text>
<p><tt>mapping</tt> - internal pike mappings</p>
<p>'struct mapping' is the C representation of a Pike mapping. The struct
itself contains no user servicable parts except for the member 'refs'
which has to be increased when putting a 'struct mapping *' into a
svalue. Never _ever_ decrease the ref counter manually, use
free_mapping instead. Also note that you should never ever allocate
a mapping statically, you should always use the functions provided by
pike to allocate mappings.
</p>
<p>A mapping is basically a hash table with a linked list of key-value
pairs in each hash bin. The hash table and the key-index pairs are
allocated together in one large block to minimize memory fragmentation.
Also note that whenever you search for a specific key-value pair in
the mapping that key-value pair is propagated to the top of the linked
list in that hash bin, which makes the search time very very small for
most cases.</p>
internals</text>
</doc>
</docgroup>
<docgroup homogen-name='mapping_indices' homogen-type='method'>
<method name='mapping_indices'/><doc placeholder='true'>
<text>
<p><tt>mapping_indices</tt> - return all the keys from a mapping</p>
<tt><p>#include "mapping.h"<br/>
</p>
<p>struct array *mapping_indices(struct mapping *m)<br/>
</p>
</tt>
<p>This function returns an array with all the keys from the mapping m.
The keys in the array are ordered in the same order as the values
when using mapping_values. But only if no other mapping operations
are done in between.</p>
mapping</text>
<group><seealso/><text>
<p><ref resolved='c::mapping_values' to='mapping_values'>mapping_values</ref> and <ref resolved='c::mkmapping' to='mkmapping'>mkmapping</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='mapping_insert' homogen-type='method'>
<method name='mapping_insert'/><doc placeholder='true'>
<text>
<p><tt>mapping_insert</tt> - insert a key-value pair into a mapping</p>
<tt><p>#include "mapping.h"<br/>
</p>
<p>void mapping_insert(struct mapping *m,<br/>
<dl><group><text>struct svalue *key,<br/>
struct svalue *value)<br/>
</text></group></dl></p>
</tt>
<p>This function inserts a new key-value pair into the mapping m.
If there is a already key-value pair with the same key in the mapping
it will be replaced with the new key-value pair. If there isn't
such a key-value pair in the mapping the mapping will grow in size
to accomodate the new key-value pair. This is identical to the
Pike operation: m[key]=value</p>
mapping</text>
<group><seealso/><text>
<p><ref resolved='c::map_delete' to='map_delete'>map_delete</ref> and <ref resolved='c::low_mapping_lookup' to='low_mapping_lookup'>low_mapping_lookup</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='mapping_replace' homogen-type='method'>
<method name='mapping_replace'/><doc placeholder='true'>
<text>
<p><tt>mapping_replace</tt> - replace values in a mapping</p>
<tt><p>#include "mapping.h"<br/>
</p>
<p>void mapping_replace(struct mapping *m,<br/>
<dl><group><text>struct svalue *from,<br/>
struct svalue *to)<br/>
</text></group></dl></p>
</tt>
<p>This function replaces all values of the value 'from' in the mapping
'm' with 'to'. It is a part of the Pike function replace().</p>
mapping</text>
</doc>
</docgroup>
<docgroup homogen-name='mapping_values' homogen-type='method'>
<method name='mapping_values'/><doc placeholder='true'>
<text>
<p><tt>mapping_values</tt> - return all the values from a mapping</p>
<tt><p>#include "mapping.h"<br/>
</p>
<p>struct array *mapping_values(struct mapping *m)<br/>
</p>
</tt>
<p>This function returns an array with all the values from the mapping m.
The values in the array are ordered in the same order as the keys
when using mapping_indices, but only if no other mapping operations
are done between the mapping_values and the mapping_indices.</p>
</text>
<group><example/><text>
<tt><p>struct mapping *slow_copy_mapping(struct mapping *m)<br/>
{<br/>
<dl><group><text>struct array *indices, *values;<br/>
indices=mapping_indices(m);<br/>
values=mapping_indices(m);<br/>
m=mkmapping(indices,values);<br/>
free_array(indices);<br/>
free_array(values);<br/>
return m;<br/>
</text></group></dl>}<br/>
</p>
</tt>
mapping</text></group>
<group><seealso/><text>
<p><ref resolved='c::mapping_indices' to='mapping_indices'>mapping_indices</ref>, <ref resolved='c::copy_mapping' to='copy_mapping'>copy_mapping</ref> and <ref resolved='c::mkmapping' to='mkmapping'>mkmapping</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='mkmapping' homogen-type='method'>
<method name='mkmapping'/><doc placeholder='true'>
<text>
<p><tt>mkmapping</tt> - make a mapping</p>
<tt><p>#include <mapping.h><br/>
</p>
<p>struct mapping *mkmapping(struct array *keys, struct array *values)<br/>
</p>
</tt>
<p>This function is the same as the Pike function mkmapping. It
makes a mapping out of an array of keys and an array of values.
Note that the returned mapping will have one extra reference.</p>
mapping</text>
<group><seealso/><text>
<p><ref resolved='c::mapping_indices' to='mapping_indices'>mapping_indices</ref> and <ref resolved='c::mapping_values' to='mapping_values'>mapping_values</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='my_strcmp' homogen-type='method'>
<method name='my_strcmp'/><doc placeholder='true'>
<text>
<p><tt>my_strcmp</tt> - my own strcmp function</p>
<tt><p>#include "stralloc.h"<br/>
</p>
<p>int my_strcmp(struct pike_string *a, struct pike_string *b)<br/>
</p>
</tt>
<p>This function compares two pike strings and takes locales into
account if the system supports locales. It returns zero if the
strings are the same, a number greater than zero zero if 'a'
is greater than 'b', and a number below zero otherwise.</p>
pike_string</text>
<group><seealso/><text>
<p><ref resolved='c::make_shared_string' to='make_shared_string'>make_shared_string</ref></p>
</text></group>
|
6be003 | 1996-11-03 | Mirar (Pontus Hagland) | | </doc>
</docgroup>
<docgroup homogen-name='object' homogen-type='method'>
<method name='object'/><doc placeholder='true'>
<text>
<p><tt>object</tt> - internal representation of an object</p>
<p>Pike uses a 'struct object' with all the global variables
allocated in the same block to represent the Pike type 'object'.
An object without any global variables is only the size of 4 C
pointers. (usually 16 bytes) The only important members of the
'struct object' are the ref counts and the pointer to the
program from which the object was cloned.</p>
internals</text>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='pike_string' homogen-type='method'>
<method name='pike_string'/><doc placeholder='true'>
<text>
<p><tt>pike_string</tt> - internal pike shared strings</p>
<p>This is the internal type for representing pike strings. They have
ref counts and they are shared though a global hash table. The C
type is a struct pike_string that has two public members: str and
len. str is an array of char which contain the actual string. It
is guaranteed that the string is null terminated, but the string
can also contain zeroes before the end. len is of course the
length of the string. Since strings are shared you may _never_
modify the contents of a string, except for adding/subtracting
references when approperiate. The only exception to this is when
creating a new shared string with begin_shared_string which has
not yet been linked to the hash table with end_shared_string.</p>
internals</text>
</doc>
</docgroup>
<docgroup homogen-name='program' homogen-type='method'>
<method name='program'/><doc placeholder='true'>
<text>
<p><tt>program</tt> - internal representation of a program</p>
<p>A 'struct program' is basically what C++ hackers call a 'class'.
It contains the byte code, information about line numbers,
global variables etc. etc. Mostly you won't have to bother with
any of the contents of a 'struct program'. Usually you only need
to create them with start_new_program()/end_c_program() or
clone them with clone().</p>
</text>
<group><seealso/><text>
<p><ref resolved='c::frame' to='frame'>frame</ref></p>
internal</text></group>
</doc>
</docgroup>
<docgroup homogen-name='push_string' homogen-type='method'>
<method name='push_string'/><doc placeholder='true'>
<text>
<p><tt>push_string</tt> - push a string on the pike stack</p>
<tt><p>#include "interpret.h"<br/>
</p>
<p>void push_string(struct pike_string *p)<br/>
</p>
</tt>
<p><matrix>
<r><c> This function pushes the string p on the pike stack. Note that this </c></r>
<r><c> function does _not_ add any extra references to 'p'. Most functions </c></r>
<r><c> that create shared strings give one extra reference to them though. </c></r>
<r><c> If you get your string from a function that does not add extra </c><c> </c></r>
<r><c> references you will have to add a reference manually. </c></r>
</matrix>
</p>
</text>
<group><note/><text>
<p>push_string is actually a macro</p>
pike_string</text></group>
</doc>
</docgroup>
<docgroup homogen-name='string_replace' homogen-type='method'>
<method name='string_replace'/><doc placeholder='true'>
<text>
<p><tt>string_replace</tt> - do string replacements</p>
<tt><p>#include "stralloc.h"<br/>
</p>
<p>struct pike_string *string_replace(struct pike_string *str,<br/>
<dl><group><text>struct pike_string *from,<br/>
struct pike_string *to);<br/>
</text></group></dl></p>
</tt>
<p>This function builds a new string from 'str' with all occurances
of 'from' replaced by 'to'. Note that the new string will have one
extra reference.</p>
pike_string</text>
</doc>
</docgroup>
<docgroup homogen-name='svalue' homogen-type='method'>
<method name='svalue'/><doc placeholder='true'>
<text>
<p><tt>svalue</tt> - internal type for storing Pike values</p>
<p>The 'struct svalue' contains one Pike 'value', variables, arrays
and the evaluator are all svalues. An svalue consists of three
elements: type, subtype and a union containing the actual value.
The type is a short which tells you what type the svalue is. The
value is one of the following:
</p>
<p><matrix>
<r><c> T_ARRAY </c><c> When type is T_ARRAY, the array is stored in </c></r>
<r><c> </c></r>
</matrix>
<dl><group><text><matrix>
<r><c> </c><c> the 'array' member of the union. So if sval is </c></r>
<r><c> </c></r>
</matrix>
<matrix>
<r><c> </c><c> the pointer to the svalue, you would use sval->u.array </c></r>
<r><c> </c></r>
</matrix>
<matrix>
<r><c> </c><c> to access the actual array. </c></r>
<r><c> </c></r>
</matrix>
</text></group></dl><matrix>
<r><c> T_MAPPING </c><c> In this case, you use sval->u.mapping. </c></r>
<r><c> T_MULTISET </c><c> sval->u.multiset </c></r>
<r><c> T_OBJECT </c><c> sval->u.object </c></r>
<r><c> T_FUNCTION </c><c> Functions are a bit more difficult, sval->u.object </c></r>
</matrix>
<dl><group><text><matrix>
<r><c> </c><c> is the object the function is in, and sval->subtype </c></r>
<r><c> </c></r>
</matrix>
<matrix>
<r><c> </c><c> is the number of the function in that object. </c></r>
<r><c> </c></r>
</matrix>
</text></group></dl><matrix>
<r><c> T_PROGRAM </c><c> sval->u.program is the struct program you want. </c></r>
<r><c> T_STRING </c><c> sval->u.string </c></r>
<r><c> T_FLOAT </c><c> sval->u.float_number </c></r>
<r><c> T_INT </c><c> sval->u.integer, a special case is that sval->subtype </c></r>
</matrix>
<dl><group><text><matrix>
<r><c> </c><c> is used in some cases to represent the value </c></r>
<r><c> </c><c> 'undefined'. This is what zero_type detects. </c></r>
</matrix>
</text></group></dl>
</p>
<p>There are lots of functions operating on svalues, so you shouldn't
have to do all that much stuff with them yourself. However, for now
you do need to check the type and extract the proper member of the
union yourself when writing your own C functions for Pike.</p>
internals</text>
</doc>
</docgroup>
<docgroup homogen-name='type_field' homogen-type='method'>
<method name='type_field'/><doc placeholder='true'>
<text>
<p><tt>type_field</tt> - bit field used for optimizations</p>
<p>Type fields are used by arrays, mappings and some svalue operations
for optimization. The type field consists of OR:ed bits, one for
each type. The bit for an array is 1<<T_ARRAY (same as BIT_ARRAY)
The bit for a string is 1<<T_STRING (or BIT_STRING) etc.
</p>
<p>A bit field never has to be exact, it needs to have at least those
bits that are present in the operation. It is never harmful to have
too many bits though. It seldom pays off to calculate the bit field
explicitly, so if you don't know what types are involved you should
use -1 for the type field.</p>
</text>
<group><seealso/><text>
<p><ref resolved='c::mapping' to='mapping'>mapping</ref>, <ref resolved='c::array' to='array'>array</ref> and <ref resolved='c::svalue' to='svalue'>svalue</ref></p>
</text></group>
</doc>
</docgroup>
</namespace>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | <namespace name='cpp'>
<doc placeholder='true'>
<text>
<p><tt>preprocessor</tt> - textually process code before compiling</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>Pike has a builtin C-style preprocessor. It works similar to old
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | C preprocessors but has a few extra features. This file describes
the different preprocessor directives.</p>
<tt><p><dl><group><text>#!<br/>
#define<br/>
#elif<br/>
#else<br/>
#elseif<br/>
#endif<br/>
#error<br/>
#if<br/>
#ifdef<br/>
#ifndef<br/>
#include<br/>
#line<br/>
#pragma<br/>
#undef<br/>
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | </text></group></dl></p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | pike</text>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
</doc>
<docgroup homogen-name='#!' homogen-type='directive'>
<directive name='#!'>
</directive>
<doc placeholder='true'>
<text>
<p>This directive is in effect a comment statement, since the
preprocessor will ignore everything to the end of the line.
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | This is used to write unix type scripts in Pike by starting
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | the script with
</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>#!/usr/local/bin/pike
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </p>
</text>
</doc>
</docgroup>
<docgroup homogen-name='#define' homogen-type='directive'>
<directive name='#define'>
</directive>
<doc placeholder='true'>
<text>
<p>The simplest way to use define is to write
</p>
<p><dl><group><text>#define <identifier> <replacement string><br/>
</text></group></dl>
</p>
<p>which will cause all subsequent occurances of 'identifier' to be
replaced with the replacement string.
</p>
<p>Define also has the capability to use arguments, thus a line like
</p>
<p><dl><group><text>#define <identifier>(arg1, arg2) <replacement string><br/>
</text></group></dl>
</p>
<p>would cause identifer to be a macro. All occurances of
'identifier(something1,something2d)' would be replaced with
the replacement string. And in the replacement string, arg1 and arg2
|
563f98 | 1996-08-15 | Fredrik Hübinette (Hubbe) | | will be replaced with something1 and something2.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </text>
|
563f98 | 1996-08-15 | Fredrik Hübinette (Hubbe) | | <group><bugs/><text>
<p>Note that it is not a good idea to do something like this:
</p>
<p>#define foo bar // a comment
</p>
<p>The comment will be included in the define, and thus inserted in the
code. This will have the effect that the rest of the line will be
ignored when the word foo is used. Not exactly what you might expect.
</p>
<p/>
</text></group>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-type='directive'>
<directive name='#if'>
</directive>
<directive name='#elif'>
</directive>
<directive name='#elseif'>
</directive>
<directive name='#else'>
</directive>
<directive name='#endif'>
</directive>
<doc placeholder='true'>
<text>
<p>The #if directive causes conditional compiling of code depending on
the expression after the #if directive. That is, if the expression
is true, the code up to the next #else, #elif, #elseif or #endif is
compiled. If the expression is false, that code will be skipped.
If the skip leads up to a #else, the code after the else will be
compiled. #elif and #elseif are equivialent and causes the code that
follow them to be compiled if the previous #if or #elif evaluated
false and the expression after the #elif evaluates true.
</p>
<p>Expressions given to #if, #elif or #endif are special, all identifiers
evaluate to zero unless they are defined to something else. Integers,
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | strings and floats are the only types that can be used, but all pike
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | operators can be used on these types.
</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>Also, two special functions can be used, defined() and constant().
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | defined(<identifer>) expands to '1' if the identifier is defined,
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | '0' otherwise. constant(<identifier>) expands to '1' if identifer is
an predefined constant (with add_constant), '0' otherwise.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </text>
<group><example/><text>
<tt><p>#if 1<br/>
<dl><group><text>write("foo");<br/>
</text></group></dl>#else<br/>
<dl><group><text>write("bar");<br/>
</text></group></dl>#endif<br/>
</p>
<p>#if defined(FOO)<br/>
<dl><group><text>write(FOO);<br/>
</text></group></dl>#elif defined(BAR)<br/>
<dl><group><text>write(BAR);<br/>
</text></group></dl>#else<br/>
<dl><group><text>write("default");<br/>
</text></group></dl>#endif<br/>
</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>#if !constant(write_file)<br/>
inherit "simulate.pike"<br/>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | #endif<br/>
<br/>
</p>
</tt></text></group>
</doc>
</docgroup>
<docgroup homogen-name='#error' homogen-type='directive'>
<directive name='#error'>
</directive>
<doc placeholder='true'>
<text>
<p>This directive causes a compiler error, it can be used to notify
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | the user that certain functions are missing and similar things.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </text>
<group><example/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#if !constant(write_file)<br/>
#error write_file efun is missing<br/>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | #endif<br/>
<br/>
</p>
</tt></text></group>
</doc>
</docgroup>
<docgroup homogen-name='#include' homogen-type='directive'>
<directive name='#include'>
</directive>
<doc placeholder='true'>
<text>
<p>This directive should be given a file as argument, it will then be
compiled as if all those lines were written at the #include line.
The compiler then continues to compile this file.</p>
</text>
<group><example/><text>
<tt><p>#include "foo.h"<br/>
<br/>
</p>
</tt></text></group>
</doc>
</docgroup>
<docgroup homogen-name='#line' homogen-type='directive'>
<directive name='#line'>
</directive>
<doc placeholder='true'>
<text>
<p>This directive tells the compiler what line and file we are compiling.
This is for instance used by the #include directive to tell the
compiler that we are compiling another file. The directive takes
the line number first, and optionally, the file afterwards.
</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This can also be used when generating pike from something else, to
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | tell teh compiler where the code originally originated from.</p>
</text>
<group><example/><text>
<tt><p>#line 4 "foo.cf" /* The next line was generated from 4 in foo.cf */<br/>
<br/>
</p>
</tt></text></group>
</doc>
</docgroup>
<docgroup homogen-name='#pragma' homogen-type='directive'>
<directive name='#pragma'>
</directive>
<doc placeholder='true'>
<text>
<p>This is a generic directive for flags to the compiler. Currently, the
only flag available is 'all_inline' which is the same as adding the
modifier 'inline' to all functions that follows.
</p>
</text>
</doc>
</docgroup>
<docgroup homogen-name='#undef' homogen-type='directive'>
<directive name='#undef'>
</directive>
<doc placeholder='true'>
<text>
<p>This removes the effect of a #define, all subsequent occurances of
the undefined identifier will not be replaced by anything. Note that
when undefining a macro, you just give the identifer, not the
arguments.</p>
</text>
<group><example/><text>
<tt><p>#define foo bar<br/>
#undef foo<br/>
#define foo(bar) gazonk bar<br/>
#undef foo<br/>
<br/>
</p>
</tt></text></group>
</doc>
</docgroup>
</namespace>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <namespace name='predef'>
|
94e6f4 | 1996-05-02 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='&&' homogen-type='method'>&&
<method name='&&'/>&&<doc placeholder='true'>
<text>
<p><tt>&&</tt> - logical and</p>
<tt><p>a && b<br/>
</p>
</tt>
<p>This operator does logical 'and' between expressions. It first
evaluates a and returns zero if a is zero. Otherwise it returns
b. Note that b is not evaluated at all if a returns zero.</p>
operators</text>
<group><seealso/><text>
<p><ref resolved='predef::`&' to='`&'>&&`&</ref> and <ref resolved='predef::&&' to='||'>&&||</ref></p>
</text></group>
</doc>
</docgroup>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='PI' homogen-type='constant'>
<constant name='PI'/><doc placeholder='true'>
<text>
<p><tt>PI</tt> - pi</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>PI<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This is not a function, it is a constant added by simulate.pike.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
float</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='_verify_internals' homogen-type='method'>
<method name='_verify_internals'/><doc placeholder='true'>
<text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>_verify_internals</tt> - check Pike internals</p>
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | |
<tt><p>void _verify_internals();<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | </tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function goes through most of the internal Pike structures and
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | generates a fatal error if one of them is found to be out of order.
It is only used for debugging.</p>
debugging</text>
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='`!' homogen-type='method'>
<method name='`!'/><doc placeholder='true'>
<text>
<p><tt>`!</tt> - is not true</p>
<tt><p>! a<br/>
or<br/>
int `!(mixed a)<br/>
</p>
</tt>
<p>Returns 1 if a is zero, 0 otherwise.</p>
operators</text>
</doc>
</docgroup>
<docgroup homogen-name='`!=' homogen-type='method'>
<method name='`!='/><doc placeholder='true'>
<text>
<p><tt>`!=</tt> - check if not equal</p>
<tt><p>a != b<br/>
or<br/>
int `!=(mixed a, mixed b)<br/>
</p>
</tt>
<p>This operator compares two values and returns 0 if they are the same,
1 otherwise. Note that pointer equivialenec is required for arrays,
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | objects, programs, mappings and multisets. (Thus it is not enough that
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | two arrays LOOK alike, it must be the same array.)</p>
operators</text>
<group><seealso/><text>
<p><ref resolved='predef::`==' to='`=='>`==</ref>, <ref resolved='predef::`<' to='`<'><<`<</ref>, <ref resolved='predef::`>' to='`>'>>>`></ref>, <ref resolved='predef::`<=' to='`<='><<`<=</ref>, <ref resolved='predef::`>=' to='`>='>>>`>=</ref> and <ref to='efuns/equal'>efuns/equal</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='`%' homogen-type='method'>
<method name='`%'/><doc placeholder='true'>
<text>
<p><tt>`%</tt> - modulo</p>
<tt><p>a % b<br/>
or<br/>
int `%(int a, int b)<br/>
or<br/>
float `%(int|float a,int|float b)<br/>
</p>
</tt>
<p>This operator computes the rest of a division. For integers, this
is the same as same as computing a-(a/b)*a. For floats, modulo is
interpreted as a-floor(a/b)*a
</p>
</text>
<group><example/><text>
<tt><p><matrix>
<r><c> 9%3 </c><c> returns 0 </c></r>
<r><c> 10%3 </c><c> returns 1 </c></r>
<r><c> 2%0.3 </c><c> returns 0.2 </c></r>
</matrix>
</p>
</tt>
operators</text></group>
<group><seealso/><text>
<p><ref resolved='predef::`/' to='`/'>`/</ref> and <ref resolved='predef::`*' to='`*'>`*</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='`&' homogen-type='method'>&
<method name='`&'/>&<doc placeholder='true'>
<text>
<p><tt>`&</tt> - intersection</p>
<tt><p>a & b<br/>
or<br/>
mixed `&(mixed ... args)<br/>
</p>
</tt>
<p>This operator does logical intersections. For ints this means
bitwise and.
</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>Arrays and multisets are treated as sets, so intersecting two arrays
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | will result in an array with containing all values present in all
arguments.
</p>
<p>For mappings, the intersection will be done on the indexes solely,
however, the values will be taken from the rightmost mapping.</p>
operators</text>
<group><seealso/><text>
|
94e6f4 | 1996-05-02 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::`|' to='`|'>`|</ref>, <ref resolved='predef::`^' to='`^'>`^</ref> and <ref resolved='predef::`&' to='&&'>&&&&&</ref></p>
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='`*' homogen-type='method'>
<method name='`*'/><doc placeholder='true'>
<text>
<p><tt>`*</tt> - multiplication</p>
<tt><p>a * b<br/>
or<br/>
int `*(int ... args)<br/>
or<br/>
float `*(int|float ... args)<br/>
or<br/>
string `*(string *strings, string delimeter)<br/>
</p>
</tt>
<p>For ints and floats, this operator simply multiplies its arguments.
If the first argument is an array, and the second a string, all
strings in the arrays will be concatenated, with the delimiter in
between each string and the result will be returned.</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | <group><example/><text>
<tt><p><matrix>
<r><c> 2*2 </c><c> returns 4 </c></r>
<r><c> 2.0*2.0 </c><c> returns 4.0 </c></r>
<r><c> 2.0*2 </c><c> returns 4.0 </c></r>
<r><c> ({"f","",""})*"o") </c><c> Returns "foo" </c></r>
<r><c> `*(2,2,2) </c><c> returns 8 </c></r>
</matrix>
</p>
</tt>
operators</text></group>
<group><seealso/><text>
<p><ref resolved='predef::`/' to='`/'>`/</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='`+' homogen-type='method'>
<method name='`+'/><doc placeholder='true'>
<text>
<p><tt>`+</tt> - add things together</p>
<tt><p>a + b<br/>
or<br/>
mixed `+(mixed ... args)<br/>
</p>
</tt>
<p>For ints and floats this operator simply adds the two operators
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | together. For strings and arrays, concatenation is done. For multisets
and mapping this creates a new multiset/mapping with all indices and data as
in a and b. Note that this can cause a multiset to contain
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | several equal indices. Also, when adding a string to an int or float
the number is converted to a printable string first.</p>
</text>
<group><example/><text>
<tt><p><matrix>
<r><c> "a"+10 </c><c> returns "a10" </c></r>
<r><c> 10+20 </c><c> returns 30 </c></r>
<r><c> ({1})+({2}) </c><c> returns ({1,2}) </c></r>
<r><c> (<1>)+(<1>) </c><c> returns (<1,1>) </c></r>
<r><c> `+(2,2,2) </c><c> returns 6 </c></r>
</matrix>
</p>
</tt>
operators</text></group>
<group><seealso/><text>
<p><ref resolved='predef::`-' to='`-'>`-</ref> and <ref resolved='predef::`*' to='`*'>`*</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='`-' homogen-type='method'>
<method name='`-'/><doc placeholder='true'>
<text>
<p><tt>`-</tt> - subtract/negate</p>
<tt><p>- a<br/>
or<br/>
`-(mixed <i>a</i>);<br/>
or<br/>
a - b<br/>
or<br/>
mixed `-(mixed a, mixed b)<br/>
</p>
</tt>
<p>This is the negation and subtraction operator, for ints and floats
the operation should be obvious.
</p>
<p>For arrays, an array containing all elements present in a and not in
b is returne. The order of the remaining values from a will be kept.
</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>For multisets, the same operation is done as for arrays, except order is
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | of course not considered.
</p>
<p><matrix>
<r><c> For mappings, a mapping is returned with every key-index pair from </c></r>
<r><c> a whos index is not present as an index in b. </c></r>
<r><c> EXAMPLES </c></r>
<r><c> 5-10 </c><c> returns -5 </c></r>
<r><c> 10-2.0 </c><c> returns 8.0 </c></r>
<r><c> ({1,2})-({2}) </c><c> returns ({1}) </c></r>
<r><c> ([1:2,2:1])-([1:0]) </c><c> returns ([2:1]) </c></r>
</matrix>
</p>
operators</text>
<group><seealso/><text>
<p><ref resolved='predef::`+' to='`+'>`+</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='`/' homogen-type='method'>
<method name='`/'/><doc placeholder='true'>
<text>
<p><tt>`/</tt> - division</p>
<tt><p>a / b<br/>
or<br/>
int `/(int a, int b)<br/>
or<br/>
float `/(int|float a,int|float b)<br/>
or<br/>
string* `/(string a,string b)<br/>
</p>
</tt>
<p>For ints and floats, this operator simply divide its arguments.
If the arguments are strings, the first string will be divided
at every occurance of the second string. The resulting pieces
are then returned in the form of an array.</p>
</text>
<group><example/><text>
<tt><p><matrix>
<r><c> 2/2 </c><c> returns 1 </c></r>
<r><c> 3/2 </c><c> returns 1 </c></r>
<r><c> 2.0/2.0 </c><c> returns 1.0 </c></r>
<r><c> 2.0/2 </c><c> returns 1.0 </c></r>
<r><c> "foo"/"o" </c><c> returns ({"f","",""}) </c></r>
<r><c> `/(2,2) </c><c> returns 1 </c></r>
</matrix>
</p>
</tt>
operators</text></group>
<group><seealso/><text>
<p><ref resolved='predef::`*' to='`*'>`*</ref> and <ref resolved='predef::`%' to='`%'>`%</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='`<' homogen-type='method'><
<method name='`<'/><<doc placeholder='true'>
<text>
<p><tt>`<</tt> - is lesser than?</p>
<tt><p>a < b<br/>
or<br/>
int `<(int|float|string a,int|float|string b)<br/>
</p>
</tt>
<p>This operator compares two values and returns 1 if the first one
is lesser than the second one.</p>
operators</text>
<group><seealso/><text>
<p><ref resolved='predef::`!=' to='`!='>`!=</ref>, <ref resolved='predef::`==' to='`=='>`==</ref>, <ref resolved='predef::`>' to='`>'>>>`></ref>, <ref resolved='predef::`<=' to='`<='><<`<=</ref> and <ref resolved='predef::`>=' to='`>='>>>`>=</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='`<<' homogen-type='method'><<
<method name='`<<'/><<<doc placeholder='true'>
<text>
<p><tt>`<<</tt> - shift left</p>
<tt><p>a << b<br/>
or<br/>
int `<<(int a, int b)<br/>
</p>
</tt>
<p>This operator shift the integer a b steps left. This is equal to
multiplying a by 2 b times.</p>
operators</text>
<group><seealso/><text>
<p><ref resolved='predef::`>>' to='`>>'>>>>>`>></ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='`<=' homogen-type='method'><
<method name='`<='/><<doc placeholder='true'>
<text>
<p><tt>`<=</tt> - is lesser or equal than?</p>
<tt><p>a <= b<br/>
or<br/>
int `<=(int|float|string a,int|float|string b)<br/>
</p>
</tt>
<p>This operator compares two values and returns 1 if the first one
is lesser than or equal to the second one.</p>
operators</text>
<group><seealso/><text>
<p><ref resolved='predef::`!=' to='`!='>`!=</ref>, <ref resolved='predef::`==' to='`=='>`==</ref>, <ref resolved='predef::`>' to='`>'>>>`></ref>, <ref resolved='predef::`<' to='`<'><<`<</ref> and <ref resolved='predef::`>=' to='`>='>>>`>=</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='`==' homogen-type='method'>
<method name='`=='/><doc placeholder='true'>
<text>
<p><tt>`==</tt> - compare values</p>
<tt><p>a == b<br/>
or<br/>
int `==(mixed a, mixed b)<br/>
</p>
</tt>
<p>This operator compares two values and returns 1 if they are the same,
0 otherwise. Note that pointer equivialenec is required for arrays,
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | objects, programs, mappings and multisets. (Thus it is not enough that
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | two arrays LOOK alike, it must be the same array.)</p>
operators</text>
<group><seealso/><text>
<p><ref resolved='predef::`!=' to='`!='>`!=</ref>, <ref resolved='predef::`<' to='`<'><<`<</ref>, <ref resolved='predef::`>' to='`>'>>>`></ref>, <ref resolved='predef::`<=' to='`<='><<`<=</ref>, <ref resolved='predef::`>=' to='`>='>>>`>=</ref> and <ref to='efuns/equal'>efuns/equal</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='`>' homogen-type='method'>>
<method name='`>'/>><doc placeholder='true'>
<text>
<p><tt>`></tt> - is lesser than?</p>
<tt><p>a > b<br/>
or<br/>
int `>(int|float|string a,int|float|string b)<br/>
</p>
</tt>
<p>This operator compares two values and returns 1 if the first one
is greater than the second one.</p>
operators</text>
<group><seealso/><text>
<p><ref resolved='predef::`!=' to='`!='>`!=</ref>, <ref resolved='predef::`==' to='`=='>`==</ref>, <ref resolved='predef::`<' to='`<'><<`<</ref>, <ref resolved='predef::`<=' to='`<='><<`<=</ref> and <ref resolved='predef::`>=' to='`>='>>>`>=</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='`>=' homogen-type='method'>>
<method name='`>='/>><doc placeholder='true'>
<text>
<p><tt>`>=</tt> - is greater than or equal to?</p>
<tt><p>a >= b<br/>
or<br/>
int `>=(int|float|string a,int|float|string b)<br/>
</p>
</tt>
<p>This operator compares two values and returns 1 if the first one
is greater than or equal to the second one.</p>
operators</text>
<group><seealso/><text>
<p><ref resolved='predef::`!=' to='`!='>`!=</ref>, <ref resolved='predef::`==' to='`=='>`==</ref>, <ref resolved='predef::`>' to='`>'>>>`></ref>, <ref resolved='predef::`<' to='`<'><<`<</ref> and <ref resolved='predef::`<=' to='`<='><<`<=</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='`>>' homogen-type='method'>>>
<method name='`>>'/>>><doc placeholder='true'>
<text>
<p><tt>`>></tt> - shift right</p>
<tt><p>a >> b<br/>
or<br/>
int `>>(int a, int b)<br/>
</p>
</tt>
<p>This operator shift the integer a b steps right. This is equal to
dividing a by 2 b times.</p>
operators</text>
<group><seealso/><text>
<p><ref resolved='predef::`<<' to='`<<'><<<<`<<</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='`^' homogen-type='method'>
<method name='`^'/><doc placeholder='true'>
<text>
<p><tt>`^</tt> - exclusive or</p>
<tt><p>a ^ b<br/>
or<br/>
mixed `^(mixed ... args)<br/>
</p>
</tt>
<p>This operator does logical exclusive or operations For ints this means
bitwise xor.
</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>Arrays and multisets are treated as sets, so xoring two arrays will
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | result in an array with containing all values present in either but
not both arrays.
</p>
<p>For mappings, the intersection will be done on the indexes solely,
however, the values will be taken from the rightmost mapping.</p>
operators</text>
<group><seealso/><text>
<p><ref resolved='predef::`|' to='`|'>`|</ref> and <ref resolved='predef::`&' to='`&'>&&`&</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='`|' homogen-type='method'>
<method name='`|'/><doc placeholder='true'>
<text>
<p><tt>`|</tt> - union</p>
<tt><p>a | b<br/>
or<br/>
mixed `|(mixed ... args)<br/>
</p>
</tt>
<p>This operator does logical unions. For ints this means bitwise or.
</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>Arrays and multisets are treated as sets, so doing a union on two arrays
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | will result in an array with containing all values present in either
array. Although values present in both ararys will only be present
once in the result.
</p>
<p>For mappings, the intersection will be done on the indexes solely,
however, the values will be taken from the rightmost mapping.</p>
operators</text>
<group><seealso/><text>
|
94e6f4 | 1996-05-02 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::`&' to='`&'>&&`&</ref>, <ref resolved='predef::`^' to='`^'>`^</ref> and <ref resolved='predef::`|' to='||'>||</ref></p>
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='`~' homogen-type='method'>
<method name='`~'/><doc placeholder='true'>
<text>
<p><tt>`~</tt> - bitwise complement</p>
<tt><p>~ a<br/>
or<br/>
int `~(int a)<br/>
</p>
</tt>
<p>This operator inverses all bits in an integer and returns the
new integer.</p>
operators</text>
<group><seealso/><text>
<p><ref resolved='predef::`&' to='`&'>&&`&</ref>, <ref resolved='predef::`|' to='`|'>`|</ref> and <ref resolved='predef::`^' to='`^'>`^</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='acos' homogen-type='method'>
<method name='acos'/><doc placeholder='true'>
<text>
<p><tt>acos</tt> - Trigonometrical inverse cosine</p>
<tt><p>float acos(float <i>f</i>);<br/>
</p>
</tt>
<p>Return the arcus cosinus value for f.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
float</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::cos' to='predef::cos'>math/cos</ref> and <ref resolved='predef::asin' to='predef::asin'>math/asin</ref></p>
</text></group>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='add_constant' homogen-type='method'>
<method name='add_constant'/><doc placeholder='true'>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | <text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>add_constant</tt> - add new predefined functions or constants</p>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>void add_constant(string <i>name</i>, mixed <i>value</i>);<br/>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | or<br/>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | void add_constant(string <i>name</i>);<br/>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function adds a new constant to Pike, it is often used to
add builin functions (efuns). All programs compiled after add_constant
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | function is called can access 'value' by the name given by 'name'.
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | If there is a constant called 'name' already, it will be replaced by
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | by the new definition. This will not affect already compiled programs.
</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>Calling add_constant without a value will remove that name from the list<br/>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | <dl><group><text><matrix>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <r><c> </c><c> of of constant. As with replacing, this will not affect already compiled </c></r>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | <r><c> </c></r>
</matrix>
</text></group></dl>programs.<br/>
</p>
</text>
<group><example/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>add_constant("true",1);<br/>
add_constant("false",0);<br/>
add_constant("PI",4.0);<br/>
add_constant("sqr",lambda(mixed x) { return x * x; });<br/>
add_constant("add_constant");<br/>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | </p>
</tt></text></group>
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::all_constants' to='all_constants'>all_constants</ref></p>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | </text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='add_efun' homogen-type='method'>
<method name='add_efun'/><doc placeholder='true'>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>add_efun</tt> - add an efun or constant</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>void add_efun(string func_name, mixed function)<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | or<br/>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | void add_efun(string func_name)<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function is the same as add_constant.</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <group><seealso/><text>
<p><ref resolved='predef::add_constant' to='predef::add_constant'>builtin/add_constant</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='aggregage_list' homogen-type='method'>
<method name='aggregage_list'/><doc placeholder='true'>
<text>
<p><tt>aggregage_list</tt> - aggregate a multiset</p>
<tt><p>#include <simulate.h><br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>multiset aggregage_list(mixed ... <i>args</i>);<br/>
</p>
</tt>
<p>This function is exactly the same as aggregate_multiset.</p>
</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::aggregate_multiset' to='predef::aggregate_multiset'>builtin/aggregate_multiset</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='aggregate' homogen-type='method'>
<method name='aggregate'/><doc placeholder='true'>
<text>
<p><tt>aggregate</tt> - construct an array</p>
<tt><p>mixed *aggregate(mixed ... <i>elems</i>);<br/>
or<br/>
({ elem1, elem2, ... })<br/>
</p>
</tt>
|
fceb84 | 1995-11-16 | David Hedbor | | <p>Construct an array with the arguments as indices. This function
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | could be written in Pike as:
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
<p>mixed *aggregate(mixed ... elems) { return elems; }</p>
</text>
<group><note/><text>
<p>Arrays are dynamically allocated there is no need to declare them
like int a[10]=allocate(10); (and it isn't possible either) like
in C, just int *a=allocate(10); will do.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
array</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::sizeof' to='sizeof'>sizeof</ref>, <ref resolved='predef::arrayp' to='arrayp'>arrayp</ref> and <ref resolved='predef::allocate' to='allocate'>allocate</ref></p>
</text></group>
</doc>
</docgroup>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='aggregate_mapping' homogen-type='method'>
<method name='aggregate_mapping'/><doc placeholder='true'>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>aggregate_mapping</tt> - construct a mapping</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>mapping aggregate_mapping(mixed ... <i>elems</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | or<br/>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | ([ key1:val1, key2:val2, ... ])<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>Groups the arguments together two and two to key-index pairs and
creates a mapping of those pairs. The second syntax is always
preferable.</p>
|
203da9 | 1995-11-20 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | mapping</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::sizeof' to='sizeof'>sizeof</ref>, <ref resolved='predef::mappingp' to='mappingp'>mappingp</ref> and <ref resolved='predef::mkmapping' to='mkmapping'>mkmapping</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='aggregate_multiset' homogen-type='method'>
<method name='aggregate_multiset'/><doc placeholder='true'>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>aggregate_multiset</tt> - construct a multiset</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>multiset aggregate_multiset(mixed ... <i>elems</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | or<br/>
(< elem1, elem2, ... >)<br/>
</p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>Construct an multiset with the arguments as indexes. This function
could be written in Pike as:
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>multiset aggregate(mixed ... elems) { return mkmultiset(elems); }
</p>
<p>The only problem is that mkmultiset is implemented using
aggregage_multiset...</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | multiset</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::sizeof' to='sizeof'>sizeof</ref>, <ref resolved='predef::multisetp' to='multisetp'>multisetp</ref> and <ref resolved='predef::mkmultiset' to='mkmultiset'>mkmultiset</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
|
94e6f4 | 1996-05-02 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='alarm' homogen-type='method'>
<method name='alarm'/><doc placeholder='true'>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <text>
|
94e6f4 | 1996-05-02 | Fredrik Hübinette (Hubbe) | | <p><tt>alarm</tt> - set an alarm clock for delivery of a signal</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
94e6f4 | 1996-05-02 | Fredrik Hübinette (Hubbe) | | <tt><p>int alarm(int <i>seconds</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
94e6f4 | 1996-05-02 | Fredrik Hübinette (Hubbe) | | <p>alarm arranges for a SIGALRM signal to be delivered to the
process in seconds seconds.
</p>
<p>If seconds is zero, no new alarm is scheduled.
</p>
<p>In any event any previously set alarm is cancelled.</p>
</text>
|
fceb84 | 1995-11-16 | David Hedbor | |
|
94e6f4 | 1996-05-02 | Fredrik Hübinette (Hubbe) | | <group><returns/><text>
<p>alarm returns the number of seconds remaining until any
previously scheduled alarm was due to be delivered, or
zero if there was no previously scheduled alarm.</p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
94e6f4 | 1996-05-02 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::signal' to='signal'>signal</ref></p>
</text></group>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='all_constants' homogen-type='method'>
<method name='all_constants'/><doc placeholder='true'>
<text>
<p><tt>all_constants</tt> - return all predefined constants</p>
<tt><p>mapping (string:mixed) <i>all_constant</i>();<br/>
</p>
</tt>
<p>Return a mapping containing all constants, indexed on the names of the
constant, and with the value of the efun as argument.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::add_constant' to='add_constant'>add_constant</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='all_efuns' homogen-type='method'>
<method name='all_efuns'/><doc placeholder='true'>
<text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>all_efuns</tt> - return all 'efuns'</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | </p>
<p>mapping all_efuns();<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function is the same as all_constants.</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::all_constants' to='all_constants'>all_constants</ref></p>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='allocate' homogen-type='method'>
<method name='allocate'/><doc placeholder='true'>
<text>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <p><tt>allocate</tt> - allocate an array</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | <tt><p>mixed *allocate(int <i>size</i>);<br/>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | <p>Allocate an array of size elements and initialize them to zero.</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
<group><example/><text>
<tt><p>mixed *a=allocate(17);<br/>
</p>
</tt></text></group>
<group><note/><text>
<p>Arrays are dynamically allocated there is no need to declare them
like int a[10]=allocate(10); (and it isn't possible either) like
in C, just int *a=allocate(10); will do.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
array</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::sizeof' to='sizeof'>sizeof</ref>, <ref resolved='predef::aggregate' to='aggregate'>aggregate</ref> and <ref resolved='predef::arrayp' to='arrayp'>arrayp</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='array' homogen-type='method'>
<method name='array'/><doc placeholder='true'>
<text>
<p><tt>array</tt> - an array of values</p>
<tt><p>({ 1, 2, 3 })<br/>
allocate(10);<br/>
</p>
</tt>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <p>Arrays are basically a place to store a number of other values.
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | Arrays in pike are allocated blocks of values. They are dynamically
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | allocated and does not need to be declared as in C. The values in
the array can be set when creating the array as in the first
construction or anytime afterwards like this: arr[index]=data where
|
563f98 | 1996-08-15 | Fredrik Hübinette (Hubbe) | | index is an integer. Index is normally 0 <= index < sizeof(arr), and
refers to the corresponding element in the array. If index is less
than zero, it is the same as doing arr[sizeof(arr)+index]. This
means that negative index will index the array from the end rather
than from the beginning.
</p>
<p>Note that arrays are shared and use reference counts to keep
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | track of their references. This will have the effect that you can
have two variables pointing to the same array, and when you change
an index in in it, both variables will show the change.
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
<p>Here follows a list of operators that applies to arrays:
In this list a and b is used to represent an array expression:
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p><matrix>
<r><c> a + b </c><c> summation ( ({1}) + ({2}) returns ({1,2}) ) </c></r>
<r><c> a - b </c><c> subtraction, returns a copy of a with all values that are present in b removed, ( ({1, 2, 3}) - ({2}) returns ({1,3}) ) </c></r>
<r><c> a & b </c><c> intersection, return an array with all values that are present in both a and b </c></r>
<r><c> a | b </c><c> union, return an array with all values that are present in a or b, differs from summation in that values that are present in both a and b are only returned once. </c></r>
<r><c> a ^ b </c><c> xor, return an array with all values that are present in a or b but not in both. </c></r>
<r><c> a * c </c><c> multiplication (c is a string) same thing as implode(a,c) </c></r>
<r><c> a == b </c><c> returns 1 if a is the same array as b, same size and values is not enough. </c></r>
<r><c> a != b </c><c> returns 0 if a is the same array as b, same size and values is not enough. </c></r>
<r><c> ! a </c><c> boolean not, returns 0 </c></r>
<r><c> a[c] </c><c> indexing, returns element c in the array (c is an int) </c></r>
<r><c> a[c]=d </c><c> setting, sets element c in the array to d (c is an int) </c></r>
<r><c> a[c..d] </c><c> range (c & d are ints) returns an array containing a pice of the array a. The piece starts at element c and ends (and includes) element d. </c></r>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </matrix>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | </p>
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | types</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::mapping' to='mapping'>mapping</ref>, <ref resolved='predef::multiset' to='multiset'>multiset</ref>, <ref resolved='predef::allocate' to='predef::allocate'>builtin/allocate</ref> and <ref resolved='predef::sizeof' to='predef::sizeof'>builtin/sizeof</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='arrayp' homogen-type='method'>
<method name='arrayp'/><doc placeholder='true'>
<text>
<p><tt>arrayp</tt> - is the argument an array?</p>
<tt><p>int arrayp(mixed <i>arg</i>);<br/>
</p>
</tt>
<p>Returns 1 if arg is an array, zero otherwise.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
array</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::allocate' to='allocate'>allocate</ref>, <ref resolved='predef::intp' to='intp'>intp</ref>, <ref resolved='predef::programp' to='programp'>programp</ref>, <ref resolved='predef::floatp' to='floatp'>floatp</ref>, <ref resolved='predef::stringp' to='stringp'>stringp</ref>, <ref resolved='predef::objectp' to='objectp'>objectp</ref>, <ref resolved='predef::mappingp' to='mappingp'>mappingp</ref>, <ref resolved='predef::multisetp' to='multisetp'>multisetp</ref> and <ref resolved='predef::functionp' to='functionp'>functionp</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='asin' homogen-type='method'>
<method name='asin'/><doc placeholder='true'>
<text>
<p><tt>asin</tt> - Trigonometrical inverse sine</p>
<tt><p>float asin(float <i>f</i>);<br/>
</p>
</tt>
<p>Return the arcus sinus value for f.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
float</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::sin' to='predef::sin'>math/sin</ref> and <ref resolved='predef::acos' to='predef::acos'>math/acos</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='atan' homogen-type='method'>
<method name='atan'/><doc placeholder='true'>
<text>
<p><tt>atan</tt> - Trigonometrical inverse tangent</p>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <tt><p>float atan(float <i>f</i>);<br/>
|
a9858a | 1996-10-13 | Mirar (Pontus Hagland) | | </p>
</tt>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <p>Return the arcus tangent value for f.</p>
|
a9858a | 1996-10-13 | Mirar (Pontus Hagland) | |
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | float</text>
|
a9858a | 1996-10-13 | Mirar (Pontus Hagland) | |
<group><seealso/><text>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::tan' to='predef::tan'>math/tan</ref>, <ref resolved='predef::asin' to='predef::asin'>math/asin</ref> and <ref resolved='predef::acos' to='predef::acos'>math/acos</ref></p>
|
a9858a | 1996-10-13 | Mirar (Pontus Hagland) | | </text></group>
</doc>
</docgroup>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='backtrace' homogen-type='method'>
<method name='backtrace'/><doc placeholder='true'>
|
a9858a | 1996-10-13 | Mirar (Pontus Hagland) | | <text>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <p><tt>backtrace</tt> - get a description of the call stack</p>
|
a9858a | 1996-10-13 | Mirar (Pontus Hagland) | |
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <tt><p>mixed *backtrace();<br/>
|
a9858a | 1996-10-13 | Mirar (Pontus Hagland) | | </p>
</tt>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <p>This function returns a description of the call stack at this moment.
The description is returned in an array with one entry for each call
in the stack. Each entry has this format:
</p>
<p>({<br/>
<dl><group><text><matrix>
<r><c> file, </c><c> /* a string with the filename if known, else zero */ </c></r>
<r><c> line, </c><c> /* an integer containing the line if known, else zero */ </c></r>
<r><c> function, </c><c> /* The function-pointer to the called function */ </c></r>
</matrix>
</text></group></dl>})<br/>
|
a9858a | 1996-10-13 | Mirar (Pontus Hagland) | |
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | </p>
<p>The current call frame will be last in the array, and the one above
that the last but one and so on.</p>
</text>
|
a9858a | 1996-10-13 | Mirar (Pontus Hagland) | |
<group><seealso/><text>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::catch' to='catch'>catch</ref> and <ref resolved='predef::throw' to='throw'>throw</ref></p>
|
a9858a | 1996-10-13 | Mirar (Pontus Hagland) | | </text></group>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='break' homogen-type='method'>
<method name='break'/><doc placeholder='true'>
<text>
<p><tt>break</tt> - break a loop or switch</p>
<tt><p>break<br/>
</p>
</tt>
<p>Break jumps directly out of any loop or switch statement, it is
a very vital part of every switch statement.</p>
control</text>
<group><seealso/><text>
<p><ref to='do-while'>do-while</ref>, <ref resolved='predef::while' to='while'>while</ref>, <ref resolved='predef::for' to='for'>for</ref> and <ref resolved='predef::switch' to='switch'>switch</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='call_function' homogen-type='method'>
<method name='call_function'/><doc placeholder='true'>
<text>
<p><tt>call_function</tt> - call a function with arguments</p>
<tt><p>mixed call_function(function <i>fun</i>,mixed ... <i>args</i>);<br/>
or<br/>
mixed fun ( mixed ... <i>args</i> );<br/>
</p>
</tt>
<p>This function takes a a function pointer as first argument and calls
this function with the rest of the arguments as arguments. Normally,
you will never have to write call_function(), because you will use the
second syntax instead.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
function</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::backtrace' to='backtrace'>backtrace</ref> and <ref resolved='predef::get_function' to='get_function'>get_function</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='call_out' homogen-type='method'>
<method name='call_out'/><doc placeholder='true'>
<text>
<p><tt>call_out</tt> - make a delayed call to a function</p>
|
c1a125 | 1996-08-06 | Fredrik Hübinette (Hubbe) | | <tt><p>mixed call_out(function <i>f</i>, int <i>delay</i>, mixed ... <i>args</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>Call_out places a call to the function f with the argument args
|
c1a125 | 1996-08-06 | Fredrik Hübinette (Hubbe) | | in a queue to be called in about delay seconds. The return value
identifies this call out. The return value can be sent to
find_call_out or remove_call_out to remove the call out again.</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
<group><seealso/><text>
<p><ref resolved='predef::remove_call_out' to='remove_call_out'>remove_call_out</ref>, <ref resolved='predef::find_call_out' to='find_call_out'>find_call_out</ref> and <ref resolved='predef::call_out_info' to='call_out_info'>call_out_info</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='call_out_info' homogen-type='method'>
<method name='call_out_info'/><doc placeholder='true'>
<text>
<p><tt>call_out_info</tt> - get info about all call outs</p>
<tt><p>mixed **call_out_info();<br/>
</p>
</tt>
<p>This function returns an array with one entry for each entry in the
call out queue. The first in the queue will be in index 0. Each index
contains an array that looks like this:
</p>
<p>({<br/>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <dl><group><text><matrix>
<r><c> time_left, </c><c> /* an int */ </c></r>
<r><c> caller, </c><c> /* the object that made the call out */ </c></r>
<r><c> function, </c><c> /* the function to be called */ </c></r>
<r><c> arg1, </c><c> /* the first argument, if any */ </c></r>
<r><c> arg2, </c><c> /* the second argument, if any */ </c></r>
<r><c> ... </c><c> /* and so on... */ </c></r>
</matrix>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group></dl>})<br/>
</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::call_out' to='call_out'>call_out</ref>, <ref resolved='predef::find_call_out' to='find_call_out'>find_call_out</ref> and <ref resolved='predef::remove_call_out' to='remove_call_out'>remove_call_out</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='capitalize' homogen-type='method'>
<method name='capitalize'/><doc placeholder='true'>
<text>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <p><tt>capitalize</tt> - capitalize a string</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>string capitalize(string str)<br/>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <p>Convert the first character in str to upper case, and return the
new string.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
string</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::lower_case' to='predef::lower_case'>builtin/lower_case</ref> and <ref resolved='predef::upper_case' to='predef::upper_case'>builtin/upper_case</ref></p>
</text></group>
</doc>
</docgroup>
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='cast' homogen-type='method'>
<method name='cast'/><doc placeholder='true'>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <text>
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | <p><tt>cast</tt> - convert one type to another</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | <tt><p>( <i>type</i> ) <i>expression</i><br/>
</p>
</tt>
<p>Casts convert types, in most cases it just tells the compiler what
type the expression has, but it can also be used to actually convert
the value of the expression into something else.
</p>
<p>Casting from float or int to string will convert the given number
into a decimal ascii string representation.
</p>
<p>Casting from string to float or int will do the opposite. IE.
Read a decimal number from the string and return that.
</p>
<p>Casting from string to program will call cast_to_program in the
master object and request a program to return. The standard master
object will consider the string a file name and compile the program
given by that string. It will then put the program in a chache in
case you cast the same string to a program again later.
</p>
|
563f98 | 1996-08-15 | Fredrik Hübinette (Hubbe) | | <p>Castring from string to object will call cast_to_object in the
master object and request an object to return. The standard master
object will consider the string a file name, cast it to a program
and return a clone of that file. If the same cast is attempted again
later, the _same_ object will be returned.
</p>
<p>When casting an object, the method o->cast will be called with a string
with the name of the type as argument. o->cast can then return any
value.
</p>
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | <p>In all other cases, casts are just compiler hints.</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
|
563f98 | 1996-08-15 | Fredrik Hübinette (Hubbe) | | <group><example/><text>
<tt><p><matrix>
<r><c> (program)"/precompiled/file" </c><c> // returns the file program </c></r>
<r><c> (object)"/precompiled/file" </c><c> // returns a clone of the file program </c></r>
<r><c> (int)(object)"/precompiled/mpz" // returns 0 </c></r>
</matrix>
</p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | pike</text></group>
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | |
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <group><seealso/><text>
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::compile_file' to='compile_file'>compile_file</ref> and <ref resolved='predef::sscanf' to='sscanf'>sscanf</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='catch' homogen-type='method'>
<method name='catch'/><doc placeholder='true'>
<text>
<p><tt>catch</tt> - catch errors</p>
<tt><p>catch { commands }<br/>
or<br/>
catch ( expression )<br/>
</p>
</tt>
<p>catch traps exceptions such as run time errors or calls to throw() and
returns the argument given to throw. For a run time error, this value
is ({ "error message", backtrace }) </p>
control</text>
<group><seealso/><text>
<p><ref resolved='predef::throw' to='predef::throw'>builtin/throw</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='cd' homogen-type='method'>
<method name='cd'/><doc placeholder='true'>
<text>
<p><tt>cd</tt> - change directory</p>
<tt><p>int cd(string <i>s</i>);<br/>
</p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>Change the current directory for the whole Pike process, return
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | 1 for success, 0 otherwise.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
file</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::getcwd' to='predef::getcwd'>files/getcwd</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='ceil' homogen-type='method'>
<method name='ceil'/><doc placeholder='true'>
<text>
<p><tt>ceil</tt> - Truncate a number upward</p>
<tt><p>float ceil(float <i>f</i>);<br/>
</p>
</tt>
<p>Return the closest integral value higher or equal to x.
Note that ceil() does _not_ return an int, merely an integral value.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
float</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::floor' to='predef::floor'>math/floor</ref></p>
</text></group>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='class' homogen-type='method'>
<method name='class'/><doc placeholder='true'>
<text>
<p><tt>class</tt> - define a inlined program</p>
<tt><p>class { program definition }<br/>
</p>
</tt>
<p>Class is a way of writing serveral programs in one file.
The program written between the brackets will be returned by
class.</p>
</text>
<group><example/><text>
<tt><p>complex=clone(class { float r, i; });<br/>
complex->r=1.0;<br/>
complex->i=1.0;<br/>
</p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | pike</text></group>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::inherit' to='inherit'>inherit</ref> and <ref resolved='predef::lambda' to='lambda'>lambda</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='clone' homogen-type='method'>
<method name='clone'/><doc placeholder='true'>
<text>
<p><tt>clone</tt> - clone an object from a program</p>
<tt><p>object clone(program <i>p</i>,mixed ... <i>args</i>);<br/>
</p>
</tt>
<p>clone() creates an object from the program p. Or in C++ terms:
It creates an instance of the class p. This clone will first have
all global variables initalized, and then create() will be called
with args as arguments.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
object and program</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::destruct' to='destruct'>destruct</ref>, <ref resolved='predef::compile_string' to='compile_string'>compile_string</ref> and <ref resolved='predef::compile_file' to='compile_file'>compile_file</ref></p>
</text></group>
</doc>
</docgroup>
|
234b6d | 1996-06-09 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='column' homogen-type='method'>
<method name='column'/><doc placeholder='true'>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <text>
|
234b6d | 1996-06-09 | Fredrik Hübinette (Hubbe) | | <p><tt>column</tt> - extract a column</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
234b6d | 1996-06-09 | Fredrik Hübinette (Hubbe) | | <tt><p>array column(mixed *data,mixed index)<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
234b6d | 1996-06-09 | Fredrik Hübinette (Hubbe) | | <p>This function is exactly equivialent to:
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
|
234b6d | 1996-06-09 | Fredrik Hübinette (Hubbe) | | <p>map_array(index,lambda(mixed x,mixed y) { return x[y]; },data)
</p>
<p>Except of course it is a lot shorter and faster.
That is, it indexes every index in the array data on the value of
the argument index and returns an array with the results.</p>
array</text>
<group><seealso/><text>
<p><ref resolved='predef::rows' to='rows'>rows</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
</doc>
</docgroup>
<docgroup homogen-name='combine_path' homogen-type='method'>
<method name='combine_path'/><doc placeholder='true'>
<text>
<p><tt>combine_path</tt> - concatenate paths</p>
<tt><p>string combine_path(string <i>absolute</i>, string <i>relative</i>);<br/>
</p>
</tt>
<p>Concatenate a relative path to an absolute path and remove any
"//", "/.." or "/." to produce a straightforward absolute path
as a result.</p>
</text>
<group><example/><text>
<tt><p>> combine_path("/foo/bar/","..");<br/>
Result: /foo<br/>
> combine_path("/foo/bar/","../apa.c");<br/>
Result: /foo/apa.c<br/>
> combine_path("/foo/bar","./sune.c");<br/>
Result: /foo/bar/sune.c<br/>
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | </tt>
file</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::getcwd' to='getcwd'>getcwd</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='compile_file' homogen-type='method'>
<method name='compile_file'/><doc placeholder='true'>
<text>
<p><tt>compile_file</tt> - compile a file to a program</p>
<tt><p>program compile_file(string <i>filename</i>);<br/>
</p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function will compile the filename to an Pike program that can
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | later be used for cloning.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
program</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::clone' to='clone'>clone</ref> and <ref resolved='predef::compile_string' to='compile_string'>compile_string</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='compile_string' homogen-type='method'>
<method name='compile_string'/><doc placeholder='true'>
<text>
<p><tt>compile_string</tt> - compile a string to a program</p>
<tt><p>program compile_string(string <i>prog</i>, string <i>name</i>);<br/>
</p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>Compile_string takes a complete Pike program as an argument in a the
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | string prog and compiles it to clonable program. The second argument
will be used as the file name of the program and will be used for
error messages and such.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
program</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::compile_string' to='compile_string'>compile_string</ref> and <ref resolved='predef::clone' to='clone'>clone</ref></p>
</text></group>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='continue' homogen-type='method'>
<method name='continue'/><doc placeholder='true'>
<text>
<p><tt>continue</tt> - continue a loop</p>
<tt><p>continue<br/>
</p>
</tt>
<p>Continue work similarly to break only it does't finish the loop,
it just aborts the rest of this turn in the loop. </p>
control</text>
<group><seealso/><text>
<p><ref to='do-while'>do-while</ref>, <ref resolved='predef::while' to='while'>while</ref> and <ref resolved='predef::for' to='for'>for</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='copy_value' homogen-type='method'>
<method name='copy_value'/><doc placeholder='true'>
<text>
<p><tt>copy_value</tt> - copy a value recursively</p>
<tt><p>mixed copy_value(mixed <i>value</i>);<br/>
</p>
</tt>
<p>Copy value will copy the value given to it recursively. If the result
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | value is changed destructively (only possible for multisets, arrays and
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | mappings) the copied value will not be changed. The resulting value
will always be equal to the copied (tested with the efun equal), but
they may not the the same value. (tested with ==)</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::equal' to='equal'>equal</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='cos' homogen-type='method'>
<method name='cos'/><doc placeholder='true'>
<text>
<p><tt>cos</tt> - Trigonometrical cosine</p>
<tt><p>float cos(float <i>f</i>);<br/>
</p>
</tt>
<p>Return the cosinus value for f.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
float</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::acos' to='predef::acos'>math/acos</ref> and <ref resolved='predef::sin' to='predef::sin'>math/sin</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='crypt' homogen-type='method'>
<method name='crypt'/><doc placeholder='true'>
<text>
<p><tt>crypt</tt> - crypt a password</p>
<tt><p>string crypt(string <i>password</i>);<br/>
or<br/>
int crypt(string <i>typed_password</i>, string <i>crypted_password</i>);<br/>
</p>
</tt>
<p>This function crypts and verifies a short string. (normally only
the first 8 characters are significant) The first syntax crypts
the string password into something that is hopefully hard to decrypt,
and the second function crypts the first string and verifies that the
crypted result matches the second argument and returns 1 if they
matched, 0 otherwise.</p>
</text>
<group><example/><text>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <tt><p>To crypt a password use:<br/>
<dl><group><text>crypted_password = crypt(typed_password);<br/>
</text></group></dl>To see if the same password was used again use:<br/>
<dl><group><text>matched = crypt(typed_password, crypted_password);<br/>
</text></group></dl></p>
</tt>
string</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
</doc>
</docgroup>
<docgroup homogen-name='ctime' homogen-type='method'>
<method name='ctime'/><doc placeholder='true'>
<text>
<p><tt>ctime</tt> - convert time int to readable date string</p>
<tt><p>string ctime(int <i>current_time</i>);<br/>
</p>
</tt>
<p>Convert the output from a previous call to time() into a readable
string containing the currnent year, month, day and time.</p>
</text>
<group><example/><text>
<tt><p>> ctime(time());<br/>
Result: Wed Jan 14 03:36:08 1970<br/>
</p>
</tt></text></group>
<group><seealso/><text>
<p><ref resolved='predef::time' to='time'>time</ref></p>
</text></group>
</doc>
</docgroup>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='describe_backtrace' homogen-type='method'>
<method name='describe_backtrace'/><doc placeholder='true'>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <text>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <p><tt>describe_backtrace</tt> - make a backtrace readable</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>string describe_backtrace(mixed **<i>backtrace</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>Describe backtrace returns a string containing a readable message
that describes where the backtrace was made. The argument 'backtrace'
should normally be the return value from a call to backtrace()</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::backtrace' to='predef::backtrace'>builtin/backtrace</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='destruct' homogen-type='method'>
<method name='destruct'/><doc placeholder='true'>
<text>
<p><tt>destruct</tt> - destruct an object</p>
<tt><p>void destruct(object <i>o</i>);<br/>
</p>
</tt>
<p>Destruct marks an object as destructed, all pointers and function
pointers to this object will become zero. The destructed object will
|
fceb84 | 1995-11-16 | David Hedbor | | be freed from memory as soon as possible. This will also call
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | o->destroy.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
object</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::clone' to='clone'>clone</ref></p>
</text></group>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='do-while' homogen-type='method'>
<method name='do-while'/><doc placeholder='true'>
<text>
<p><tt>do-while</tt> - execute a statement while an expression is true</p>
<tt><p>do <i>statement</i> while ( <i>expression</i> );<br/>
</p>
</tt>
<p>do - while only differs from the ordinary while-loop in that it does
_not_ evaluate the expression until after the statement has been
executed once. Thus it always runs the statement once.</p>
</text>
<group><example/><text>
<tt><p>int i=circular_buffer_pos;<br/>
do<br/>
{<br/>
<dl><group><text>write(circular_buffer[i]);<br/>
i=(i+1) % sizeof(circular_buffer);<br/>
</text></group></dl>}while(i != circular_buffer_pos);<br/>
</p>
</tt>
control</text></group>
<group><seealso/><text>
<p><ref to='do-while'>do-while</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='equal' homogen-type='method'>
<method name='equal'/><doc placeholder='true'>
<text>
<p><tt>equal</tt> - check if two values are equal or not</p>
<tt><p>int equal(mixed <i>a</i>, mixed <i>b</i>);<br/>
</p>
</tt>
<p>This function checks if the values a and b are equal. For all types but
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | arrays, multisets and mappings, this operation is the same as doing a == b.
For arrays, mappings and multisets however, their contents are checked
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | recursively, and if all their contents are the same and in the same
place, they are considered equal.</p>
</text>
<group><example/><text>
<tt><p>> ({ 1 }) == ({ 1 });<br/>
Result: 0<br/>
> equal( ({ 1 }), ({ 1 }) );<br/>
Result: 1<br/>
> <br/>
</p>
</tt></text></group>
<group><seealso/><text>
<p><ref resolved='predef::copy_value' to='copy_value'>copy_value</ref></p>
</text></group>
|
3f0cfb | 1995-11-13 | David Hedbor | | </doc>
</docgroup>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='errno' homogen-type='method'>
<method name='errno'/><doc placeholder='true'>
|
3f0cfb | 1995-11-13 | David Hedbor | | <text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>errno</tt> - return system error number</p>
|
3f0cfb | 1995-11-13 | David Hedbor | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>int errno();<br/>
|
3f0cfb | 1995-11-13 | David Hedbor | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function returns the system error from the last file operation.
Note that you should normally use the function errno in the file
object instead.</p>
|
3f0cfb | 1995-11-13 | David Hedbor | | </text>
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::/precompiled/file' to='file/errno'>file/errno</ref></p>
|
3f0cfb | 1995-11-13 | David Hedbor | | </text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='exec' homogen-type='method'>
<method name='exec'/><doc placeholder='true'>
<text>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <p><tt>exec</tt> - simple way to use exece()</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <process.h><br/>
</p>
<p>int exec(string <i>file</i>, string ... <i>args</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function destroys the Pike parser and runs the program
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | 'file' instead with the arguments. If no there are no '/' in
the filename, the variable PATH will be consulted when looking
for the program. This function does not return except when
the exec fails for some reason.</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
<group><example/><text>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <tt><p>exec("/bin/echo","hello","world");<br/>
<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt></text></group>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='exece' homogen-type='method'>
<method name='exece'/><doc placeholder='true'>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | <text>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <p><tt>exece</tt> - execute a program</p>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | |
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <tt><p>int exece(string <i>file</i>, string *<i>args</i>);<br/>
or<br/>
int exece(string <i>file</i>, string *<i>args</i>, mapping(string:string) <i>env</i>);<br/>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function transforms the Pike process into a process running
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | the program specified in the argument 'file' with the argument 'args'.
If the mapping 'env' is present, it will completely replace all
environment variables before the new program is executed.
This function only returns if something went wrong during exece(),
and in that case it returns zero.</p>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | </text>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <group><note/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>The Pike driver _dies_ when this function is called. You must use
fork() if you wish to execute a program and still run the Pike
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | driver.</p>
</text></group>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | <group><example/><text>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <tt><p>exece("/bin/ls", ({"-l"}));<br/>
exece("/bin/sh", ({"-c", "echo $HOME"}), (["HOME":"/not/home"]));<br/>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | </p>
</tt></text></group>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <group><seealso/><text>
<p><ref resolved='predef::fork' to='predef::fork'>files/fork</ref> and <ref resolved='predef::/precompiled/file.pipe' to='file->pipe'>>file->pipe</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='exit' homogen-type='method'>
<method name='exit'/><doc placeholder='true'>
<text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>exit</tt> - exit Pike interpreter</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<tt><p>void exit(int <i>returncode</i>);<br/>
</p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function exits the whole 'pike' program with the return code
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | given. Using exit() with any other value than 0 indicates that
something went wrong during execution. See your system manuals for
more information about return codes.
</p>
</text>
</doc>
</docgroup>
<docgroup homogen-name='exp' homogen-type='method'>
<method name='exp'/><doc placeholder='true'>
<text>
<p><tt>exp</tt> - Natural exponent</p>
<tt><p>float exp(float <i>f</i>);<br/>
</p>
</tt>
<p>Return the natural exponent of f.
log( exp( x ) ) == x as long as exp(x) doesn't overflow an int.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
float</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::pow' to='predef::pow'>math/pow</ref> and <ref resolved='predef::log' to='predef::log'>math/log</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='explode' homogen-type='method'>
<method name='explode'/><doc placeholder='true'>
<text>
<p><tt>explode</tt> - explode a string on a delimeter</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>string *explode(string <i>victim</i>, string <i>delimeter</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>Explode divides the string called victim at every occurance of
the string delimeter and returns the resulting parts in an array.
If delimeter is an empty string, victim will be divided into strings
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | of length 1.
</p>
<p>Explode is the same as division.</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
<group><example/><text>
<tt><p>> explode("foobar","o");<br/>
Result: ({ "f", "", "bar" })<br/>
> explode("10101001010100010101","10");<br/>
Result: ({ "", "", "", "0", "", "", "00", "", "1" })<br/>
> explode("/foo/bar/gazonk","/");<br/>
Result: ({ "", "foo", "bar", "gazonk" })<br/>
> explode("foobar","");<br/>
Result: ({ "f", "o", "o", "b", "a", "r" })<br/>
</p>
|
fceb84 | 1995-11-16 | David Hedbor | | </tt>
string</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::implode' to='implode'>implode</ref> and <ref resolved='predef::`/' to='`/'>`/</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='file_size' homogen-type='method'>
<method name='file_size'/><doc placeholder='true'>
<text>
<p><tt>file_size</tt> - return the size of a file in bytes</p>
|
06fa8e | 1996-10-24 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <stdio.h><br/>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | |
</p>
<p>int file_size(string <i>file</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>Give the size of a file. Size -1 indicates that the file either
does not exist, or that it is not readable by you. Size -2
indicates that it is a directory.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
file</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::write_file' to='write_file'>write_file</ref> and <ref resolved='predef::read_bytes' to='read_bytes'>read_bytes</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='file_stat' homogen-type='method'>
<method name='file_stat'/><doc placeholder='true'>
<text>
<p><tt>file_stat</tt> - stat a file</p>
<tt><p>int *file_stat(string <i>file</i>);<br/>
or<br/>
int *file_stat(string <i>file</i>, <i>1</i>);<br/>
or<br/>
int *file->stat();<br/>
</p>
</tt>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | <p>file_stat returns an array of integers describing some properties<br/>
|
4cc385 | 1996-09-23 | Fredrik Hübinette (Hubbe) | | about the file. Currently file_stat returns 7 entries:<br/>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | ({<br/>
<dl><group><text><matrix>
<r><c> mode, </c><c> /* file mode, protection bits etc. etc. */ </c></r>
<r><c> size, </c><c> /* file size for regular files, -2 for dirs, -3 for links, -4 for otherwise */ </c></r>
<r><c> atime, </c><c> /* last access time */ </c></r>
<r><c> mtime, </c><c> /* last modify time */ </c></r>
<r><c> ctime, </c><c> /* last status time change */ </c></r>
<r><c> uid, </c><c> /* The user who owns this file */ </c></r>
<r><c> gid </c><c> /* The group this file belongs to */ </c></r>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </matrix>
</text></group></dl>})<br/>
|
4cc385 | 1996-09-23 | Fredrik Hübinette (Hubbe) | | If you give 1 as a second argument, file_stat does not follow links.<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | You can never get -3 as size if you don't give a second argument.<br/>
</p>
<p>If there is no such file or directory, zero is returned.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
file</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::get_dir' to='predef::get_dir'>files/get_dir</ref></p>
</text></group>
</doc>
</docgroup>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='filter' homogen-type='method'>
<method name='filter'/><doc placeholder='true'>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>filter</tt> - filter an array or mapping through a function</p>
<tt><p>#include <array.h><br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | </p>
<p>mixed *filter(mixed <i>arr</i>,function <i>fun</i>,mixed ... <i>args</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | or<br/>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | mixed *filter(object *<i>arr</i>,string <i>fun</i>,mixed ... <i>args</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | or<br/>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | mixed *filter(function *<i>arr</i>,-<i>1</i>,mixed ... <i>args</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>First syntax:
Filter array returns an array holding the items of arr for which
fun returns true.
</p>
<p>Second syntax:
Filter array calls fun in all the objects in the array arr, and
return all objects that returned true.
</p>
<p>Third syntax:
Filter array calls all functionpointers in the array arr, and
return all that returned true.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
array</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::sum_arrays' to='sum_arrays'>sum_arrays</ref> and <ref resolved='predef::map' to='map'>map</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='filter_array' homogen-type='method'>
<method name='filter_array'/><doc placeholder='true'>
<text>
<p><tt>filter_array</tt> - filter an array through a function</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>mixed *filter_array(mixed *<i>arr</i>,function <i>fun</i>,mixed ... <i>args</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | or<br/>
mixed *filter_array(object *<i>arr</i>,string <i>fun</i>,mixed ... <i>args</i>);<br/>
or<br/>
mixed *filter_array(function *<i>arr</i>,-<i>1</i>,mixed ... <i>args</i>);<br/>
</p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>Filter array is the same function as filter.</p>
array</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::sum_arrays' to='sum_arrays'>sum_arrays</ref>, <ref resolved='predef::map_array' to='map_array'>map_array</ref> and <ref resolved='predef::filter' to='filter'>filter</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='find_call_out' homogen-type='method'>
<method name='find_call_out'/><doc placeholder='true'>
<text>
<p><tt>find_call_out</tt> - find a call out in the queue</p>
<tt><p>int find_call_out(function <i>f</i>);<br/>
|
c1a125 | 1996-08-06 | Fredrik Hübinette (Hubbe) | | or<br/>
int find_call_out(mixed <i>id</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
c1a125 | 1996-08-06 | Fredrik Hübinette (Hubbe) | | <p>This function searches the call out queue. If given a function as
argument, it looks for the first call out scheduled to that function.
The argument can also be a call out id as returned by call_out, in
which case that call_out will be found. (Unless it has already been
called.) find_call_out will then return how many seconds remains
before that call will be executed. If no call is found,
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | zero_type(find_call_out(f)) will return 1.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::call_out' to='call_out'>call_out</ref>, <ref resolved='predef::remove_call_out' to='remove_call_out'>remove_call_out</ref> and <ref resolved='predef::call_out_info' to='call_out_info'>call_out_info</ref></p>
</text></group>
|
362e88 | 1996-10-15 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='find_option' homogen-type='method'>
<method name='find_option'/><doc placeholder='true'>
<text>
<p><tt>find_option</tt> - find command line options</p>
<tt><p>#include <getopt.h><br/>
</p>
<p>mixed find_option(string *argv,<br/>
<dl><group><text>string shortform,<br/>
string longform,<br/>
string envvar,<br/>
mixed def);<br/>
</text></group></dl></p>
</tt>
<p>This is a generic function to parse command line options of the
type '-f', '--foo' or '--foo=bar'. The first argument should be
the array of strings that is sent as second argument to your
main() function, the second is a string with the short form of
your option. The short form must be only one character long.
The 'longform' is an alternative and maybe more readable way to
give the same option. If you give "foo" as longform your program
will accept --foo as argument. The envvar argument specifies what
environment variable can be used to specify the same option. The
envvar option exists to make it easier to custimizer program usage.
The 'def' has two functions: It specifies that the option takes an
argument and it tells find_option what to return if the option is
not present. If 'def' is given and the option does not have an
argument find_option will print an error message and exit the program.
</p>
<p>Also, as an extra bonus: shortform, longform and envvar can all be
arrays, in which case either of the options in the array will be
accpted.</p>
</text>
<group><note/><text>
<p>find_option modifies argv.</p>
</text></group>
<group><example/><text>
<tt><p>int main(int argc, string *argv)<br/>
{<br/>
<dl><group><text>if(find_option(argv,"f","foo"))<br/>
<dl><group><text>werror("The FOO option was given.\n");<br/>
</text></group></dl></text></group></dl>
</p>
<p><dl><group><text>werror("The BAR option got the "+<br/>
find_option(argv,"b","bar","BAR_OPTION","default")+<br/>
" argument.\n");<br/>
</text></group></dl>}<br/>
</p>
</tt></text></group>
<group><seealso/><text>
<p><ref resolved='predef::get_args' to='get_args'>get_args</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='float' homogen-type='method'>
<method name='float'/><doc placeholder='true'>
<text>
<p><tt>float</tt> - floating point numbers</p>
<tt><p>0.9<br/>
1.0<br/>
2.7e7<br/>
</p>
</tt>
<p>This type stores a floating point number, normally it use 4 bytes
of storage when used in a global variable.
</p>
<p>A list of operators that applies to floats follows:
In this list a and b is used to represent a float expression:
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p><matrix>
<r><c> a + b </c><c> summation </c></r>
<r><c> a - b </c><c> subtraction </c></r>
<r><c> a * b </c><c> multiplication </c></r>
|
d3910d | 1996-05-13 | Fredrik Hübinette (Hubbe) | | <r><c> a / b </c><c> division </c></r>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <r><c> a % b </c><c> modulo ( same thing as a - floor( a / b ) * b ) </c></r>
<r><c> - a </c><c> negation </c></r>
<r><c> a == b </c><c> return 1 if a is equal to b, 0 otherwise </c></r>
<r><c> a != b </c><c> return 0 if a is equal to b, 1 otherwise </c></r>
<r><c> a < b </c><c> returns 1 if a is lesser than b, 0 otherwise </c></r>
<r><c> a <= b </c><c> returns 1 if a is lesser or equal to b, 0 otherwise </c></r>
<r><c> a > b </c><c> returns 1 if a is greater than b, 0 otherwise </c></r>
<r><c> a >= b </c><c> returns 1 if a is greater or equal to b, 0 otherwise </c></r>
</matrix>
</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
<group><note/><text>
<p>floats and ints cannot be used together, they have to be cast
to the same type first.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | types</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::sin' to='predef::sin'>math/sin</ref>, <ref resolved='predef::cos' to='predef::cos'>math/cos</ref>, <ref resolved='predef::tan' to='predef::tan'>math/tan</ref> and <ref resolved='predef::sqrt' to='predef::sqrt'>math/sqrt</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='floatp' homogen-type='method'>
<method name='floatp'/><doc placeholder='true'>
<text>
<p><tt>floatp</tt> - is the argument an float?</p>
<tt><p>int floatp(mixed <i>arg</i>);<br/>
</p>
</tt>
<p>Returns 1 if arg is a float, zero otherwise.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
float</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::intp' to='intp'>intp</ref>, <ref resolved='predef::programp' to='programp'>programp</ref>, <ref resolved='predef::arrayp' to='arrayp'>arrayp</ref>, <ref resolved='predef::stringp' to='stringp'>stringp</ref>, <ref resolved='predef::objectp' to='objectp'>objectp</ref>, <ref resolved='predef::mappingp' to='mappingp'>mappingp</ref>, <ref resolved='predef::multisetp' to='multisetp'>multisetp</ref> and <ref resolved='predef::functionp' to='functionp'>functionp</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='floor' homogen-type='method'>
<method name='floor'/><doc placeholder='true'>
<text>
<p><tt>floor</tt> - Truncate a number downward</p>
<tt><p>float floor(float <i>f</i>);<br/>
</p>
</tt>
<p>Return the closest integral value lower or equal to x.
Note that floor() does _not_ return an int, merely an integral value.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
float</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::ceil' to='predef::ceil'>math/ceil</ref></p>
</text></group>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='for' homogen-type='method'>
<method name='for'/><doc placeholder='true'>
<text>
<p><tt>for</tt> - generic loop statement</p>
<tt><p>for ( expression1 ; expression2 ; expression3 ) <i>statement</i><br/>
</p>
</tt>
<p>the above statement is exactly equal to:
</p>
<p>expression1;<br/>
while( expression2 )<br/>
{<br/>
<dl><group><text><statement><br/>
expression3;<br/>
</text></group></dl>}<br/>
</p>
<p>Except when using 'continue'. When using continue in <statement>
expresstion3 will not be called.</p>
</text>
<group><example/><text>
<tt><p>int e;<br/>
for(e=0;e<10;e++) write(e+"\n");<br/>
</p>
</tt>
control</text></group>
<group><seealso/><text>
<p><ref resolved='predef::while' to='while'>while</ref>, <ref resolved='predef::break' to='break'>break</ref> and <ref resolved='predef::continue' to='continue'>continue</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='foreach' homogen-type='method'>
<method name='foreach'/><doc placeholder='true'>
<text>
<p><tt>foreach</tt> - loop over an array</p>
<tt><p>foreach ( array, variable ) statement<br/>
</p>
</tt>
<p>For each element in array, set variable to that value and execute
'statement'.</p>
</text>
<group><example/><text>
<tt><p>string word;<br/>
foreach( explode(sentence," "), word) foo(word);<br/>
</p>
</tt>
control</text></group>
<group><seealso/><text>
<p><ref resolved='predef::for' to='for'>for</ref> and <ref resolved='predef::while' to='while'>while</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='fork' homogen-type='method'>
<method name='fork'/><doc placeholder='true'>
<text>
<p><tt>fork</tt> - fork the process in two</p>
<tt><p>int fork();<br/>
</p>
</tt>
<p>Fork splits the process in two, and for the parent it returns the
pid of the child. Refer to your unix manual for further details.</p>
</text>
<group><note/><text>
<p>This function cause endless bugs if used without proper care.</p>
</text></group>
<group><seealso/><text>
|
7491fd | 1995-10-11 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::exec' to='predef::exec'>files/exec</ref> and <ref resolved='predef::/precompiled/file.pipe' to='file->pipe'>>file->pipe</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='function' homogen-type='method'>
<method name='function'/><doc placeholder='true'>
<text>
<p><tt>function</tt> - a function pointer</p>
<tt><p>foo /* if foo is a function in this object */<br/>
bar::foo /* if foo is a function in the inherited program 'bar' */<br/>
o->foo /* function (or variable) foo in the object o */<br/>
</p>
</tt>
<p>A functionpointer is a reference to a function in an object. It can be
called with call_function which can also be written as just ().
If the object the functionpointer is in is destructed the pointer will
become 0. If you try to call a functionpointer that has is 0 then 0
will be returned.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | types</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::object' to='object'>object</ref>, <ref resolved='predef::call_function' to='predef::call_function'>builtin/call_function</ref>, <ref resolved='predef::functionp' to='predef::functionp'>builtin/functionp</ref>, <ref resolved='predef::function_object' to='predef::function_object'>builtin/function_object</ref> and <ref resolved='predef::function_name' to='predef::function_name'>builtin/function_name</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='function_name' homogen-type='method'>
<method name='function_name'/><doc placeholder='true'>
<text>
<p><tt>function_name</tt> - return the name of a function, if known</p>
<tt><p>string function_name(function <i>f</i>);<br/>
</p>
</tt>
<p>This function returns the name of the function f. If the function is
a pre-defined function in the driver, zero will be returned.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
function</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::function_object' to='function_object'>function_object</ref> and <ref resolved='predef::get_function' to='get_function'>get_function</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='function_object' homogen-type='method'>
<method name='function_object'/><doc placeholder='true'>
<text>
<p><tt>function_object</tt> - return what object a function is in</p>
<tt><p>object function_object(function <i>f</i>);<br/>
</p>
</tt>
<p>Function_object will return the object the function f is in. If the
function is a predefined function from the driver, zero will be
returned.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
function</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::function_name' to='function_name'>function_name</ref> and <ref resolved='predef::get_function' to='get_function'>get_function</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='functionp' homogen-type='method'>
<method name='functionp'/><doc placeholder='true'>
<text>
<p><tt>functionp</tt> - is the argument an function?</p>
<tt><p>int functionp(mixed <i>arg</i>);<br/>
</p>
</tt>
<p>Returns 1 if arg is a function, zero otherwise.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
function</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::intp' to='intp'>intp</ref>, <ref resolved='predef::programp' to='programp'>programp</ref>, <ref resolved='predef::arrayp' to='arrayp'>arrayp</ref>, <ref resolved='predef::stringp' to='stringp'>stringp</ref>, <ref resolved='predef::objectp' to='objectp'>objectp</ref>, <ref resolved='predef::mappingp' to='mappingp'>mappingp</ref>, <ref resolved='predef::multisetp' to='multisetp'>multisetp</ref> and <ref resolved='predef::floatp' to='floatp'>floatp</ref></p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='functions' homogen-type='method'>
<method name='functions'/><doc placeholder='true'>
<text>
<p><tt>functions</tt> - how to write a function</p>
<tt><p>modifier type function_name (argument_specification)<br/>
{<br/>
<dl><group><text>/* function body */<br/>
</text></group></dl>}<br/>
</p>
</tt>
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | <p>A function is basically a piece of code which takes some data
does some things, and hands some data back. Data sent to a
a function is called an 'argument'.
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p>This defines a function called 'function_name' returning the type
'type'. The argument_specification is a comma separated list of
arguments. Each argument is specified with a type, whitespace and
the name of the argument. The last argument may have ... before
the name to indicate that that argument shall contain an array of
the rest of the arguments given by the caller. Note that using
... automatically makes an the variable an array, so writing
</p>
<p><matrix>
<r><c> </c><c> int foo(int * ... ints); </c></r>
<r><c> </c></r>
</matrix>
</p>
<p>means that 'ints' is an array of arrays of integers. Which might not
be what you want.
</p>
<p>The modifiers can be zero or more of: static, no_mask, varargs, inline
and private. Varargs means that it is ok to call the function with
less arguments that would otherwise be needed. Inline means that
the function may be inlined in other code. Inline also makes the
function no_mask. Static means that the function can not be called
from other objects. Private means that the function can not be accessed
from programs that inherits this program.
</p>
<p>Some times you need to use a function before it is defined, then you
can write a 'forward declaration' of the function. This is done by
copying the function definition up until (but not including) the '{'
and putting a semicolon after it. The forward declaration should be
put before the use of the function of course.
</p>
<p>Function definitions and forward declarations are toplevel constructs,
they can not be written inside functions or expressions.</p>
</text>
<group><example/><text>
<tt><p>/* Forward declare foobar as taking an array of int as argument <br/>
<dl><group><text>*and returning an int<br/>
*/<br/>
</text></group></dl>static int foobar(int *a);<br/>
</p>
<p>/* This function takes a format string and any number of integers<br/>
<dl><group><text>* as argument and returns a string<br/>
*/<br/>
</text></group></dl>string dofobar(string format ,int ... rest)<br/>
{<br/>
<dl><group><text>return sprintf(format, foobar(rest));<br/>
</text></group></dl>}<br/>
</p>
<p>/* Define foobar */<br/>
static int foobar(int *a)<br/>
{<br/>
<dl><group><text>int e, ret;<br/>
ret=1;<br/>
</text></group></dl>
</p>
<p><dl><group><text>for(e=0;e<sizeof(a);e++)<br/>
<dl><group><text>ret*=a[e];<br/>
</text></group></dl></text></group></dl>
</p>
<p><dl><group><text>return ret;<br/>
</text></group></dl>}<br/>
</p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | pike</text></group>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::lambda' to='lambda'>lambda</ref>, <ref resolved='predef::return' to='return'>return</ref> and <ref resolved='predef::modifier' to='modifier'>modifier</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
|
c1a125 | 1996-08-06 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='gauge' homogen-type='method'>
<method name='gauge'/><doc placeholder='true'>
<text>
<p><tt>gauge</tt> - measure system time</p>
<tt><p>gauge { commands }<br/>
or<br/>
gauge ( expression )<br/>
</p>
</tt>
<p>Gauge measure how much cpu time is used to execute the commands
given as arguments. The number of milliseconds used is returned
as an integer.</p>
|
6be003 | 1996-11-03 | Mirar (Pontus Hagland) | |
control</text>
|
c1a125 | 1996-08-06 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::catch' to='catch'>catch</ref> and <ref resolved='predef::rusage' to='predef::rusage'>builtin/rusage</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='gc' homogen-type='method'>
<method name='gc'/><doc placeholder='true'>
<text>
<p><tt>gc</tt> - do garbage collection</p>
<tt><p>int gc();<br/>
</p>
</tt>
<p><matrix>
<r><c> This function checks all the memory for cyclic structures such </c></r>
<r><c> as arrays containing themselves and frees them if approperiate. </c></r>
<r><c> It also frees up destructed objects. It then returns how many </c></r>
<r><c> arrays/objects/programs/etc. it managed </c><c> to free by doing this. </c></r>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <r><c> Normally there is no need to call this function since Pike will </c></r>
<r><c> call it by itself every now and then. (Pike will try to predict </c></r>
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | <r><c> when 20% of all arrays/object/programs in memory is 'garbage' </c></r>
<r><c> and call this routine then.) </c></r>
</matrix>
</p>
<p/>
</text>
|
362e88 | 1996-10-15 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='get_args' homogen-type='method'>
<method name='get_args'/><doc placeholder='true'>
<text>
<p><tt>get_args</tt> - get the non-option arguments</p>
<tt><p>#include <getopt.h><br/>
</p>
<p>string *get_args(string *<i>argv</i>);<br/>
</p>
</tt>
<p>This function returns the remaining command line arguments after
you have run find_options to find all the options in the
argument list. If there are any options left not handled by
find_options an error message will be written and the program will
exit. Otherwise a new 'argv' array without the parsed options is
returned.</p>
</text>
<group><example/><text>
<tt><p>int main(int argc, string *argv)<br/>
{<br/>
<dl><group><text>if(find_option(argv,"f","foo"))<br/>
<dl><group><text>werror("The FOO option was given.\n");<br/>
</text></group></dl></text></group></dl>
</p>
<p><dl><group><text>argv=get_args(argv);<br/>
werror("The arguments are: "+(argv*" ")+".\n");<br/>
</text></group></dl>}<br/>
</p>
</tt></text></group>
<group><seealso/><text>
<p><ref resolved='predef::find_option' to='find_option'>find_option</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='get_dir' homogen-type='method'>
<method name='get_dir'/><doc placeholder='true'>
<text>
<p><tt>get_dir</tt> - read a directory</p>
<tt><p>string *get_dir(string <i>dirname</i>);<br/>
</p>
</tt>
<p>Return an array of all filenames in the directory dir, or zero if
no such directory exists.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
file</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::mkdir' to='predef::mkdir'>files/mkdir</ref> and <ref resolved='predef::cd' to='predef::cd'>files/cd</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='get_function' homogen-type='method'>
<method name='get_function'/><doc placeholder='true'>
<text>
<p><tt>get_function</tt> - fetch a function from an object</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>function get_function(object <i>o</i>, string <i>name</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p>Defined as: return o[name];</p>
function</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
</doc>
</docgroup>
<docgroup homogen-name='getcwd' homogen-type='method'>
<method name='getcwd'/><doc placeholder='true'>
<text>
<p><tt>getcwd</tt> - return current working directory</p>
<tt><p>string getcwd();<br/>
</p>
</tt>
<p>getcwd returns the current working directory.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
file</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::cd' to='predef::cd'>files/cd</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='getenv' homogen-type='method'>
<method name='getenv'/><doc placeholder='true'>
<text>
<p><tt>getenv</tt> - get an environment variable</p>
<tt><p>string getenv(string <i>varname</i>);<br/>
</p>
</tt>
<p>Reurns the value of the environment variable with the name varname,
if no such environment variable exists, zero is returned.</p>
</text>
<group><note/><text>
<p>This function is provided by master.c
</p>
</text></group>
|
7491fd | 1995-10-11 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='getpid' homogen-type='method'>
<method name='getpid'/><doc placeholder='true'>
<text>
<p><tt>getpid</tt> - get the process id of this process</p>
<tt><p>int getpid();<br/>
</p>
</tt>
<p>This returns the pid of this process. Useful for sending
signals to yourself.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::kill' to='kill'>kill</ref>, <ref resolved='predef::fork' to='fork'>fork</ref> and <ref resolved='predef::signal' to='signal'>signal</ref></p>
</text></group>
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='glob' homogen-type='method'>
<method name='glob'/><doc placeholder='true'>
<text>
<p><tt>glob</tt> - match strings against globs</p>
<tt><p>int glob(string <i>glob</i>, string <i>str</i>);<br/>
or<br/>
string *glob(string <i>glob</i>, string *<i>arr</i>);<br/>
</p>
</tt>
<p>This function matches "globs". A in the glob string a question sign
matches any character and an asterisk matches any string. When
given two strings as argument a true/false value is returned
which reflects if the 'str' matches 'glob'. When given an array as
second argument, an array containing all matching strings is returned.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::sscanf' to='sscanf'>sscanf</ref> and <ref resolved='predef::regexp' to='regexp'>regexp</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='hash' homogen-type='method'>
<method name='hash'/><doc placeholder='true'>
<text>
<p><tt>hash</tt> - hash a string</p>
<tt><p>int hash(string <i>s</i>);<br/>
or<br/>
int hash(string <i>s</i>, int <i>max</i>);<br/>
</p>
</tt>
<p>This function will return an int derived from the string s. The same
string will always hash to the same value. If a second argument
|
fceb84 | 1995-11-16 | David Hedbor | | is given, the result will be >= 0 and lesser than that argument.</p>
string</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='hilfe' homogen-type='method'>
<method name='hilfe'/><doc placeholder='true'>
<text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>hilfe</tt> - Hubbe's Incremental Pike FrontEnd</p>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | |
<tt><p>$ hilfe<br/>
or<br/>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | $ pike -Cstay hilfe<br/>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>Hilfe is a Pike-script that supplies an incremental environment for
Pike. It allowes you to evaluate Pike 'on the fly'. If you're running
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | UNIX, you only have to write 'hilfe' to start it, otherwise you will
have to write 'driver -Cstay hilfe' to run it. If you don't know what
'incremeantal' means in this context, ask you local LISP junkie.
</p>
<p>Hilfe has the following commands:
</p>
<p>quit - exit hilfe
new - clear all variables and function definition
dump - dump all current variables
. - clear input buffer
</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>Hilfe parses a subset of Pike, there many things it doesn't handle. Here
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | is a list of what you can do:
</p>
<p>Define a function:
<type> <name>( <arguments> ) { <statements > }
Note that hilfe simulates a function defenition by defining a variable
and setting it to the function pointer. Therefor actual typechecking is
almost nil. Also note that hilfe doesn't recognize type modifiers such
as static, private, varargs etc.
</p>
<p>Declare one or many global variables:
<type> <name> [=<value>], <name> [=value>] ..... ;
Hilfe simulates variable handling, and typechecking is almost nil,
therefor all global variables are declared as mixed, whatever the
<type> may be.
</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | <p>Evaluate a statement:
<statement> ;
Statements include the following examples:
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | <p><dl><group><text>for(e=0;e<10;e++) ;<br/>
</text></group></dl>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | <p><dl><group><text>e=10;<br/>
</text></group></dl>
</p>
<p><dl><group><text>write(e);<br/>
</text></group></dl>
</p>
<p><dl><group><text>if(foo) return bar; else return gazonk;<br/>
</text></group></dl>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </p>
<p>Statements beginning with for, while, switch, if, do or return will
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | not automatically return anything, and no result will be printed.
</p>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </text>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='if-else' homogen-type='method'>
<method name='if-else'/><doc placeholder='true'>
<text>
<p><tt>if-else</tt> - run on condition</p>
<tt><p>if( expression ) <i>statement</i><br/>
or<br/>
if( expression ) <i>statement</i> else <i>statement</i><br/>
</p>
</tt>
<p>If is the simplest of all control structures, in the first form
it runs the statement if the expression is true and in the second
form it runs the first statement if the expression is true and the
second if it is false.</p>
control</text>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <group><seealso/><text>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::switch' to='switch'>switch</ref></p>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='implode' homogen-type='method'>
<method name='implode'/><doc placeholder='true'>
<text>
<p><tt>implode</tt> - implode an array of strings</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>string implode(string *<i>a</i>, string <i>delimeter</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | or<br/>
a * delimeter<br/>
</p>
</tt>
<p>This function is the inverse of explode. It contatenates all the
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | strings in a with a delimeter in between each.
</p>
<p>This function is the same as multiplication.</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
<group><example/><text>
<tt><p>> implode( ({ "foo","bar","gazonk"}), "-" );<br/>
Result: foo-bar-gazonk<br/>
> ({ "a","b","c" })*" and ";<br/>
Result: a and b and c<br/>
> <br/>
</p>
|
fceb84 | 1995-11-16 | David Hedbor | | </tt>
string</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::explode' to='explode'>explode</ref></p>
</text></group>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='implode_nicely' homogen-type='method'>
<method name='implode_nicely'/><doc placeholder='true'>
<text>
<p><tt>implode_nicely</tt> - make an english comma separated list</p>
<tt><p>#include <string.h><br/>
</p>
<p>string implode_nicely(string *words, string|void separator)<br/>
</p>
</tt>
<p>This function implodes a list of words to a readable string.
If the separator is omitted, the default is 'and'.</p>
</text>
<group><example/><text>
<tt><p>> implode_nicely(({"green"}));<br/>
Result: green<br/>
> implode_nicely(({"green","blue"}));<br/>
Result: green and blue<br/>
> implode_nicely(({"green","blue","white"}));<br/>
Result: green, blue and white<br/>
> implode_nicely(({"green","blue","white"}),"or");<br/>
Result: green, blue or white<br/>
</p>
</tt>
string</text></group>
<group><seealso/><text>
<p><ref resolved='predef::`*' to='`*'>`*</ref></p>
</text></group>
|
563f98 | 1996-08-15 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='index' homogen-type='method'>
<method name='index'/><doc placeholder='true'>
<text>
<p><tt>index</tt> - get/set an element in an array/string/mapping/object</p>
<tt><p>a [ b ]<br/>
or<br/>
a [ b ] = c<br/>
or<br/>
a -> b<br/>
</p>
</tt>
<p><matrix>
<r><c> This operator does a lookup in 'a' to find the element named 'b' in </c></r>
<r><c> 'a'. The last syntax (a->b) is equal to a [ "b" ]. Different usage </c></r>
<r><c> applies </c><c> to different types. </c></r>
</matrix>
</p>
<p><matrix>
<r><c> Strings </c><c> With strings, the index operator can only be used to get values </c></r>
<r><c> </c><c> not change them. The index must be an integer, and the return value will be the ascii value of the corresponding character in the string. The first character is numbered 0. </c></r>
<r><c> Arrays </c><c> As with strings, arrays can only be indexed on integers. However, values can also be changed by using indexing on the left side of an assignment. The values in the array can have any type. As with strings, the first index is 0. </c></r>
<r><c> Mappings </c><c> Mappings can be indexed on any type of value, quite often they are indexed on strings. Values can be changed as with arrays. Mappings do not have a fixed size, nor do they have a specific order in which the values are stored. If you attempt to set a value in a mapping that does not already exists, the mapping will grow to include the new value. There is no 'first' index for mappings. </c></r>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <r><c> Multisets </c><c> Multisets can be also be indexed on any value, but the return value only reflects a true/false status depending on weather that index was present in the multiset. As with mappings, multisets will grow when you try to set a value in it that is does not already exists. However multisets will only grow if the inserted 'c' is nonzero. </c></r>
|
563f98 | 1996-08-15 | Fredrik Hübinette (Hubbe) | | <r><c> Object </c><c> Objects can only be indexed on strings. It then gets/sets the value of the variable with that name. If the 'variable' isn't a variable at all, but a function it will return a pointer to that function but you can't change it. </c></r>
</matrix>
</p>
</text>
<group><example/><text>
<tt><p><matrix>
<r><c> "foobar"[2] </c><c> returns 111 /* ascii for 'o' */ </c></r>
<r><c> "foobar"[0] </c><c> returns 102 /* ascii for 'f' */ </c></r>
<r><c> ({1,2,3})[1] </c><c> returns 2 </c></r>
<r><c> ([1:2})[1] </c><c> returns 2 </c></r>
<r><c> (<1,2,3>)[2] </c><c> returns 1 </c></r>
</matrix>
</p>
</tt>
operators</text></group>
<group><seealso/><text>
<p><ref resolved='predef::index' to='index'>index</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='indices' homogen-type='method'>
<method name='indices'/><doc placeholder='true'>
<text>
<p><tt>indices</tt> - return an array of all index possible for a value</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>mixed *indices(string|array|mapping|multiset|object <i>foo</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>Indices returns an array of all values you can use as index when
indexing foo. For strings and arrays this is simply an array of the
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | ascending numbers. For mappings and multisets, the array may contain any
|
3f0cfb | 1995-11-13 | David Hedbor | | kind of value. For objects, the result is an array of strings.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | mapping and multiset</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::values' to='values'>values</ref></p>
</text></group>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='inherit' homogen-type='method'>
<method name='inherit'/><doc placeholder='true'>
<text>
<p><tt>inherit</tt> - use definitions from another program</p>
<tt><p>inherit "<program name>";<br/>
or<br/>
inherit "<program name>" : local_name;<br/>
</p>
</tt>
<p><matrix>
<r><c> Inherit copies the global identifiers (functions and global variables) </c></r>
<r><c> from the named program. These functions and variables can then be </c></r>
<r><c> used as </c><c> if they were defined in this program. All the inherited </c></r>
<r><c> identifiers that was no declared as no_mask in the inherited program </c></r>
<r><c> can be also be redefined. The redefinition will not only </c></r>
<r><c> affect functions following the redefinition, but all functions in </c></r>
<r><c> this program, including the inherited ones. </c></r>
</matrix>
</p>
<p>Even if an identifier is redefined you can still access the original
though. Prepending the identifier name with :: will return the original
identifier, OR an array of all inherited identifiers with that name.
</p>
<p>You can also use the local_name to access a specific identifier, just
prepend it like 'local_name::identifier'. This will return the named
identifer in the program inherited with the given local_name. If no
local_name was given to inherit , the last part of the path in the
program name will be used as local_name.
</p>
<p>Inherit calls master()->cast_to_program(<program name>) to get the
program to inherit. For this reason there can be no inherits in the
master object.
</p>
<p>Inherit is not an expression or statement, it is a toplevel construct
and must not be written inside a function body.</p>
</text>
<group><example/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>/* This is file hworld.pike */<br/>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | int hello_world() { write("Hello world.\n"); }<br/>
</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>/* This is the file hello_world.pike */<br/>
inherit "hworld.pike";<br/>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <br/>
int main()<br/>
{<br/>
<dl><group><text>hello_world();<br/>
exit(0);<br/>
</text></group></dl>}<br/>
</p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | pike</text></group>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::class' to='class'>class</ref></p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | </text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='int' homogen-type='method'>
<method name='int'/><doc placeholder='true'>
<text>
<p><tt>int</tt> - integers numbers</p>
<tt><p>9797 /* decimal number */<br/>
0x20 /* hexadecimal number */<br/>
|
7491fd | 1995-10-11 | Fredrik Hübinette (Hubbe) | | 020 /* octal number */<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>This type stores an integer, normally it is 32 bits and use 4 bytes
of storage when used in a global variable.
</p>
<p>A list of operators that applies to ints follows:
</p>
<p>In this list a and b is used to represent an integer expression:
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p><matrix>
<r><c> a + b </c><c> summation </c></r>
<r><c> a - b </c><c> subtraction </c></r>
<r><c> a * b </c><c> multiplication </c></r>
<r><c> a / b </c><c> integer division </c></r>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <r><c> a % b </c><c> modulo ( same thing as a - ( a / b ) * b ) </c></r>
<r><c> a | b </c><c> bitwise or </c></r>
<r><c> a & b </c><c> bitwise and </c></r>
<r><c> a ^ b </c><c> bitwise xor </c></r>
<r><c> ! a </c><c> boolean not, returns 1 if a is zero 0 otherwise </c></r>
<r><c> ~ a </c><c> bitwise complement </c></r>
<r><c> - a </c><c> negation </c></r>
<r><c> a == b </c><c> return 1 if a is equal to b, 0 otherwise </c></r>
<r><c> a != b </c><c> return 0 if a is equal to b, 1 otherwise </c></r>
<r><c> a < b </c><c> returns 1 if a is lesser than b, 0 otherwise </c></r>
<r><c> a <= b </c><c> returns 1 if a is lesser or equal to b, 0 otherwise </c></r>
<r><c> a > b </c><c> returns 1 if a is greater than b, 0 otherwise </c></r>
<r><c> a >= b </c><c> returns 1 if a is greater or equal to b, 0 otherwise </c></r>
</matrix>
|
362e88 | 1996-10-15 | Fredrik Hübinette (Hubbe) | | </p>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | types</text>
|
362e88 | 1996-10-15 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::float' to='float'>float</ref></p>
|
362e88 | 1996-10-15 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='intp' homogen-type='method'>
<method name='intp'/><doc placeholder='true'>
|
362e88 | 1996-10-15 | Fredrik Hübinette (Hubbe) | | <text>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <p><tt>intp</tt> - is the argument an int?</p>
|
362e88 | 1996-10-15 | Fredrik Hübinette (Hubbe) | |
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <tt><p>array intp(mixed <i>arg</i>);<br/>
|
362e88 | 1996-10-15 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <p>Returns 1 if arg is an int, zero otherwise.</p>
|
362e88 | 1996-10-15 | Fredrik Hübinette (Hubbe) | |
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | int</text>
|
362e88 | 1996-10-15 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::arrayp' to='arrayp'>arrayp</ref>, <ref resolved='predef::programp' to='programp'>programp</ref>, <ref resolved='predef::floatp' to='floatp'>floatp</ref>, <ref resolved='predef::stringp' to='stringp'>stringp</ref>, <ref resolved='predef::objectp' to='objectp'>objectp</ref>, <ref resolved='predef::mappingp' to='mappingp'>mappingp</ref>, <ref resolved='predef::multisetp' to='multisetp'>multisetp</ref> and <ref resolved='predef::functionp' to='functionp'>functionp</ref></p>
|
362e88 | 1996-10-15 | Fredrik Hübinette (Hubbe) | | </text></group>
|
7491fd | 1995-10-11 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='kill' homogen-type='method'>
<method name='kill'/><doc placeholder='true'>
<text>
<p><tt>kill</tt> - send signal to other process</p>
<tt><p>int kill(int pid, int signal)<br/>
</p>
</tt>
<p>Kill sends a signal to another process. If something goes wrong
-1 is returned, 0 otherwise.
</p>
<p>Some signals and their supposed purpose:
</p>
<p><matrix>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <r><c> SIGHUP </c><c> Hangup, sent to process when user logs out </c></r>
<r><c> SIGINT </c><c> Interrupt, normally sent by ctrl-c </c></r>
<r><c> SIGQUIT </c><c> Quit, sent by ctrl-\ </c></r>
<r><c> SIGILL </c><c> Illegal instruction </c></r>
<r><c> SIGTRAP </c><c> Trap, mostly used by debuggers </c></r>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <r><c> SIGABRT </c><c> Aborts process, can be caught, used by Pike whenever something goes seriously wrong. </c></r>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <r><c> SIGBUS </c><c> Bus error </c></r>
<r><c> SIGFPE </c><c> Floating point error (such as division by zero) </c></r>
<r><c> SIGKILL </c><c> Really kill a process, cannot be caught </c></r>
<r><c> SIGUSR1 </c><c> Signal reserved for whatever you want to use it for. </c></r>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <r><c> SIGSEGV </c><c> Segmentation fault, caused by accessing memory where you shouldn't. Should never happen to Pike. </c></r>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <r><c> SIGUSR2 </c><c> Signal reserved for whatever you want to use it for. </c></r>
<r><c> SIGALRM </c><c> Signal used for timer interrupts. </c></r>
<r><c> SIGTERM </c><c> Termination signal </c></r>
<r><c> SIGSTKFLT </c><c> Stack fault </c></r>
<r><c> SIGCHLD </c><c> Child process died </c></r>
<r><c> SIGCONT </c><c> Continue suspended </c></r>
<r><c> SIGSTOP </c><c> Stop process </c></r>
<r><c> SIGSTP </c><c> Suspend process </c></r>
<r><c> SIGTTIN </c><c> tty input for background process </c></r>
<r><c> SIGTTOU </c><c> tty output for background process </c></r>
<r><c> SIGXCPU </c><c> Out of cpu </c></r>
<r><c> SIGXFSZ </c><c> File size limit exceeded </c></r>
<r><c> SIGPROF </c><c> Profile trap </c></r>
<r><c> SIGWINCH </c><c> Window change signal </c></r>
|
7491fd | 1995-10-11 | Fredrik Hübinette (Hubbe) | | </matrix>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
|
7491fd | 1995-10-11 | Fredrik Hübinette (Hubbe) | | </p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p>Note that you have to use signame to translate the name of a signal
to it's number.</p>
|
7491fd | 1995-10-11 | Fredrik Hübinette (Hubbe) | | </text>
<group><seealso/><text>
<p><ref resolved='predef::signal' to='signal'>signal</ref>, <ref resolved='predef::signum' to='signum'>signum</ref>, <ref resolved='predef::signame' to='signame'>signame</ref> and <ref resolved='predef::fork' to='predef::fork'>files/fork</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='l_sizeof' homogen-type='method'>
<method name='l_sizeof'/><doc placeholder='true'>
<text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>l_sizeof</tt> - Return the size of a multiset</p>
<tt><p>#include <simulate.h><br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | </p>
<p>int l_sizeof(multiset <i>m</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function is equal to sizeof.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | multiset</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::sizeof' to='predef::sizeof'>builtin/sizeof</ref></p>
|
7491fd | 1995-10-11 | Fredrik Hübinette (Hubbe) | | </text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='lambda' homogen-type='method'>
<method name='lambda'/><doc placeholder='true'>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <text>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p><tt>lambda</tt> - write nameless functions</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <tt><p>lambda(<argument specifications>) { <i>code</i> }<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p>Lambda let's you write a function as a value to a function call
or anywhere where you can enter an expression. Using lambda is
basically the same as defining the function before the current
function with a temporary name and then use the name instead.</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <group><example/><text>
<tt><p>/* These two lettersort routines are equal */<br/>
string *lettersort(string *words)<br/>
{<br/>
<dl><group><text>return sort_array(lettersort, lambda(string a,string b)<br/>
<dl><group><text>{<br/>
<dl><group><text>return a < b;<br/>
</text></group></dl>});<br/>
</text></group></dl></text></group></dl>}<br/>
</p>
<p>int tmp_cmp_fun(string a, string b)<br/>
{<br/>
<dl><group><text>return a < b;<br/>
</text></group></dl>}<br/>
</p>
<p>string *lettersort(string *words)<br/>
{<br/>
<dl><group><text>return sort_array(lettersort, tmp_cmp_fun);<br/>
</text></group></dl>}<br/>
</p>
</tt></text></group>
<group><note/><text>
<p>function_name() will return something for lambda functions,
what it returns is unspecified though.</p>
</text></group>
<group><bugs/><text>
<p>confuses the hell out of C indent programs</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | pike</text></group>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <group><seealso/><text>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::class' to='class'>class</ref> and <ref resolved='predef::function' to='function'>function</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='listp' homogen-type='method'>
<method name='listp'/><doc placeholder='true'>
<text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>listp</tt> - is the argument a list? (multiset)</p>
<tt><p>#include <simulate.h><br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | </p>
<p>int listp(mixed l)<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function is the same as multisetp.</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::multisetp' to='predef::multisetp'>builtin/multisetp</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
|
9f2499 | 1996-10-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='load_module' homogen-type='method'>
<method name='load_module'/><doc placeholder='true'>
<text>
<p><tt>load_module</tt> - load a binary module</p>
<tt><p>int load_module(string <i>module_name</i>);<br/>
</p>
</tt>
<p>This function loads a module written in C or some other language
into Pike. The module is initialized and any programs or constants
defined will immediately be available.
</p>
<p>When a module is loaded the functions init_module_efuns and
init_module_programs are called to initialize it. When Pike exits
exit_module is called in all dynamically loaded modules. These
functions _must_ be available in the module.
</p>
<p>Please see the source and any examples available at
ftp://www.infovav.se/pub/pike for more information on how to
write modules for Pike in C.</p>
</text>
<group><bugs/><text>
<p>Please use "./name.so" instead of just "foo.so" for the module
name. If you use just "foo.se" the module will not be found.
</p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='localtime' homogen-type='method'>
<method name='localtime'/><doc placeholder='true'>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <text>
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | <p><tt>localtime</tt> - break down time() into intelligible components</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | <tt><p>mapping(string:int) localtime(int <i>time</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | <p>Given a time represented as second since 1970, as returned by the
function time(), this function returns a mapping with the following
components:
</p>
<p><matrix>
<r><c> sec </c><c> seconds over the minute </c><c> 0 - 59 </c></r>
<r><c> min </c><c> minutes over the hour </c><c> 0 - 59 </c></r>
<r><c> hour </c><c> what hour in the day </c><c> 0 - 23 </c></r>
<r><c> mday </c><c> day of the month </c><c> 1 - 31 </c></r>
<r><c> mon </c><c> what month </c><c> 0 - 11 </c></r>
<r><c> year </c><c> years since 1900 </c><c> 0 - </c></r>
<r><c> wday </c><c> day of week (0=sunday) </c><c> 0 - 6 </c></r>
<r><c> yday </c><c> day of year </c><c> 0 - 365 </c></r>
<r><c> isdst </c><c> is daylight saving time </c><c> 0/1 </c></r>
<r><c> timezone </c><c> differance between </c></r>
<r><c> </c><c> </c><c> local time and UTC </c></r>
</matrix>
</p>
</text>
|
fceb84 | 1995-11-16 | David Hedbor | |
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | <group><note/><text>
<p>The 'timezone' might not be available on all platforms.</p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::time' to='time'>time</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='log' homogen-type='method'>
<method name='log'/><doc placeholder='true'>
<text>
<p><tt>log</tt> - Natural logarithm</p>
<tt><p>float log(float <i>f</i>);<br/>
</p>
</tt>
<p>Return the natural logarithm of f.
exp( log(x) ) == x for x > 0.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
float</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::pow' to='predef::pow'>math/pow</ref> and <ref resolved='predef::exp' to='predef::exp'>math/exp</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='lower_case' homogen-type='method'>
<method name='lower_case'/><doc placeholder='true'>
<text>
<p><tt>lower_case</tt> - convert a string to lower case</p>
<tt><p>string lower_case(string <i>s</i>);<br/>
</p>
</tt>
<p>Return a string with all capital letters converted to lower case.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
string</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::upper_case' to='upper_case'>upper_case</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='m_delete' homogen-type='method'>
<method name='m_delete'/><doc placeholder='true'>
<text>
<p><tt>m_delete</tt> - remove an index from a mapping</p>
<tt><p>mapping m_delete(mapping <i>map</i>, mixed <i>index</i>);<br/>
</p>
</tt>
<p>Remove the entry with index 'index' from mapping 'map' destructively.
Return the changed mapping. If the mapping does not have an
entry with index 'index', nothing is done.
Note that m_delete changes map destructively and only returns
the mapping for compatibility reasons.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
mapping</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::mappingp' to='mappingp'>mappingp</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='m_indices' homogen-type='method'>
<method name='m_indices'/><doc placeholder='true'>
<text>
<p><tt>m_indices</tt> - return all indices from a mapping</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>mixed *m_indices(mapping <i>m</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function is equal to indices</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
mapping</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::indices' to='predef::indices'>builtin/indices</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='m_sizeof' homogen-type='method'>
<method name='m_sizeof'/><doc placeholder='true'>
<text>
<p><tt>m_sizeof</tt> - Return the size of a mapping</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>int m_sizeof(mapping <i>m</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function is equal to sizeof.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
mapping</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::sizeof' to='predef::sizeof'>builtin/sizeof</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='m_values' homogen-type='method'>
<method name='m_values'/><doc placeholder='true'>
<text>
<p><tt>m_values</tt> - return all values from a mapping</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>mixed *m_values(mapping <i>m</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function is equal to values</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
mapping</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::values' to='predef::values'>builtin/values</ref></p>
</text></group>
</doc>
</docgroup>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='map' homogen-type='method'>
<method name='map'/><doc placeholder='true'>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | <text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>map</tt> - map an array or mapping over a function</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>mixed *map(mixed <i>arr</i>,function <i>fun</i>,mixed ... <i>args</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | or<br/>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | mixed *map(object *<i>arr</i>,string <i>fun</i>,mixed ... <i>args</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | or<br/>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | mixed *map(function *<i>arr</i>,-<i>1</i>,mixed ... <i>arg</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>First syntax:
Map array returns an array holding the items of arr mapped thrugh
the function fun. ie. arr[x]=fun(arr[x], @args) for all x.
</p>
<p>Second syntax:
Map array calls function fun in all objects in the array arr.
ie. arr[x]=arr[x]->fun(@ args);
</p>
<p>Third syntax:
Map array calls the functions in the array arr:
arr[x]=arr[x]->fun(@ args);</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
array</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::sum_arrays' to='sum_arrays'>sum_arrays</ref> and <ref resolved='predef::filter' to='filter'>filter</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='map_array' homogen-type='method'>
<method name='map_array'/><doc placeholder='true'>
<text>
<p><tt>map_array</tt> - map an array over a function</p>
<tt><p>mixed *map_array(mixed *<i>arr</i>,function <i>fun</i>,mixed ... <i>args</i>);<br/>
or<br/>
mixed *map_array(object *<i>arr</i>,string <i>fun</i>,mixed ... <i>args</i>);<br/>
or<br/>
mixed *map_array(function *<i>arr</i>,-<i>1</i>,mixed ... <i>arg</i>);<br/>
</p>
</tt>
<p>This function is the same as map.</p>
array</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::filter_array' to='filter_array'>filter_array</ref>, <ref resolved='predef::sum_arrays' to='sum_arrays'>sum_arrays</ref> and <ref resolved='predef::map' to='map'>map</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='mapping' homogen-type='method'>
<method name='mapping'/><doc placeholder='true'>
<text>
<p><tt>mapping</tt> - an associative array</p>
<tt><p>([ index1:data1, index2:data2 ])<br/>
</p>
</tt>
<p>A mapping is basically an array that can be indexed on any type, not
not just integers. It can also be seen as a way of linking data
(usaully strings) together. It consists of a lot of index-data pairs
which are linked togeter in such a way that map[index1] returns data1.
It is also possible to set that data by writing map[index1]=new_data1.
If you try to set an index in a mapping that isn't already present in
the mapping then it will be added.
</p>
<p>Here follows a list of operators that applies to mappings:
In this list a and b is used to represent a mapping expression:
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p><matrix>
|
2a82fd | 1996-03-24 | Fredrik Hübinette (Hubbe) | | <r><c> a + b </c><c> summation ( ([1:1]) + ([2:2,2:2]) returns ([1:1,2:2,2:2]) ) </c></r>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <r><c> a - b </c><c> subtraction, returns a copy of a with all pairs whos index is present in b removed. </c></r>
<r><c> a & b </c><c> intersection, return a mapping with all indices that are resent in both a and b, if an index is present in both a & b the data for that index will be taken from b. </c></r>
<r><c> a | b </c><c> union, return a mapping with all values that are present in a or b, differs from summation in that values that are present in both a and b are only returned once, as with intersection, data will be taken from b when possible. </c></r>
<r><c> a ^ b </c><c> xor, return a mapping with all indices that are present in a or b but not in both. </c></r>
<r><c> a == b </c><c> returns 1 if a is the same mapping as b, same size, indices and values is not enough, 0 otherwise. </c></r>
<r><c> a != b </c><c> returns 0 if a is the same mapping as b, same size, indices and values is not enough, 1 otherwise. </c></r>
<r><c> ! a </c><c> boolean not, returns 0 </c></r>
|
94e6f4 | 1996-05-02 | Fredrik Hübinette (Hubbe) | | <r><c> a[c] </c><c> indexing, returns the value associated with the value c in the mapping a. If there is no index c in the mapping zero will be returned. (With zero_type = 1) </c></r>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <r><c> a[c]=d </c><c> setting, this associates d with c in the mapping, the index c will be added to the mapping automatically if it isn't already there. </c></r>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </matrix>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | </p>
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | types</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::array' to='array'>array</ref>, <ref resolved='predef::multiset' to='multiset'>multiset</ref>, <ref resolved='predef::sizeof' to='predef::sizeof'>builtin/sizeof</ref>, <ref resolved='predef::indices' to='predef::indices'>builtin/indices</ref>, <ref resolved='predef::values' to='predef::values'>builtin/values</ref> and <ref resolved='predef::zero_type' to='predef::zero_type'>builtin/zero_type</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='mappingp' homogen-type='method'>
<method name='mappingp'/><doc placeholder='true'>
<text>
<p><tt>mappingp</tt> - is the argument an mapping?</p>
<tt><p>int mappingp(mixed <i>arg</i>);<br/>
</p>
</tt>
<p>Returns 1 if arg is a mapping, zero otherwise.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
mapping</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::intp' to='intp'>intp</ref>, <ref resolved='predef::programp' to='programp'>programp</ref>, <ref resolved='predef::arrayp' to='arrayp'>arrayp</ref>, <ref resolved='predef::stringp' to='stringp'>stringp</ref>, <ref resolved='predef::objectp' to='objectp'>objectp</ref>, <ref resolved='predef::multisetp' to='multisetp'>multisetp</ref>, <ref resolved='predef::floatp' to='floatp'>floatp</ref> and <ref resolved='predef::functionp' to='functionp'>functionp</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='master' homogen-type='method'>
<method name='master'/><doc placeholder='true'>
<text>
<p><tt>master</tt> - return the master object</p>
<tt><p>object master();<br/>
</p>
</tt>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p>Master is added by the master object to make it easier to access it.</p>
object</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
</doc>
</docgroup>
<docgroup homogen-name='member_array' homogen-type='method'>
<method name='member_array'/><doc placeholder='true'>
<text>
<p><tt>member_array</tt> - find first occurance of a value in an array</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>int member_array(mixed <i>item</i>, mixed *<i>arr</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>Returns the index of the first occurence of item in array arr.
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | If not found, then -1 is returned.</p>
array</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='mixed' homogen-type='method'>
<method name='mixed'/><doc placeholder='true'>
<text>
<p><tt>mixed</tt> - any type</p>
<p>This is not really a type. But this keyword can be used to specify
that a variable, argument or return type can be of any type.</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | <group><example/><text>
<tt><p>mixed i=1;<br/>
mixed j="foo";<br/>
mixed foo() { return "bar"; }<br/>
mixed bar() { return ({}); }<br/>
</p>
</tt>
types</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='mkdir' homogen-type='method'>
<method name='mkdir'/><doc placeholder='true'>
<text>
<p><tt>mkdir</tt> - make directory</p>
<tt><p>int mkdir(string <i>dirname</i>);<br/>
</p>
</tt>
<p>Create a directory, return zero if it fails and nonzero if it fails.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
file</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::rm' to='predef::rm'>files/rm</ref> and <ref resolved='predef::cd' to='predef::cd'>files/cd</ref></p>
</text></group>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='mklist' homogen-type='method'>
<method name='mklist'/><doc placeholder='true'>
<text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>mklist</tt> - make a multiset</p>
<tt><p>#include <simulate.h><br/>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | </p>
<p>multiset mklist(mixed *a)<br/>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function creates a multiset from an array.</p>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </text>
<group><example/><text>
<tt><p>> mklist( ({1,2,3}) );<br/>
Result: (< /* 3 elements */<br/>
<dl><group><text>1,<br/>
2,<br/>
3<br/>
</text></group></dl>>)<br/>
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | </tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | multiset</text></group>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::aggregate_multiset' to='predef::aggregate_multiset'>builtin/aggregate_multiset</ref></p>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='mkmapping' homogen-type='method'>
<method name='mkmapping'/><doc placeholder='true'>
<text>
<p><tt>mkmapping</tt> - make a mapping from two arrays</p>
<tt><p>mapping mkmapping(mixed *<i>ind</i>, mixed *<i>val</i>);<br/>
</p>
</tt>
<p>Makes a mapping ind[x]:val[x], 0<=x<sizeof(ind).
Ind and val must have the same size.
This is the inverse operation of indices and values.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
mapping</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::indices' to='indices'>indices</ref> and <ref resolved='predef::values' to='values'>values</ref></p>
</text></group>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='mkmultiset' homogen-type='method'>
<method name='mkmultiset'/><doc placeholder='true'>
<text>
<p><tt>mkmultiset</tt> - make a multiset</p>
<tt><p>multiset mkmultiset(mixed *a)<br/>
</p>
</tt>
<p>This function creates a multiset from an array.</p>
</text>
<group><example/><text>
<tt><p>> mkmultiset( ({1,2,3}) );<br/>
Result: (< /* 3 elements */<br/>
<dl><group><text>1,<br/>
2,<br/>
3<br/>
</text></group></dl>>)<br/>
</p>
</tt>
multiset</text></group>
<group><seealso/><text>
<p><ref resolved='predef::aggregate_multiset' to='predef::aggregate_multiset'>builtin/aggregate_multiset</ref></p>
</text></group>
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='modifier' homogen-type='method'>
<method name='modifier'/><doc placeholder='true'>
<text>
<p><tt>modifier</tt> - modify function / variable definitions</p>
<p>Modifiers makes it possible to give functions and gobal variables
certain characteristics. A list of modifiers follows:
</p>
<p><matrix>
<r><c> static </c><c> make this identifier unavailable by indexing </c></r>
<r><c> inline </c><c> allow inlining this function </c></r>
<r><c> private </c><c> hide this identifier to inheriting programs </c></r>
<r><c> nomask </c><c> don't allow this identifier to be re-defined </c></r>
</matrix>
</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | pike</text>
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::functions' to='functions'>functions</ref> and <ref resolved='predef::variables' to='variables'>variables</ref></p>
</text></group>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='multiset' homogen-type='method'>
<method name='multiset'/><doc placeholder='true'>
<text>
<p><tt>multiset</tt> - a set of values</p>
<tt><p>(< 1, 7, 8, 9 >)<br/>
</p>
</tt>
<p>A multiset is basically a mapping without data values, when indexing a
multiset 1 willl be returned if the index is present, zero otherwise.
</p>
<p>Here follows a list of operators that applies to multisets:
In this list a and b is used to represent a multiset expression:
</p>
<p><matrix>
<r><c> a + b </c><c> summation ( (<1>) + (<2>) returns (<1,2>) ) </c></r>
<r><c> a - b </c><c> subtraction, returns a copy of a with all values that are present in b removed. </c></r>
<r><c> a & b </c><c> intersection, return a multiset with all values that are present in both a & b. </c></r>
<r><c> a | b </c><c> union, return a multiset with all values that are present in a or b, differs from summation in that values that are present in both a and b are only returned once. </c></r>
<r><c> a ^ b </c><c> xor, return a multiset with all indices that are present in a or b but not in both. </c></r>
<r><c> a == b </c><c> returns 1 if a is the same multiset as b, same size and values is not enough. </c></r>
<r><c> a != b </c><c> returns 1 if a is the same multiset as b, same size and values is not enough. </c></r>
<r><c> ! a </c><c> boolean not, returns 0 </c></r>
<r><c> a[c] </c><c> indexing, returns 1 c is present in the multiset a. </c></r>
<r><c> a[c]=d </c><c> setting, if d is true, c is added to the multiset if it is not present already. If d is false, it is removed if it is present. </c></r>
</matrix>
</p>
types</text>
<group><seealso/><text>
<p><ref resolved='predef::mapping' to='mapping'>mapping</ref>, <ref resolved='predef::array' to='array'>array</ref>, <ref resolved='predef::indices' to='predef::indices'>builtin/indices</ref> and <ref resolved='predef::sizeof' to='predef::sizeof'>builtin/sizeof</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='multisetp' homogen-type='method'>
<method name='multisetp'/><doc placeholder='true'>
<text>
<p><tt>multisetp</tt> - is the argument a multiset?</p>
<tt><p>int multisetp(mixed <i>arg</i>);<br/>
</p>
</tt>
<p>Returns 1 if arg is a multiset, zero otherwise.</p>
multiset</text>
<group><seealso/><text>
<p><ref resolved='predef::intp' to='intp'>intp</ref>, <ref resolved='predef::programp' to='programp'>programp</ref>, <ref resolved='predef::arrayp' to='arrayp'>arrayp</ref>, <ref resolved='predef::stringp' to='stringp'>stringp</ref>, <ref resolved='predef::objectp' to='objectp'>objectp</ref>, <ref resolved='predef::mappingp' to='mappingp'>mappingp</ref>, <ref resolved='predef::floatp' to='floatp'>floatp</ref> and <ref resolved='predef::functionp' to='functionp'>functionp</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='mv' homogen-type='method'>
<method name='mv'/><doc placeholder='true'>
<text>
<p><tt>mv</tt> - move a file (may handle directiories as well)</p>
<tt><p>int mv(string <i>from</i>,string <i>to</i>);<br/>
</p>
</tt>
<p>Rename or move a file between directories. If the destination
file already exists, it will be overwritten. Returns 1 on sucess,
0 otherwise.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
file</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::rm' to='predef::rm'>files/rm</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='next_object' homogen-type='method'>
<method name='next_object'/><doc placeholder='true'>
<text>
<p><tt>next_object</tt> - get next object</p>
<tt><p>object next_object(object <i>o</i>);<br/>
or<br/>
object next_object();<br/>
</p>
</tt>
<p>All objects are stored in a linked list, next_object() returns the
first object in this list, and next_object(o) the next object in the
list after o.</p>
</text>
<group><example/><text>
<tt><p>/* This example calls shutting_down() in all cloned objects */<br/>
object o;<br/>
for(o=next_object();o;o=next_object(o))<br/>
<dl><group><text>o->shutting_down();<br/>
</text></group></dl></p>
|
fceb84 | 1995-11-16 | David Hedbor | | </tt>
object</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::clone' to='clone'>clone</ref> and <ref resolved='predef::destruct' to='destruct'>destruct</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='object' homogen-type='method'>
<method name='object'/><doc placeholder='true'>
<text>
<p><tt>object</tt> - an instance of a class (program)</p>
<p>There is no syntax example in this file because there is no way to
write constant object. The only way to make new objects is to use
clone() on a program.
</p>
<p>Here follows a list of operators that applies to objects:
In this list, o and o2 are used to represent object expressions,
and s is a string expression:
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p><matrix>
<r><c> o[s] </c><c> indexing, returns the identifier named s in the object o, </c></r>
<r><c> </c><c> an identifier is a global variable or a function. </c></r>
<r><c> o[s]=c </c><c> This sets the global variable s int the object o to c, if s is a function however, an error is produced. </c></r>
<r><c> o->foo </c><c> same as o["foo"] </c></r>
<r><c> o == o2 </c><c> return 1 if o and o2 are the same object </c></r>
<r><c> o != o2 </c><c> return 0 if o and o2 are the same object </c></r>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </matrix>
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | types</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::program' to='program'>program</ref>, <ref resolved='predef::function' to='function'>function</ref>, <ref resolved='predef::clone' to='predef::clone'>builtin/clone</ref> and <ref resolved='predef::destruct' to='predef::destruct'>builtin/destruct</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='object_program' homogen-type='method'>
<method name='object_program'/><doc placeholder='true'>
<text>
<p><tt>object_program</tt> - get the program asociated with the object</p>
<tt><p>program object_program(object <i>o</i>);<br/>
</p>
</tt>
<p>This function returns the program from which o was cloned.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
object</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::clone' to='clone'>clone</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='objectp' homogen-type='method'>
<method name='objectp'/><doc placeholder='true'>
<text>
<p><tt>objectp</tt> - is the argument an object?</p>
<tt><p>int objectp(mixed <i>arg</i>);<br/>
</p>
</tt>
<p>Returns 1 if arg is an object, zero otherwise.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
object</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::intp' to='intp'>intp</ref>, <ref resolved='predef::programp' to='programp'>programp</ref>, <ref resolved='predef::floatp' to='floatp'>floatp</ref>, <ref resolved='predef::stringp' to='stringp'>stringp</ref>, <ref resolved='predef::arrayp' to='arrayp'>arrayp</ref>, <ref resolved='predef::mappingp' to='mappingp'>mappingp</ref>, <ref resolved='predef::multisetp' to='multisetp'>multisetp</ref> and <ref resolved='predef::functionp' to='functionp'>functionp</ref></p>
|
de3cbb | 1995-10-11 | Fredrik Hübinette (Hubbe) | | </text></group>
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='operators' homogen-type='method'>
<method name='operators'/><doc placeholder='true'>
<text>
<p><tt>operators</tt> - arethmics and other stuff</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>Pike has the following operators:
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | </p>
<p><matrix>
<r><c> a(args) </c><c> function call </c></r>
<r><c> a[b..c] </c><c> range </c></r>
<r><c> a[b] </c><c> index </c></r>
<r><c> --a </c><c> pre decrement </c></r>
<r><c> a-- </c><c> post decrement </c></r>
<r><c> ++a </c><c> pre increment </c></r>
<r><c> a++ </c><c> post increment </c></r>
<r><c> (type)a </c><c> cast </c></r>
<r><c> ~a </c><c> complement </c></r>
<r><c> !a </c><c> not </c></r>
<r><c> -a </c><c> negate </c></r>
<r><c> a/b </c><c> divide </c></r>
<r><c> a%b </c><c> modulo </c></r>
<r><c> a*b </c><c> multiply </c></r>
<r><c> a-b </c><c> subtract </c></r>
<r><c> a+b </c><c> add </c></r>
<r><c> >> </c><c> shift right </c></r>
<r><c> << </c><c> shift left </c></r>
<r><c> a>b </c><c> greater than? </c></r>
<r><c> a<b </c><c> lesser than? </c></r>
<r><c> a>=b </c><c> greater or equal than? </c></r>
<r><c> a<=b </c><c> lesser or equal than? </c></r>
<r><c> a!=b </c><c> not equal to? </c></r>
<r><c> a==b </c><c> equal to? </c></r>
<r><c> a&b </c><c> intersection </c></r>
<r><c> a^b </c><c> xor (symmetric differance) </c></r>
<r><c> a|b </c><c> union </c></r>
<r><c> a&&b </c><c> logical and </c></r>
<r><c> a||b </c><c> logical or </c></r>
<r><c> a?b:c </c><c> condition </c></r>
<r><c> a=b </c><c> assignment </c></r>
</matrix>
</p>
<p>The ones at the top of the list are parsed before operators lower
down on the list. This means that a|b&c means a|(b&c) not (a|b)&c.
Look at the individual pages for fuller explanations of what they do.
</p>
<p>Then there is also the @ "splice" operator which can only be used in
argument lists.
</p>
<p>Arguments to operators are always computed from left to right.
</p>
<p>Many (but not all) of these operators can also be used as by prepending
with a ` sign. For instance `+(a,b) is the same as a+b. These functions
are called "operator functions" and the following are currently
available:
</p>
<p>`== `!= `! `< `<= `> `>= `+ `- `& `| `^ `<< `>> `* `/ `% `~
</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>These operator functions are basically "efuns", but beware, if you
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | re-define the `+ function a+b will also be redefined.
</p>
<p>On top of all this, many operators can also be overloaded. Overloading
an operator lets you specify how operators works on your objects.
To overload an operator you simply put the corresponding operator
function as a method in your object. An example:
</p>
<p>> program nine=class {<br/>
<dl><group><text>int `+(int arg) { return arg+9; }<br/>
</text></group></dl>};<br/>
Result: program<br/>
> clone(nine)+1;<br/>
Result: 10<br/>
><br/>
</p>
<p>This little example defines a program that works almost like the number
nine. As you can see, clone(nine)+1 is the same as clone(nine)->`+(1)
in this case, and that is the whole point of operator overloading.
Note however that it would not have worked to write 1+clone(nine)
because operator overloading only works if the first argument is the
object with the overloaded function. Well, almost anyway, the operators
<, >, <=, >= can check both sides. In fact, the methods `<= and `>=
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | will never be called since Pike will translate a<=b to !(a>b).
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | </p>
<p>These are the operators you can overload:
</p>
<p><matrix>
<r><c> `== </c><c> also overloads `!= </c></r>
<r><c> `! </c><c> This is also used by if-statements to find out if the object in question is 'true' or not. </c></r>
<r><c> `< </c><c> also overloads `>= </c></r>
<r><c> `> </c><c> also overloads `<= </c></r>
<r><c> `+ </c><c> </c></r>
<r><c> `- </c><c> </c></r>
<r><c> `& </c><c> </c></r>
<r><c> `| </c><c> </c></r>
<r><c> `^ </c><c> </c></r>
<r><c> `<< </c><c> </c></r>
<r><c> `>> </c><c> </c></r>
<r><c> `* </c><c> </c></r>
<r><c> `/ </c><c> </c></r>
<r><c> `% </c><c> </c></r>
<r><c> `~ </c><c> </c></r>
</matrix>
</p>
<p>If you also define a function __hash to return an integer, which
must be equal for all objects where `== is true you can index mappings
on the contents of your objects rather than on the object itself.
More details about this will come later.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::operators' to='/precompiled/mpz'>/precompiled/mpz</ref></p>
|
de3cbb | 1995-10-11 | Fredrik Hübinette (Hubbe) | | </text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='perror' homogen-type='method'>
<method name='perror'/><doc placeholder='true'>
<text>
<p><tt>perror</tt> - print error</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <stdio.h><br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>void perror(string <i>s</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | </tt>
<p>This function prints a message to stderr along with a description
of what went wrong if available. It uses the system errno to find
out what went wrong, so it is only applicable to IO errors.</p>
file</text>
<group><seealso/><text>
<p><ref resolved='predef::werror' to='werror'>werror</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
</doc>
</docgroup>
<docgroup homogen-name='popen' homogen-type='method'>
<method name='popen'/><doc placeholder='true'>
<text>
<p><tt>popen</tt> - pipe open</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <process.h><br/>
</p>
<p>string popen(string <i>cmd</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
64a636 | 1995-10-20 | Fredrik Hübinette (Hubbe) | | <p>This function runs the command cmd as in a shell and returns the
output. See your unix/C manual for details on popen.
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
<p/>
</text>
</doc>
</docgroup>
<docgroup homogen-name='pow' homogen-type='method'>
<method name='pow'/><doc placeholder='true'>
<text>
<p><tt>pow</tt> - Raise a number to the power of another.</p>
|
fceb84 | 1995-11-16 | David Hedbor | | <tt><p>float pow(float <i>n</i>, float <i>x</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>Return n raised to the power of x.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
float</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::exp' to='predef::exp'>math/exp</ref> and <ref resolved='predef::log' to='predef::log'>math/log</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='previous_object' homogen-type='method'>
<method name='previous_object'/><doc placeholder='true'>
<text>
<p><tt>previous_object</tt> - return the calling object</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>object previous_object();<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>Returns an object pointer to the object that called current function,
if any.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::call_function' to='predef::call_function'>builtin/call_function</ref> and <ref resolved='predef::backtrace' to='predef::backtrace'>builtin/backtrace</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='program' homogen-type='method'>
<method name='program'/><doc placeholder='true'>
<text>
<p><tt>program</tt> - a class, or blueprint for an object</p>
<p>There is no syntax example in this file because there is no way to
write constant programs. (yet) New programs are made with
compile_file() or compile_string(). Programs are only useful as
arguments to clone() and the only operators that applies to programs
are == and !=.</p>
</text>
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | <group><note/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>In Pike the term 'program' is somewhat confusing, becuase it is used
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | both to reference a complete runnable software package, and to a
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | structure in Pike containing code.</p>
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | |
types</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::object' to='object'>object</ref>, <ref resolved='predef::function' to='function'>function</ref>, <ref resolved='predef::compile_file' to='predef::compile_file'>builtin/compile_file</ref>, <ref resolved='predef::compile_string' to='predef::compile_string'>builtin/compile_string</ref> and <ref resolved='predef::clone' to='predef::clone'>builtin/clone</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='programp' homogen-type='method'>
<method name='programp'/><doc placeholder='true'>
<text>
<p><tt>programp</tt> - is the argument an program?</p>
<tt><p>int programp(mixed <i>arg</i>);<br/>
</p>
</tt>
<p>Returns 1 if arg is a program, zero otherwise.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
program</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::intp' to='intp'>intp</ref>, <ref resolved='predef::multisetp' to='multisetp'>multisetp</ref>, <ref resolved='predef::arrayp' to='arrayp'>arrayp</ref>, <ref resolved='predef::stringp' to='stringp'>stringp</ref>, <ref resolved='predef::objectp' to='objectp'>objectp</ref>, <ref resolved='predef::mappingp' to='mappingp'>mappingp</ref>, <ref resolved='predef::floatp' to='floatp'>floatp</ref> and <ref resolved='predef::functionp' to='functionp'>functionp</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
|
ab5bd4 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='putenv' homogen-type='method'>
<method name='putenv'/><doc placeholder='true'>
<text>
<p><tt>putenv</tt> - put environment variable</p>
<tt><p>void putenv(string <i>varname</i>, string <i>value</i>);<br/>
</p>
</tt>
<p>This function sets the environment variable 'varname' to 'value'.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::getenv' to='getenv'>getenv</ref> and <ref resolved='predef::exece' to='exece'>exece</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='query_host_name' homogen-type='method'>
<method name='query_host_name'/><doc placeholder='true'>
<text>
<p><tt>query_host_name</tt> - return the name of the host we are running on</p>
<tt><p>string query_host_name();<br/>
</p>
</tt>
<p>This function returns the name of the machine the interpreter is
running on. This is the same thing that the command 'hostname'
prints.
</p>
</text>
</doc>
</docgroup>
<docgroup homogen-name='query_num_arg' homogen-type='method'>
<method name='query_num_arg'/><doc placeholder='true'>
<text>
<p><tt>query_num_arg</tt> - find out how many arguments were given</p>
<tt><p>int query_num_arg();<br/>
</p>
</tt>
<p>Query_num_arg returns the number of arguments given when this
function was called. This is only useful for varargs functions.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::call_function' to='call_function'>call_function</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='random' homogen-type='method'>
<method name='random'/><doc placeholder='true'>
<text>
<p><tt>random</tt> - return a random number</p>
<tt><p>int random(int <i>max</i>);<br/>
</p>
</tt>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <p>This function returns a random number in the range 0 - max-1.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
int</text>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::random_seed' to='random_seed'>random_seed</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='random_seed' homogen-type='method'>
<method name='random_seed'/><doc placeholder='true'>
<text>
<p><tt>random_seed</tt> - seed random generator</p>
<tt><p>void random_seed(int <i>seed</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </tt>
<p>This function sets the initial value for the random generator.</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <group><example/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>Pike v1.0E-13 Running Hilfe v1.2 (Hubbe's Incremental Pike FrontEnd)<br/>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | > random_seed(17);<br/>
Result: 0<br/>
> random(1000);<br/>
Result: 732<br/>
> random(1000);<br/>
Result: 178<br/>
> random(1000);<br/>
Result: 94<br/>
> random_seed(17);<br/>
Result: 0<br/>
> random(1000);<br/>
Result: 732<br/>
> random(1000);<br/>
Result: 178<br/>
> random(1000);<br/>
Result: 94<br/>
><br/>
</p>
|
fceb84 | 1995-11-16 | David Hedbor | | </tt>
|
203da9 | 1995-11-20 | Fredrik Hübinette (Hubbe) | | int</text></group>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::random' to='random'>random</ref></p>
</text></group>
|
6d49eb | 1996-03-29 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='range' homogen-type='method'>
<method name='range'/><doc placeholder='true'>
<text>
<p><tt>range</tt> - cut a slice of an array or string</p>
<tt><p>a [ b .. c ]<br/>
or<br/>
a [ .. c ]<br/>
or<br/>
a [ b .. ]<br/>
</p>
</tt>
<p>This operator cuts out a piece of an array or string. If a is an array
a[b..c] will return an array containing a[b], a[b+1], a[b+2] to a[c].
Given a string about the same thing will happen, except the the result
will be a string of course. If b is omitted, everything from the
beginning up to and including c will be included. If c is omitted
the result will include everything from (and including) b to the end.</p>
</text>
<group><example/><text>
<tt><p><matrix>
|
d3910d | 1996-05-13 | Fredrik Hübinette (Hubbe) | | <r><c> "foobar"[0..2] </c><c> returns "foo" </c></r>
<r><c> "foobar"[3..5] </c><c> returns "bar" </c></r>
<r><c> ({1,2,3})[..1] </c><c> returns ({1,2}) </c></r>
<r><c> ({1,2,3})[1..] </c><c> returns ({2,3}) </c></r>
|
6d49eb | 1996-03-29 | Fredrik Hübinette (Hubbe) | | <r><c> ({1,2,3})[..] </c><c> returns ({1,2,3}) </c></r>
</matrix>
</p>
</tt>
operators</text></group>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
563f98 | 1996-08-15 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::index' to='index'>index</ref></p>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='read_bytes' homogen-type='method'>
<method name='read_bytes'/><doc placeholder='true'>
<text>
<p><tt>read_bytes</tt> - read a number of bytes into a string from a file</p>
|
06fa8e | 1996-10-24 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <stdio.h><br/>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | |
</p>
<p>string read_bytes(string <i>file</i>,int <i>start</i>,int <i>len</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>Read len number of bytes from file file staring at byte start and
return it as a string.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
file</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::write_file' to='write_file'>write_file</ref></p>
</text></group>
|
06fa8e | 1996-10-24 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <docgroup homogen-name='read_file' homogen-type='method'>
<method name='read_file'/><doc placeholder='true'>
|
06fa8e | 1996-10-24 | Fredrik Hübinette (Hubbe) | | <text>
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | <p><tt>read_file</tt> - read a number of lines into a string from file</p>
|
06fa8e | 1996-10-24 | Fredrik Hübinette (Hubbe) | |
<tt><p>#include <stdio.h><br/>
</p>
<p>string read_file(string <i>file</i>, int <i>start</i>, int <i>len</i>);<br/>
</p>
</tt>
<p>Read 'len' lines from the file 'file' after skipping 'start' lines
and return those lines as a string. If start and len are omitted
the whole file is read.</p>
file</text>
<group><seealso/><text>
<p><ref resolved='predef::read_bytes' to='read_bytes'>read_bytes</ref> and <ref resolved='predef::write_file' to='write_file'>write_file</ref></p>
</text></group>
|
9e25d9 | 1996-07-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='readline' homogen-type='method'>
<method name='readline'/><doc placeholder='true'>
<text>
<p><tt>readline</tt> - read a line from stdin</p>
<tt><p>string readline(string <i>prompt</i>);<br/>
</p>
</tt>
<p>This function writes the string 'prompt' and then waits until the
user has entered a line from the keyboard. If the readline library
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | was available when Pike was compiled the user will have history and
|
9e25d9 | 1996-07-09 | Fredrik Hübinette (Hubbe) | | line edithing at his/her disposal when entering the line.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::/precompiled/file' to='predef::file'>files/file</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='regexp' homogen-type='method'>
<method name='regexp'/><doc placeholder='true'>
<text>
<p><tt>regexp</tt> - filter an array through a regexp</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>string *regexp(string *<i>arr</i>, string <i>reg</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>Return those strings in arr that matches the regexp in reg.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
string</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::regexp' to='regexp/regexp'>regexp/regexp</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='remove_call_out' homogen-type='method'>
<method name='remove_call_out'/><doc placeholder='true'>
<text>
<p><tt>remove_call_out</tt> - remove a call out from the call out queue</p>
<tt><p>int remove_call_out(function <i>f</i>);<br/>
|
c1a125 | 1996-08-06 | Fredrik Hübinette (Hubbe) | | or<br/>
int remove_call_out(function <i>id</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>This function finds the first call to the function f in the call
out queue and removes it. The time left to that call out will be
returned. If no call out was found, zero_type(remove_call_out(f))
|
c1a125 | 1996-08-06 | Fredrik Hübinette (Hubbe) | | will return 1. You can also give a call out id as argument. (as
returned by call_out)</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
<group><seealso/><text>
<p><ref resolved='predef::call_out_info' to='call_out_info'>call_out_info</ref>, <ref resolved='predef::call_out' to='call_out'>call_out</ref> and <ref resolved='predef::find_call_out' to='find_call_out'>find_call_out</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='replace' homogen-type='method'>
<method name='replace'/><doc placeholder='true'>
<text>
<p><tt>replace</tt> - generic replace function</p>
<tt><p>string replace(string <i>s</i>, string <i>from</i>, string <i>to</i>);<br/>
or<br/>
string replace(string <i>s</i>, string *<i>from</i>, string *<i>to</i>);<br/>
or<br/>
array replace(array <i>a</i>, mixed <i>from</i>, mixed <i>to</i>);<br/>
or<br/>
mapping replace(mapping <i>a</i>, mixed <i>from</i>, mixed <i>to</i>);<br/>
</p>
</tt>
<p>This function can do several kinds replacement operations, the
different syntaxes do different things as follow:
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p>string replace(string s, string from, string to);
</p>
<p><dl><group><text>When given strings as second and third argument, a copy of<br/>
|
94e6f4 | 1996-05-02 | Fredrik Hübinette (Hubbe) | | s with every occurance of 'from' return 'to' is returned.<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group></dl>
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p>string replace(string s, string *from, string *to);
</p>
<p><dl><group><text>When given arrays of strings as second and third argument,<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | every occurance of from[0] in s is replaced by to[0],<br/>
from[1] is replaced by to[1] and so on...<br/>
</text></group></dl>
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p><matrix>
<r><c> array replace(array a, mixed from, mixed to); </c><c> </c></r>
<r><c> mapping replace(mapping a, mixed from, mixed to); </c></r>
</matrix>
</p>
<p><dl><group><text>When the first argument is an array or mapping, the values in<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | a are searched for values equal to from, which are replaced by<br/>
to destructively.<br/>
|
fceb84 | 1995-11-16 | David Hedbor | | </text></group></dl></p>
string, array and mapping</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='return' homogen-type='method'>
<method name='return'/><doc placeholder='true'>
<text>
<p><tt>return</tt> - return from a function</p>
<tt><p>return<br/>
or<br/>
return <i>expression</i><br/>
</p>
</tt>
<p>Return jumps directly out of a function returning the given value to
the calling function. If no expression is given, 0 is returned.</p>
control</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='reverse' homogen-type='method'>
<method name='reverse'/><doc placeholder='true'>
<text>
<p><tt>reverse</tt> - reverse a string, array or int</p>
<tt><p>string reverse(string <i>s</i>);<br/>
or<br/>
array reverse(arary <i>a</i>);<br/>
or<br/>
int reverse(int <i>i</i>);<br/>
</p>
</tt>
<p>This function reverseses a string, char by char, an array, value
by value or an int, bit by bit and returns the result. Reversing
strings can be particularly useful for parsing difficult syntaxes
which require scanning backwards.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
string, array and int</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::sscanf' to='sscanf'>sscanf</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='rm' homogen-type='method'>
<method name='rm'/><doc placeholder='true'>
<text>
<p><tt>rm</tt> - remove file or directory</p>
<tt><p>int rm(string <i>f</i>);<br/>
</p>
</tt>
<p>Remove a file or directory, return 0 if it fails. Nonzero otherwise.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
file</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::mkdir' to='predef::mkdir'>files/mkdir</ref></p>
</text></group>
|
234b6d | 1996-06-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='rows' homogen-type='method'>
<method name='rows'/><doc placeholder='true'>
<text>
<p><tt>rows</tt> - select a set of rows from an array</p>
<tt><p>array rows(mixed data, mixed *index)<br/>
</p>
</tt>
<p>This function is exactly equivialent to:
</p>
<p>map_array(index,lambda(mixed x,mixed y) { return y[x]; },data)
</p>
<p>Except of course it is a lot shorter and faster.
That is, it indexes data on every index in the array index and
returns an array with the results.</p>
array</text>
<group><seealso/><text>
<p><ref resolved='predef::column' to='column'>column</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='rusage' homogen-type='method'>
<method name='rusage'/><doc placeholder='true'>
<text>
<p><tt>rusage</tt> - return resource usage</p>
<tt><p>int *rusage();<br/>
</p>
</tt>
<p>This function returns an array of ints describing how much resources
the intepreter process has used so far. This array will have at least
29 elements, of which those values not available on this system will
be zero. The elements are as follows:
</p>
<p>0: user time
1: system time
2: maxrss
3: idrss
4: isrss
5: minflt
6: minor pagefaults
7: major pagefaults
8: swaps
9: block input op.
10: block output op.
11: messages sent
12: messages received
13: signals received
14: voluntary context switches
15: involuntary context switches
16: sysc
17: ioch
18: rtime
19: ttime
20: tftime
21: dftime
22: kftime
23: ltime
24: slptime
25: wtime
26: stoptime
27: brksize
28: stksize
</p>
<p>Don't ask me to explain these values, read your system manuals for
more information. (Note that all values may not be present though)</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::time' to='time'>time</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='search' homogen-type='method'>
<method name='search'/><doc placeholder='true'>
<text>
<p><tt>search</tt> - search for a value in a string or array</p>
<tt><p>int search(string <i>haystack</i>, string <i>needle</i>, [ int <i>start</i> ]);<br/>
or<br/>
int search(mixed *<i>haystack</i>, mixed <i>needle</i>, [ int <i>start</i> ]);<br/>
or<br/>
mixed search(mapping <i>haystack</i>, mixed <i>needle</i>, [ mixed <i>start</i> ]);<br/>
</p>
</tt>
<p>Search for needle in haystack. Return the position of needle in
haystack or -1 if not found. If the optional argument start is present
search is started at this position. Note that when haystack is a string
needle must be a string, and the first occurance of this string is
returned. However, when haystack is an array, needle is compared only
to one value at a time in haystack.
</p>
<p>When the haystack is a mapping, search tries to find the index
connected to the data needle. That is, it tries to lookup the mapping
backwards. If needle isn't present in the mapping, zero is returned,
and zero_type() will return 1 for this zero.</p>
</text>
<group><note/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function replaces strstr and member_array from Pike4.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
string, array and mapping</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::indices' to='indices'>indices</ref>, <ref resolved='predef::values' to='values'>values</ref> and <ref resolved='predef::zero_type' to='zero_type'>zero_type</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='search_array' homogen-type='method'>
<method name='search_array'/><doc placeholder='true'>
<text>
<p><tt>search_array</tt> - search for something in an array</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <array.h><br/>
</p>
<p>int search_array(mixed *<i>arr</i>,function <i>fun</i>,mixed <i>arg</i>, ...);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | or<br/>
int search_array(object *<i>arr</i>,string <i>fun</i>,mixed <i>arg</i>, ...);<br/>
or<br/>
int search_array(function *<i>arr</i>,-<i>1</i>,mixed <i>arg</i>, ...);<br/>
</p>
</tt>
<p>search_array works like map_array, only it returns the index of the
first call that returned true instead or returning an array of the
returned values. If no call returns true, -1 is returned.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
array</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::sum_arrays' to='sum_arrays'>sum_arrays</ref>, <ref resolved='predef::filter_array' to='filter_array'>filter_array</ref> and <ref resolved='predef::member_array' to='member_array'>member_array</ref></p>
</text></group>
|
7491fd | 1995-10-11 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='signal' homogen-type='method'>
<method name='signal'/><doc placeholder='true'>
<text>
<p><tt>signal</tt> - trap signals</p>
<tt><p>void signal(int <i>sig</i>, function(int:void) <i>callback</i>);<br/>
or<br/>
void signal(int <i>sig</i>);<br/>
</p>
</tt>
<p>This function allows you to trap a signal and have a function called
when the process receives a signal. Although it IS possible to trap
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | SIGBUS, SIGSEGV etc. I advice you not to. Pike should not receive any
such signals and if it does it is because of bugs in the Pike
|
7491fd | 1995-10-11 | Fredrik Hübinette (Hubbe) | | interperter. And all bugs should be reported, no matter how trifle.
</p>
<p>The callback will receive the signal number as the only argument.
See the document for the function 'kill' for a list of signals.
</p>
<p>If no second argument is given, the signal handler for that signal
|
0515af | 1996-08-12 | Fredrik Hübinette (Hubbe) | | is restored to the default handler.
</p>
<p>If the second argument is zero, the signal will be completely ignored.</p>
|
7491fd | 1995-10-11 | Fredrik Hübinette (Hubbe) | | </text>
<group><seealso/><text>
<p><ref resolved='predef::kill' to='kill'>kill</ref>, <ref resolved='predef::signame' to='signame'>signame</ref> and <ref resolved='predef::signum' to='signum'>signum</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='signame' homogen-type='method'>
<method name='signame'/><doc placeholder='true'>
<text>
<p><tt>signame</tt> - get the name of a signal</p>
<tt><p>string signame(int <i>sig</i>);<br/>
</p>
</tt>
<p>Return a string describing the signal.</p>
</text>
<group><example/><text>
<tt><p>> signame(9);<br/>
Result: SIGKILL<br/>
</p>
</tt></text></group>
<group><seealso/><text>
<p><ref resolved='predef::kill' to='kill'>kill</ref>, <ref resolved='predef::signum' to='signum'>signum</ref> and <ref resolved='predef::signal' to='signal'>signal</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='signum' homogen-type='method'>
<method name='signum'/><doc placeholder='true'>
<text>
<p><tt>signum</tt> - get a signal number given a desctiptive string</p>
<tt><p>int signum(string <i>sig</i>);<br/>
</p>
</tt>
<p>This function is the opposite of signame.</p>
</text>
<group><example/><text>
<tt><p>> signum("SIGKILL");<br/>
Result: 9<br/>
</p>
</tt></text></group>
<group><seealso/><text>
<p><ref resolved='predef::signame' to='signame'>signame</ref>, <ref resolved='predef::kill' to='kill'>kill</ref> and <ref resolved='predef::signal' to='signal'>signal</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='sin' homogen-type='method'>
<method name='sin'/><doc placeholder='true'>
<text>
<p><tt>sin</tt> - Trigonometrical sine</p>
<tt><p>float sin(float <i>f</i>);<br/>
</p>
</tt>
<p>Return the sinus value for f.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
float</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::asin' to='predef::asin'>math/asin</ref> and <ref resolved='predef::cos' to='predef::cos'>math/cos</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='sizeof' homogen-type='method'>
<method name='sizeof'/><doc placeholder='true'>
<text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><tt>sizeof</tt> - return the size of an array, string, multiset or mapping</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>int sizeof(string|multiset|mapping|array|object <i>a</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>This function returns the number of indexes available in the argument
given to it. It replaces older functions like strlen, m_sizeof and
|
fceb84 | 1995-11-16 | David Hedbor | | size.</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | string, multiset, mapping and array</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
7491fd | 1995-10-11 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='sleep' homogen-type='method'>
<method name='sleep'/><doc placeholder='true'>
<text>
<p><tt>sleep</tt> - let interpreter doze of for a while</p>
<tt><p>void sleep(int <i>s</i>);<br/>
</p>
</tt>
<p>This function makes the program stop for s seconds. Only signal
handlers can interrupt the sleep. Other callbacks are not called
during sleep.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::signal' to='signal'>signal</ref></p>
</text></group>
|
234b6d | 1996-06-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='sort' homogen-type='method'>
<method name='sort'/><doc placeholder='true'>
<text>
<p><tt>sort</tt> - sort an array destructively</p>
<tt><p>mixed *sort(array(mixed) <i>index</i>, array(mixed) ... <i>data</i>);<br/>
</p>
</tt>
<p>This function sorts the array 'index' destructively. That means
that the array itself is changed and returned, no copy is created.
If extra arguments are given, they are supposed to be arrays of the
same size. Each of these arrays will be modified in the same way as
'index'. Ie. if index 3 is moved to position 0 in 'index' index 3
will be moved to position 0 in all the other arrays as well.
</p>
<p>Sort can sort strings, integers and floats in ascending order.
Arrays will be sorted first on the first element of each array.
</p>
<p>Sort returns it's first argument.</p>
array</text>
<group><seealso/><text>
<p><ref resolved='predef::reverse' to='reverse'>reverse</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='sort_array' homogen-type='method'>
<method name='sort_array'/><doc placeholder='true'>
<text>
<p><tt>sort_array</tt> - sort an array</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <array.h><br/>
</p>
<p>mixed *sort_array(mixed *<i>arr</i>,function <i>fun</i>,mixed ... <i>args</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>The first syntax sorts an array after a compare-function fun
which takes two arguments and should return 1 if the first argument
is larger then the second. The rest of the arguments 'args' will be
sent as 3rd, 4th etc. argument to fun. If fun is omitted, < is unsed
instead.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
array</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::map_array' to='map_array'>map_array</ref> and <ref resolved='predef::filter_array' to='filter_array'>filter_array</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='spawn' homogen-type='method'>
<method name='spawn'/><doc placeholder='true'>
<text>
<p><tt>spawn</tt> - spawn a process</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <process.h><br/>
</p>
<p>int spawn(string <i>cmd</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | or<br/>
int spawn(string <i>cmd</i>, object <i>stdin</i>);<br/>
or<br/>
int spawn(string <i>cmd</i>, object <i>stdin</i>, object <i>stdout</i>);<br/>
or<br/>
int spawn(string <i>cmd</i>, object <i>stdin</i>, object <i>stdout</i>, object <i>stderr</i>);<br/>
</p>
</tt>
<p>This function spawns a process but does not wait for it to finish.
Optionally, clones of /precompiled/file can be sent to it to
specify where stdin, stdout and stderr of the spawned processes
should go.</p>
</text>
<group><seealso/><text>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::popen' to='popen'>popen</ref>, <ref resolved='predef::fork' to='predef::fork'>files/fork</ref>, <ref resolved='predef::exec' to='predef::exec'>files/exec</ref>, <ref resolved='predef::/precompiled/file.pipe' to='predef::file->pipe'>>files/file->pipe</ref> and <ref resolved='predef::/precompiled/file.dup2' to='predef::file->dup2'>>files/file->dup2</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='sprintf' homogen-type='method'>
<method name='sprintf'/><doc placeholder='true'>
<text>
<p><tt>sprintf</tt> - print the result from sprintf</p>
<tt><p>string sprintf(string <i>format</i>,mixed <i>arg</i>,....);<br/>
|
3f0cfb | 1995-11-13 | David Hedbor | | </p>
</tt>
<p>The format string is a string containing a description of how to
output the data in the rest of the arguments. This string should
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | generally speaking have one %<modifiers><operator> (examples:
|
3f0cfb | 1995-11-13 | David Hedbor | | %s, %0d, %-=20s) for each of the rest arguments.
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | <p>Modifiers:
</p>
<p><matrix>
<r><c> 0 </c><c> Zero pad numbers (implies right justification) </c></r>
<r><c> ! </c><c> Toggle truncation </c></r>
<r><c> ' ' (space) </c><c> pad positive integers with a space </c></r>
<r><c> + </c><c> pad positive integers with a plus sign </c></r>
<r><c> - </c><c> left adjusted within field size (default is right) </c></r>
<r><c> | </c><c> centered within field size </c></r>
<r><c> = </c><c> column mode if strings are greater than field size </c></r>
<r><c> / </c><c> Rough linebreak (break at exactly fieldsize instead of between words) </c></r>
<r><c> # </c><c> table mode, print a list of '\n' separated word (top-to-bottom order) </c></r>
<r><c> $ </c><c> Inverse table mode (left-to-right order) </c></r>
<r><c> n </c><c> (where n is a number or *) a number specifies field size </c></r>
<r><c> .n </c><c> set precision </c></r>
<r><c> :n </c><c> set field size & precision </c></r>
<r><c> ;n </c><c> Set column width </c></r>
|
3819e3 | 1996-10-15 | Fredrik Hübinette (Hubbe) | | <r><c> * </c><c> if n is a * then next argument is used for precision/field size </c></r>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | <r><c> 'X' </c><c> Set a pad string. ' cannot be a part of the pad_string (yet) </c></r>
|
3819e3 | 1996-10-15 | Fredrik Hübinette (Hubbe) | | <r><c> ~ </c><c> Get pad string from argument list. </c></r>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | <r><c> < </c><c> Use same arg again </c></r>
<r><c> ^ </c><c> repeat this on every line produced </c></r>
<r><c> @ </c><c> do this format for each entry in argument array </c></r>
<r><c> > </c><c> Put the string at the bottom end of column instead of top </c></r>
<r><c> _ </c><c> Set width to the length of data </c></r>
</matrix>
</p>
<p>Operators:
</p>
<p><matrix>
<r><c> %% </c><c> percent </c></r>
<r><c> %d </c><c> signed decimal int </c></r>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <r><c> %u </c><c> unsigned decimal int (doesn't really exist in Pike) </c></r>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | <r><c> %o </c><c> unsigned octal int </c></r>
<r><c> %x </c><c> lowercase unsigned hexadecimal int </c></r>
<r><c> %X </c><c> uppercase unsigned hexadecimal int </c></r>
<r><c> %c </c><c> char (or short with %2c, %3c gives 3 bytes etc.) </c></r>
<r><c> %f </c><c> float </c></r>
<r><c> %g </c><c> heruistically chosen representation of float </c></r>
<r><c> %e </c><c> exponential notation float </c></r>
<r><c> %s </c><c> string </c></r>
<r><c> %O </c><c> any type (debug style) </c></r>
<r><c> %n </c><c> nop </c></r>
<r><c> %t </c><c> type of argument </c></r>
<r><c> %<modifiers>{format%} </c><c> do a format for every index in an array. </c></r>
</matrix>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
|
3f0cfb | 1995-11-13 | David Hedbor | | </text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><example/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>Pike v0.1 Running Hilfe v1.2 (Incremental Pike Frontend)<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | > int screen_width=70;<br/>
Result: 70<br/>
> mixed sample;<br/>
> write(sprintf("fish: %c\n", 65));<br/>
fish: A<br/>
Result: 0<br/>
> write(sprintf("Hello green friends\n"));<br/>
Hello green friends<br/>
Result: 0<br/>
> write(sprintf("num: %d\n", 10));<br/>
num: 10<br/>
Result: 0<br/>
> write(sprintf("num: %+10d\n", 10));<br/>
num: +10<br/>
Result: 0<br/>
> write(sprintf("num: %010d\n", 5*2));<br/>
num: 0000000010<br/>
Result: 0<br/>
> write(sprintf("num: %|10d\n", 20/2));<br/>
num: 10 <br/>
Result: 0<br/>
> write(sprintf("%|*s\n",screen_width,"THE NOT END"));<br/>
<dl><group><text>THE NOT END <br/>
</text></group></dl>Result: 0<br/>
> write(sprintf("%|=*s\n",screen_width, "fun with penguins\n"));<br/>
<dl><group><text>fun with penguins <br/>
</text></group></dl>Result: 0<br/>
> write(sprintf("%-=*O\n",screen_width,({ "fish", 9, "gumbies", 2 })));<br/>
({ /* 4 elements */ <br/>
<dl><group><text>"fish", <br/>
9, <br/>
"gumbies", <br/>
2 <br/>
</text></group></dl>}) <br/>
Result: 0<br/>
> write(sprintf("%-=*s\n", screen_width,<br/>
<dl><group><text>"This will wordwrap the specified string within the "+<br/>
"specified field size, this is useful say, if you let "+<br/>
"users specify their screen size, then the room "+<br/>
"descriptions will automagically word-wrap as appropriate.\n"+<br/>
"slosh-n's will of course force a new-line when needed.\n"));<br/>
</text></group></dl>This will wordwrap the specified string within the specified field <br/>
size, this is useful say, if you let users specify their screen size, <br/>
then the room descriptions will automagically word-wrap as <br/>
appropriate. <br/>
slosh-n's will of course force a new-line when needed. <br/>
Result: 0<br/>
> write(sprintf("%-=*s %-=*s\n", screen_width/2,<br/>
<dl><group><text>"Two columns next to each other (any number of columns will "+<br/>
"of course work) independantly word-wrapped, can be useful.",<br/>
screen_width/2-1,<br/>
"The - is to specify justification, this is in addherence "+<br/>
"to std sprintf which defaults to right-justification, "+<br/>
"this version also supports centre and right justification."));<br/>
</text></group></dl>Two columns next to each other (any The - is to specify justification,<br/>
number of columns will of course this is in addherence to std <br/>
work) independantly word-wrapped, sprintf which defaults to <br/>
can be useful. right-justification, this version <br/>
<dl><group><text>also supports centre and right <br/>
justification. <br/>
</text></group></dl>Result: 0<br/>
> write(sprintf("%-$*s\n", screen_width,<br/>
<dl><group><text>"Given a\nlist of\nslosh-n\nseparated\n'words',\nthis option\n"+<br/>
"creates a\ntable out\nof them\nthe number of\ncolumns\n"+<br/>
"be forced\nby specifying a\npresision.\nThe most obvious\n"+<br/>
"use is for\nformatted\nls output."));<br/>
</text></group></dl>Given a list of slosh-n <br/>
separated 'words', this option <br/>
creates a table out of them <br/>
the number of columns be forced <br/>
by specifying a presision. The most obvious <br/>
use is for formatted ls output. <br/>
Result: 0<br/>
> write(sprintf("%-#*s\n", screen_width,<br/>
<dl><group><text>"Given a\nlist of\nslosh-n\nseparated\n'words',\nthis option\n"+<br/>
"creates a\ntable out\nof them\nthe number of\ncolumns\n"+<br/>
"be forced\nby specifying a\npresision.\nThe most obvious\n"+<br/>
"use is for\nformatted\nls output."));<br/>
</text></group></dl>Given a creates a by specifying a <br/>
list of table out presision. <br/>
slosh-n of them The most obvious <br/>
separated the number of use is for <br/>
'words', columns formatted <br/>
this option be forced ls output. <br/>
Result: 0<br/>
> sample = ({ "first column: bing", "second column: womble" });<br/>
Result: ({ /* 2 elements */<br/>
<dl><group><text>"first column: bing",<br/>
"second column: womble"<br/>
</text></group></dl>})<br/>
> write(sprintf("%-=*s\n%-=@*s\n", screen_width,<br/>
<dl><group><text>"Another bizarre option is the @ operator, it applies the "+<br/>
"format string it is in to each element of the array:",<br/>
screen_width/sizeof(sample),<br/>
sample));<br/>
</text></group></dl>Another bizarre option is the @ operator, it applies the format string<br/>
it is in to each element of the array: <br/>
first column: bing second column: womble <br/>
Result: 0<br/>
> write(sprintf("Better use these instead: %{gurksallad: %s\n%}\n",<br/>
<dl><group><text>sample));<br/>
</text></group></dl>Better use these instead: gurksallad: first column: bing<br/>
gurksallad: second column: womble<br/>
<br/>
Result: 0<br/>
> write(sprintf("Of course all the simple printf options "+<br/>
<dl><group><text>"are supported:\n %s: %d %x %o %c\n",<br/>
"65 as decimal, hex, octal and a char",<br/>
65, 65, 65, 65));<br/>
</text></group></dl>Of course all the simple printf options are supported:<br/>
<dl><group><text>65 as decimal, hex, octal and a char: 65 41 101 A<br/>
</text></group></dl>Result: 0<br/>
> write(sprintf("%|*s\n",screen_width, "THE END"));<br/>
<dl><group><text>THE END <br/>
</text></group></dl>Result: 0<br/>
> quit<br/>
Exiting.<br/>
</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </tt>
string</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::sscanf' to='sscanf'>sscanf</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='sqrt' homogen-type='method'>
<method name='sqrt'/><doc placeholder='true'>
<text>
<p><tt>sqrt</tt> - Square root</p>
<tt><p>float sqrt(float <i>f</i>);<br/>
or<br/>
int sqrt(int <i>i</i>);<br/>
</p>
</tt>
<p>Return the square root of f, or in the second case, the square root
truncated to the closest lower integer.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
float and int</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::pow' to='predef::pow'>math/pow</ref>, <ref resolved='predef::log' to='predef::log'>math/log</ref>, <ref resolved='predef::exp' to='predef::exp'>math/exp</ref> and <ref resolved='predef::floor' to='predef::floor'>math/floor</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='sscanf' homogen-type='method'>
<method name='sscanf'/><doc placeholder='true'>
<text>
<p><tt>sscanf</tt> - scan a string using a format string</p>
<tt><p>int sscanf(string <i>str</i>, string <i>fmt</i>, mixed <i>var1</i>, mixed <i>var2</i> ...);<br/>
</p>
</tt>
<p>Parse a string str using the format fmt. fmt can contain strings
separated by "%d,%s,%c and %f. Every % corresponds to one of var1,
var2...
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p><matrix>
<r><c> %d </c><c> gives an integer </c></r>
<r><c> %o </c><c> gives an octal integer </c></r>
<r><c> %x </c><c> gives a hexadecimal integer </c></r>
<r><c> %D </c><c> gives an integer that is either octal (leading zero), hexadecimal (leading 0x) or decimal. </c></r>
<r><c> %f </c><c> gives a float </c></r>
<r><c> %c </c><c> matches one char and returns it as an integer </c></r>
|
0515af | 1996-08-12 | Fredrik Hübinette (Hubbe) | | <r><c> %2c </c><c> matches two chars and returns them as an integer (short) </c></r>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <r><c> %s </c><c> gives a string </c></r>
|
0515af | 1996-08-12 | Fredrik Hübinette (Hubbe) | | <r><c> %5s </c><c> gives a string of 5 characters (5 can be any number) </c></r>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <r><c> %[set] </c><c> matches a string containing a given set of characters. (thos given inside the brackets) %[^set] means any character ecept those inside brackets. %[0-9H] means any number or 'H'. </c></r>
</matrix>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
<p>If a * is put between the percent and the operator, the operator
will not only match it's argument, not assign any variables.
</p>
<p>Number of matched arguments is returned.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
string</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::explode' to='explode'>explode</ref> and <ref resolved='predef::sprintf' to='sprintf'>sprintf</ref></p>
</text></group>
|
06fa8e | 1996-10-24 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='stderr' homogen-type='method'>
<method name='stderr'/><doc placeholder='true'>
<text>
<p><tt>stderr</tt> - Standard error stream</p>
<tt><p>#include <stdio.h><br/>
</p>
<p>stderr->gets()<br/>
</p>
</tt>
<p>Stderr is a clone of /precompiled/file connected to the standard
error stream.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::stderr' to='/precompiled/file'>/precompiled/file</ref> and <ref resolved='predef::werror' to='werror'>werror</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='stdin' homogen-type='method'>
<method name='stdin'/><doc placeholder='true'>
<text>
<p><tt>stdin</tt> - Standard input</p>
<tt><p>#include <stdio.h><br/>
</p>
<p>stdin->gets()<br/>
</p>
</tt>
<p>Stdin is a clone of /precompiled/FILE connected to the standard input.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::stdin' to='/precompiled/FILE'>/precompiled/FILE</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='stdout' homogen-type='method'>
<method name='stdout'/><doc placeholder='true'>
<text>
<p><tt>stdout</tt> - Standard output</p>
<tt><p>#include <stdio.h><br/>
</p>
<p>stdout->gets()<br/>
</p>
</tt>
<p>Stdout is a clone of /precompiled/file connected to the standard output.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::stdout' to='/precompiled/file'>/precompiled/file</ref> and <ref resolved='predef::write' to='write'>write</ref></p>
</text></group>
|
b6f5f6 | 1996-06-21 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='strerror' homogen-type='method'>
<method name='strerror'/><doc placeholder='true'>
<text>
<p><tt>strerror</tt> - return a string describing an error</p>
<tt><p>string strerror(int <i>errno</i>);<br/>
</p>
</tt>
<p>This function returns a description of an error code. The error
code is usually obtained from the file->errno() call.</p>
file</text>
<group><note/><text>
<p>This function may not be available on all platforms.
</p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='string' homogen-type='method'>
<method name='string'/><doc placeholder='true'>
<text>
<p><tt>string</tt> - a string of characters</p>
<tt><p>"foo"<br/>
</p>
</tt>
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | <p>This type can contan text. ie. a word, a sentence, or a book. Note
that this is not simply the letters A to Z, special characters,
null characters, newlines can all be stored in a string. Any 8-bit
character in fact. Strings are a basic
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | type in Pike, as opposed to C where strings are represented by an
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | array of char. This means that you cannot set individual characters
in a string with the index operator for instance. In fact, there are
no functions that alters strings destructively. Also, all strings
are 'shared', that means that if the same string is used in several
places, only one will be stored in memory.
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | </p>
<p>When writing a string in a program, you enclose it in doublequotes.
To write special characters you need to use one of the following
syntaxes:
</p>
<p><matrix>
<r><c> \n </c><c> newline </c></r>
|
234b6d | 1996-06-09 | Fredrik Hübinette (Hubbe) | | <r><c> \r </c><c> carriage return </c></r>
|
2d40fd | 1996-03-31 | Fredrik Hübinette (Hubbe) | | <r><c> \t </c><c> tab </c></r>
<r><c> \b </c><c> backspace </c></r>
<r><c> \" </c><c> " </c></r>
<r><c> \\ </c><c> \ </c></r>
</matrix>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
<p>A list of operators that applies to strings follow:
In this list a and b is used to represent a string expression:
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p><matrix>
<r><c> a + b </c><c> summation ( "a"+"b" returns "ab") </c></r>
<r><c> a - b </c><c> subtraction ( same as replace(a,b,"") ) </c></r>
<r><c> a / b </c><c> division ( same thing as explode(a,b) ) </c></r>
<r><c> ! a </c><c> boolean not, returns 0 </c></r>
</matrix>
</p>
<p>The following operators compare two string alphabetically:
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
<p><matrix>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <r><c> a == b </c><c> return 1 if a is equal to b, 0 otherwise </c></r>
<r><c> a != b </c><c> return 0 if a is equal to b, 1 otherwise </c></r>
<r><c> a < b </c><c> returns 1 if a is lesser than b, 0 otherwise </c></r>
<r><c> a <= b </c><c> returns 1 if a is lesser or equal to b, 0 otherwise </c></r>
<r><c> a > b </c><c> returns 1 if a is greater than b, 0 otherwise </c></r>
<r><c> a >= b </c><c> returns 1 if a is greater or equal to b, 0 otherwise </c></r>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </matrix>
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
|
516e68 | 1996-02-26 | Fredrik Hübinette (Hubbe) | | types</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::indices' to='predef::indices'>builtin/indices</ref>, <ref resolved='predef::values' to='predef::values'>builtin/values</ref>, <ref resolved='predef::sscanf' to='predef::sscanf'>builtin/sscanf</ref>, <ref resolved='predef::sprintf' to='predef::sprintf'>builtin/sprintf</ref> and <ref resolved='predef::sizeof' to='predef::sizeof'>builtin/sizeof</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='stringp' homogen-type='method'>
<method name='stringp'/><doc placeholder='true'>
<text>
<p><tt>stringp</tt> - is the argument an string?</p>
<tt><p>int stringp(mixed <i>arg</i>);<br/>
</p>
</tt>
<p>Returns 1 if arg is a string, zero otherwise.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
string</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::intp' to='intp'>intp</ref>, <ref resolved='predef::multisetp' to='multisetp'>multisetp</ref>, <ref resolved='predef::arrayp' to='arrayp'>arrayp</ref>, <ref resolved='predef::programp' to='programp'>programp</ref>, <ref resolved='predef::objectp' to='objectp'>objectp</ref>, <ref resolved='predef::mappingp' to='mappingp'>mappingp</ref>, <ref resolved='predef::floatp' to='floatp'>floatp</ref> and <ref resolved='predef::functionp' to='functionp'>functionp</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='strlen' homogen-type='method'>
<method name='strlen'/><doc placeholder='true'>
<text>
<p><tt>strlen</tt> - Return the length of a string</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>int strlen(string <i>s</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function is equal to sizeof.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
string</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::sizeof' to='predef::sizeof'>builtin/sizeof</ref></p>
</text></group>
|
362e88 | 1996-10-15 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='strmult' homogen-type='method'>
<method name='strmult'/><doc placeholder='true'>
<text>
<p><tt>strmult</tt> - multiply strings</p>
<tt><p>#include <string.h><br/>
</p>
<p>string strmult(string <i>s</i>, int <i>num</i>);<br/>
</p>
</tt>
<p>This function multplies 's' by 'num'. The return value is the same
as appending 's' to an empty string 'num' times.
</p>
</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='strstr' homogen-type='method'>
<method name='strstr'/><doc placeholder='true'>
<text>
<p><tt>strstr</tt> - find a string inside a string</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>int strstr(string <i>str1</i>,string <i>str2</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>Return the position of str2 in str1, if str2 can't be found in str1
-1 is returned.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
string</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::sscanf' to='predef::sscanf'>builtin/sscanf</ref> and <ref resolved='predef::explode' to='predef::explode'>builtin/explode</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='sum' homogen-type='method'>
<method name='sum'/><doc placeholder='true'>
<text>
<p><tt>sum</tt> - add values together</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>int sum(int ... <i>i</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | or<br/>
float sum(float ... <i>f</i>);<br/>
or<br/>
string sum(string|float|int ... <i>p</i>);<br/>
or<br/>
array sum(array ... <i>a</i>);<br/>
or<br/>
mapping sum(mapping ... <i>m</i>);<br/>
or<br/>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | list sum(multiset ... <i>l</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>This function does exactly the same thing as adding all the arguments
together with +. It's just here so you can get a function-pointer to
|
fceb84 | 1995-11-16 | David Hedbor | | the summation operator.</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | int, float, string, array, mapping and multiset</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
</doc>
</docgroup>
<docgroup homogen-name='sum_arrays' homogen-type='method'>
<method name='sum_arrays'/><doc placeholder='true'>
<text>
<p><tt>sum_arrays</tt> - map any number of arrays over a function.</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <array.h><br/>
</p>
<p>mixed *sum_arrays(function <i>fun</i>,mixed *<i>arr1</i>,...);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>Works like this:
</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <p>mixed *sum_arrays(function fun,mixed *arr1,...)<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {<br/>
<dl><group><text>int e;<br/>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | mixed *res=allocate(sizeof(arr1));<br/>
for(e=0;e<sizeof(arr1);e++)<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {<br/>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | <dl><group><text>res[e]=fun(arr1[e],arr2[e],...);<br/>
</text></group></dl>}<br/>
return res;<br/>
</text></group></dl>}<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
<p>Simple ehh?</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
array</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::map_array' to='map_array'>map_array</ref>, <ref resolved='predef::filter_array' to='filter_array'>filter_array</ref> and <ref resolved='predef::search_array' to='search_array'>search_array</ref></p>
</text></group>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='switch' homogen-type='method'>
<method name='switch'/><doc placeholder='true'>
<text>
<p><tt>switch</tt> - Complicated conditional statement</p>
<tt><p>switch( expression )<br/>
{<br/>
<dl><group><text>case constant1:<br/>
<dl><group><text><i>statement1</i><br/>
</text></group></dl></text></group></dl><br/>
<dl><group><text>case constant2:<br/>
<dl><group><text><i>statement2</i><br/>
break;<br/>
</text></group></dl></text></group></dl><br/>
<dl><group><text>case constant3..constant4:<br/>
<dl><group><text><i>statement4</i><br/>
break;<br/>
</text></group></dl></text></group></dl><br/>
<dl><group><text>default:<br/>
<dl><group><text><i>statement3</i><br/>
</text></group></dl></text></group></dl>}<br/>
</p>
</tt>
<p>Switch evaluates the expression give and then executes one or more
statement accordingly to the result. If the result is equal to
constant1 then statement1 will be executed, please observe that
the second case-statement dos _not_ abort the execution in any way
instead statement2 will also be executed. After that break will
cause execution to continue after the after the last } in the
switch statement. If the result is equal to constant2 only
statement2 will be executed. If expression <= consant3 and
expression >= constant4, statement4 will be executed. In all other
cases statement3 is executed because it is 'default'. Please note
that the expression and constants can be any type that can be
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | written as a constant. Arrays, mappings and multisets have little or
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | no use though.</p>
control</text>
<group><seealso/><text>
<p><ref to='if-else'>if-else</ref> and <ref resolved='predef::break' to='break'>break</ref></p>
</text></group>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='system' homogen-type='method'>
<method name='system'/><doc placeholder='true'>
<text>
<p><tt>system</tt> - run an external program</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <process.h><br/>
</p>
<p>void system(string <i>cmd</i>);<br/>
|
8c7c69 | 1995-10-29 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>This function runs the external program cmd and waits until it
is finished. Standard /bin/sh completions/redirectoins/etc. can
be used.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::popen' to='popen'>popen</ref>, <ref resolved='predef::exec' to='exec'>exec</ref> and <ref resolved='predef::spawn' to='spawn'>spawn</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='tan' homogen-type='method'>
<method name='tan'/><doc placeholder='true'>
<text>
<p><tt>tan</tt> - Trigonometrical tangent</p>
<tt><p>float tan(float <i>f</i>);<br/>
</p>
</tt>
<p>Return the tangent value for f.</p>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | |
float</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::atan' to='predef::atan'>math/atan</ref>, <ref resolved='predef::sin' to='predef::sin'>math/sin</ref> and <ref resolved='predef::cos' to='predef::cos'>math/cos</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='this_function' homogen-type='method'>
<method name='this_function'/><doc placeholder='true'>
<text>
<p><tt>this_function</tt> - return a functionpointer to the current function</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <simulate.h><br/>
</p>
<p>function this_function();<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>Returns a functionpointer to the current function, useful for
making recursive lambda-functions.</p>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
function</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::get_function' to='predef::get_function'>builtin/get_function</ref>, <ref resolved='predef::function_name' to='predef::function_name'>builtin/function_name</ref>, <ref resolved='predef::function_object' to='predef::function_object'>builtin/function_object</ref> and <ref resolved='predef::backtrace' to='predef::backtrace'>builtin/backtrace</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='this_object' homogen-type='method'>
<method name='this_object'/><doc placeholder='true'>
<text>
<p><tt>this_object</tt> - return the object we are evaluating in currently</p>
<tt><p>object this_object();<br/>
</p>
</tt>
|
fceb84 | 1995-11-16 | David Hedbor | | <p>This function returns the object we are curently evaluating in.</p>
object</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
9f2499 | 1996-10-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='this_thread' homogen-type='method'>
<method name='this_thread'/><doc placeholder='true'>
<text>
<p><tt>this_thread</tt> - return thread id</p>
<tt><p>object thread_id();<br/>
</p>
</tt>
<p>This function returns the object that identifies this thread.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::thread_create' to='thread_create'>thread_create</ref></p>
</text></group>
|
8a2bc2 | 1996-10-06 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='thread_create' homogen-type='method'>
<method name='thread_create'/><doc placeholder='true'>
<text>
<p><tt>thread_create</tt> - create a thread</p>
|
9f2499 | 1996-10-09 | Fredrik Hübinette (Hubbe) | | <tt><p>object thread_create(function <i>f</i>, mixed ... <i>args</i>);<br/>
|
8a2bc2 | 1996-10-06 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>This function creates a new thread which will run simultaneously
to the rest of the program. The new thread will call the function
f with the arguments args. When f returns the thread will cease
to exist. All Pike functions are 'thread safe' meanting that running
a function at the same time from different threads will not corrupt
|
9f2499 | 1996-10-09 | Fredrik Hübinette (Hubbe) | | any internal data in the Pike process. The returned value will be
the same as the return value of this_thread() for the new thread.</p>
|
8a2bc2 | 1996-10-06 | Fredrik Hübinette (Hubbe) | | </text>
<group><note/><text>
<p>This function is only available on systems with POSIX threads support.</p>
</text></group>
<group><seealso/><text>
|
9f2499 | 1996-10-09 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::thread_create' to='/precompiled/mutex'>/precompiled/mutex</ref>, <ref resolved='predef::thread_create' to='/precompiled/condition'>/precompiled/condition</ref> and <ref resolved='predef::this_thread' to='this_thread'>this_thread</ref></p>
|
8a2bc2 | 1996-10-06 | Fredrik Hübinette (Hubbe) | | </text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='throw' homogen-type='method'>
<method name='throw'/><doc placeholder='true'>
<text>
<p><tt>throw</tt> - throw a value to catch or global error handling</p>
<tt><p>void throw(mixed <i>value</i>);<br/>
</p>
</tt>
<p>This function throws a value to a waiting catch. If no catch is
waiting global error handling will send the value to handle_error
in the master object. If you throw an array with where the first
index contains an error message and the second index is a backtrace,
(the output from backtrace() that is) then it will be treated exactly
like a real error by overlying functions.</p>
</text>
<group><seealso/><text>
<p><ref resolved='predef::catch' to='catch'>catch</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='time' homogen-type='method'>
<method name='time'/><doc placeholder='true'>
<text>
<p><tt>time</tt> - return the current time</p>
<tt><p>int time();<br/>
or<br/>
int time(1);<br/>
</p>
</tt>
<p>This function returns the number of secons since 1 Jan 1970.
The function ctime() converts this integer to a readable string.
</p>
<p>The second syntax does not call the system call time() as often,
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | but is only updated in the backed. (when pike code isn't running)</p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text>
<group><seealso/><text>
<p><ref resolved='predef::time' to='time'>time</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='trace' homogen-type='method'>
<method name='trace'/><doc placeholder='true'>
<text>
<p><tt>trace</tt> - change debug trace level</p>
<tt><p>int trace(int <i>t</i>);<br/>
</p>
</tt>
<p>This function affects the debug trace level. (also set by the -t
command line option) The old level is returned. Trace level 1 or
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | higher means that calls to pike functions are printed to stderr,
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | level 2 or higer means calls to builtin functions are printed, 3
means every opcode interpreted is printed, 4 means arguments to
these opcodes are printed as well. See the command lines options
for more information
</p>
</text>
|
ebb195 | 1996-03-02 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='typeof' homogen-type='method'>
<method name='typeof'/><doc placeholder='true'>
<text>
<p><tt>typeof</tt> - check return type of expression</p>
<tt><p>typeof ( expression )<br/>
</p>
</tt>
<p>This is a not really a function even if it looks like it, it returns
a human readable (almost) representation of the type that the
expression would return without actually evaluating it.
The representation is in the form of a string.</p>
</text>
<group><example/><text>
<tt><p>> typeof(`sizeof);<br/>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | Result: function(object | mapping | array | multiset | string : int)<br/>
|
ebb195 | 1996-03-02 | Fredrik Hübinette (Hubbe) | | > typeof(sizeof(({})));<br/>
Result: int<br/>
> <br/>
</p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | pike</text></group>
</doc>
</docgroup>
<docgroup homogen-name='ualarm' homogen-type='method'>
<method name='ualarm'/><doc placeholder='true'>
<text>
<p><tt>ualarm</tt> - set an alarm clock for delivery of a signal</p>
<tt><p>int ualarm(int <i>useconds</i>);<br/>
</p>
</tt>
<p>ualarm arranges for a SIGALRM signal to be delivered to the
process in useconds micro seconds.
</p>
<p>If useconds is zero, no new alarm is scheduled.
</p>
<p>In any event any previously set alarm is cancelled.</p>
</text>
<group><returns/><text>
<p>ualarm returns the number of microseconds seconds remaining<br/>
<dl><group><text>until any previously scheduled alarm was due to be delivered, or<br/>
</text></group></dl>zero if there was no previously scheduled alarm.<br/>
</p>
</text></group>
<group><seealso/><text>
<p><ref resolved='predef::signal' to='signal'>signal</ref></p>
</text></group>
|
ebb195 | 1996-03-02 | Fredrik Hübinette (Hubbe) | |
|
613072 | 1996-11-01 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='uniq' homogen-type='method'>
<method name='uniq'/><doc placeholder='true'>
<text>
<p><tt>uniq</tt> - return one of each element</p>
<tt><p>#include <array.h><br/>
</p>
<p>array uniq(array <i>a</i>);<br/>
</p>
</tt>
<p>This function returns an copy of the array a with all duplicate
values removed. The order of the values in the result is undefined.</p>
array</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='upper_case' homogen-type='method'>
<method name='upper_case'/><doc placeholder='true'>
<text>
<p><tt>upper_case</tt> - convert a string to upper case</p>
<tt><p>string upper_case(string <i>s</i>);<br/>
</p>
</tt>
<p>Return a copy of the string s with all lower case character converted
to upper case character.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
string</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::lower_case' to='lower_case'>lower_case</ref></p>
</text></group>
</doc>
</docgroup>
<docgroup homogen-name='values' homogen-type='method'>
<method name='values'/><doc placeholder='true'>
<text>
<p><tt>values</tt> - return an array of all possible values from indexing</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <tt><p>mixed *values(string|multiset|mapping|array|object <i>foo</i>);<br/>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </p>
</tt>
<p>Values return an array of all values you can get when indexing the
value foo. For strings, an array of int with the ascii values of the
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | characters in the string is returned. For a multiset, an array filled with
|
3f0cfb | 1995-11-13 | David Hedbor | | ones is return. For mappings, objects and arrays, the returned array
may contain any kind of value.</p>
|
fceb84 | 1995-11-16 | David Hedbor | |
mapping</text>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::indices' to='indices'>indices</ref></p>
</text></group>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='variables' homogen-type='method'>
<method name='variables'/><doc placeholder='true'>
<text>
<p><tt>variables</tt> - how to declare a variable</p>
<tt><p>modifier type variable_name_list;<br/>
</p>
</tt>
<p>This is how you declare a global variable. Local variables are defined
in the same way, but you may not use any modifiers for local variables.
The variable_name_list is a comma separated list of the variables
to declare as the type 'type'. Note that '*' binds to the variable
names, not the type. This means that:
</p>
<p><matrix>
<r><c> </c><c> int * i,j; </c></r>
<r><c> </c></r>
</matrix>
</p>
<p>Declares i as an array of int, but j will be declared as int. To
declare both i and j as arrays of int you have to write.
</p>
<p><matrix>
<r><c> </c><c> int * i, * j; </c></r>
<r><c> </c></r>
</matrix>
</p>
<p>or
</p>
<p><matrix>
<r><c> </c><c> array(int) i,j; </c></r>
<r><c> </c></r>
</matrix>
</p>
<p>Modifiers can be zero or more of: static, no_mask and private.
Private means that the variable can not be accessed from programs
that inherit this program. Static means that it can not be accessed
from other objects with the index operator. No_mask means that it
can not be redefined in inheriting programs.</p>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | pike</text>
|
3b8e84 | 1996-02-10 | Fredrik Hübinette (Hubbe) | |
<group><seealso/><text>
<p><ref resolved='predef::functions' to='functions'>functions</ref></p>
</text></group>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='version' homogen-type='method'>
<method name='version'/><doc placeholder='true'>
<text>
<p><tt>version</tt> - return version info</p>
<tt><p>string version();<br/>
</p>
</tt>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p>This function returns a brief information about the Pike version.</p>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | </text>
<group><example/><text>
<tt><p>> version();<br/>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | Result: Pike v1.0E-13<br/>
|
762964 | 1995-11-06 | Fredrik Hübinette (Hubbe) | | <br/>
</p>
</tt></text></group>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='werror' homogen-type='method'>
<method name='werror'/><doc placeholder='true'>
<text>
<p><tt>werror</tt> - write to stderr</p>
<tt><p>void werror(string <i>s</i>);<br/>
</p>
</tt>
<p>Writes a message to stderr. Stderr is normally the console, even if
the process output has been redirected to a file or pipe.</p>
file</text>
|
a44f22 | 1996-02-24 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='while' homogen-type='method'>
<method name='while'/><doc placeholder='true'>
<text>
<p><tt>while</tt> - execute a statement while an expression is true</p>
<tt><p>while( expression ) <i>statement</i><br/>
</p>
</tt>
<p>While runns the statement until the expression is false. The
expression is evaluated once for every loop. If the expression is
false the first time the statement is never executed.</p>
control</text>
<group><seealso/><text>
<p><ref resolved='predef::for' to='for'>for</ref> and <ref to='do-while'>do-while</ref></p>
</text></group>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </doc>
</docgroup>
<docgroup homogen-name='write' homogen-type='method'>
<method name='write'/><doc placeholder='true'>
<text>
<p><tt>write</tt> - write text to stdout</p>
<tt><p>int write(string <i>text</i>);<br/>
</p>
</tt>
<p>Added by the master, it directly calls write in a clone of
/precompiled/file</p>
</text>
<group><seealso/><text>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | | <p><ref resolved='predef::werror' to='predef::werror'>builtin/werror</ref></p>
|
a1c588 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | </text></group>
</doc>
</docgroup>
<docgroup homogen-name='write_file' homogen-type='method'>
<method name='write_file'/><doc placeholder='true'>
<text>
<p><tt>write_file</tt> - append a string to a file</p>
|
06fa8e | 1996-10-24 | Fredrik Hübinette (Hubbe) | | <tt><p>#include <stdio.h><br/>
|
d8215a | 1996-09-22 | Fredrik Hübinette (Hubbe) | |
</p>
<p>int write_file(string file, string str)<br/>
|
|