Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
multiple lines of string to multiple parameters
#3
You can do this much simpler.

Member function str.CallCS
 
Code:
Copy      Help
function~ str'_Fun [ARRAY(str)&as]
CsScript x.AddCode(this)

if(as.len)
,ret x.Call(_Fun as)
else
,out "Error!! No arguments were passed"


Function test
Code:
Copy      Help
_s=
;using System;
;
;public class cla
;{
;,public static string Fun1(string[] args)
;,{
;;;;;;;;//use if space is added at end of each line in multiline args str below
;,,//string result = string.Concat(args);
;;;;;;;// use if no space is added at end of each line in multiline args str below
;;;;;;;;string result = string.Join(" ", args);
;,,Console.WriteLine(result);
;,,return result;
;,}
;}

ARRAY(str) a
;1 arg
str args=
;First parameter
a=args
_s.CallCS("Fun1" a)

;2 args
args=
;First parameter
;Second parameter
a=args
_s.CallCS("Fun1" a)

;3 args
args=
;First parameter
;Second parameter
;Third parameter
a=args
_s.CallCS("Fun1" a)

;4 args
args=
;First parameter
;Second parameter
;Third parameter
;Forth parameter
a=args
_s.CallCS("Fun1" a)

;no args error handling
args=""
a=args
_s.CallCS("Fun1" a)


Messages In This Thread
RE: multiple lines of string to multiple parameters - by Kevin - 05-09-2023, 02:29 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)