Benutzer-Werkzeuge

Webseiten-Werkzeuge


scriptstack

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
scriptstack [2025/12/15 02:43]
jango [Routines]
scriptstack [2025/12/15 02:50] (aktuell)
jango [Routines]
Zeile 112: Zeile 112:
 <code csharp> <code csharp>
 // define route // define route
-Routine routine = new Routine( +Routine routine = new Routine((Type)null, "Print", (Type)null, "A function to print text");
- (Type)null, "Print", (Type)null, "A function to print text");+
 </code> </code>
  
Zeile 129: Zeile 128:
 listParameterTypes.Add(typeof(ArrayList)); listParameterTypes.Add(typeof(ArrayList));
  
-// define function prototype with many parameters +// define routine with many parameters 
-Routine routine = new Routine( +Routine routine = new Routine((Type)null, "Print", listParameterTypes);
- (Type)null, "Print", listParameterTypes);+
 </code> </code>
  
Zeile 155: Zeile 153:
 public class Program : Host public class Program : Host
 { {
- // class implementation + 
- private Interpreter interpreter; +    private Interpreter interpreter; 
- public Main(script script) + 
- { +    public Main(script script) 
- interpreter = new Interpreter(script); +    
- interpreter.Handler = this; +        interpreter = new Interpreter(script); 
- } +        interpreter.Handler = this; 
- public object Invoke(String functionName, List<object> parameters) +    
- { +  
- if (functionName == "Print"+    public object Invoke(String functionName, List<object> parameters) 
- { +    
- string str = (int)listParameters[0]; +        if (functionName == "Print"
- Console.WriteLine(str); +        
- return; +            string str = (int)parameters[0]; 
- } +            Console.WriteLine(str); 
- return null; +            return; 
- }+        
 +        return null; 
 +    } 
 +    
 } }
 </code> </code>
Zeile 185: Zeile 186:
 <code csharp> <code csharp>
 // register global Sine function // register global Sine function
-HostFunctionPrototype hostFunctionPrototype = new HostFunctionPrototype( +Routine routine = new Routine(typeof(float), "Print", typeof(float)); 
- typeof(float), "Sin", typeof(float)); +manager.Register(routineprintHandler); 
-m_scriptManager.RegisterHostFunction(hostFunctionPrototypetrigHandler);+
 // register global Cosine function // register global Cosine function
-HostFunctionPrototype hostFunctionPrototype = new HostFunctionPrototype( +routine = new Routine(typeof(float), "Read", typeof(float)); 
- typeof(float), "Cos", typeof(float)); +manager.Register(routinereadHandler);
-m_scriptManager.RegisterHostFunction(hostFunctionPrototype, trigHandler); +
-// register global Tangent function +
-HostFunctionPrototype hostFunctionPrototype = new HostFunctionPrototype( +
- typeof(float), "Tan", typeof(float)); +
-m_scriptManager.RegisterHostFunction(hostFunctionPrototypetrigHandler);+
 </code> </code>
  
scriptstack.1765763010.txt.gz · Zuletzt geändert: 2025/12/15 02:43 von jango