ftp.nice.ch/pub/next/unix/developer/slang0.99-34.s.tar.gz#/slang/doc/faq.txt

This is faq.txt in view mode; [Download] [Up]

Introductory FAQ  -- Far from complete -- I will update it daily.

Frequently asked questions.

Terminology: 

  S-Lang function : a user defined function that is written in
                    S-Lang.
		    
  C function:       A function that is written in C.   It may or may not be
                    callable from S-lang
		    
  Intrinsic Function: A C function that is directly callable from S-Lang,
                    e.g., strcat.
  

0. Where do I find documentation?

   The documentation is incomplete.  See slang/doc/*.* and
   slang/help/slang.hlp.  In addition, nearly all the C functions prototyped
   in slang.h are also documented in slang.h. Finally, all the intrinsics
   defined by the S-Lang library are available online from within the JED
   editor.  (Also look in slang/src/demo).

1. How can I call a specific S-Lang function from my C program?

   Use the C function `SLang_execute_function'.  This returns 0 if the
   function is not defined and 1 if it is.
   
   If you are going to call the S-Lang function many times, it is better to
   use `SLexecute_function'.  This function takes a non-NULL parameter of
   type `SLang_Name_Type' obtained from a previous call from the function
   `SLang_get_function'.
   
   Example:  Suppose that you want to call a S-Lang function `f' which
   takes two floating point numbers and returns a float.  Assume the
   parameters to `f' are `2.7' and 3.5'.
   
     First solution:
     
       double x;
       int ix, unused;
       
       SLang_push_float (2.7); SLang_push_float (3.5);
       if (SLang_execute_function ("f") == 0)
         {
	    /* f undefined */
	    return 0.0;
	 }
       SLang_pop_float (&x, &ix, &unused);
       return x;
     
     Second Solution:
     
        double x;
        int ix, unused;
	SLang_Name_Type *fp;
	
	if (NULL == (fp = SLang_get_function ("f")))
	  {
	     /* Function f undefined */
	     return 0.0;
	  }
       
       SLang_push_float (2.7); SLang_push_float (3.5);
       SLexecute_function (fp);
       SLang_pop_float (&x, &ix, &unused);
       return x;
       
3. How can I add structures to S-Lang.

   Currently, the language does not really support structures.  However, it
   is possible for variables to have values which are structures.   See
   demo/struct.c and demo/struct.sl for an explicit demonstration of how to
   add application defined structures to S-Lang.
   
   
       
       
       

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.