Quote: "So now you can eliminate the need for a plugin in your code"
yeah except the
mid$(s$,start,size) and
string count(Source$,Search$)
but i think i'll make/find a function for that too... will post updated codes soon...
Ok here is the no-plugin-code:
set window on
Set Window size 800,600
Set Text Font "Lucida Console"
Set Text Size 14
function$="text_or_stuff('a',1,200,y,20000)"
print "Full: ";function$
print "Name: ";EXT_name(function$)
print "Parameters: ";EXT_args(function$)
print "Parameter-count:";EXT_count(function$,",")
print " "
for x=1 to EXT_count(function$,",")
print "Parameter ";x;": ";rem_quote(EXT_param(function$,x,","))
next x
wait key
end
// returns the name of the function in the given function-string
function EXT_name(String$)
start=Instr2(String$,"(",0)
Name$=left$(String$,start)
endfunction Name$
// returns the number of arguments in the given function-string
function EXT_count(String$,seperator$)
Args$=EXT_args(String$)
num=str_count(Args$,seperator$)+1
endfunction num
// returns the Nth parameter of the given function-string
function EXT_param(String$,N,seperator$)
c=0
Args$=EXT_args(String$)
param$=""
repeat
x=Instr2(Args$,seperator$,1)
if x=0 then param$=Args$ : exit
param$=Left$(Args$,x)
Args$=Right$(Args$,len(Args$)-x-1)
inc c
until c=N
endfunction param$
// returns the arguments (/paramaters) of the given function-string
// just meant to be used internally ;)
function EXT_args(String$)
_start=Instr2(String$,"(",0)+2
_end=Instr2(String$,")",0)
arg$=MultiMid$(String$,_start,_end)
if _start=0 and _end=0 then arg$=String$
endfunction arg$
function rem_quote(String$)
if asc(Left$(String$,1))=34 or Left$(String$,1)="'"
String$=Right$(String$,len(String$)-1)
endif
if asc(Right$(String$,1))=34 or Right$(String$,1)="'"
String$=Left$(String$,len(String$)-1)
endif
endfunction String$
// Multi-char-mid$ by Tallun
Function MultiMid$(String$, StartChar, EndChar)
StepVal = 1
MultiMid$ = ""
If EndChar < StartChar Then StepVal = -1
For Char = StartChar To EndChar Step StepVal
MultiMid$ = MultiMid$ + Mid$(String$, Char)
Next Char
EndFunction MultiMid$
// instr by calcyman
function instr2(source as string, search as string,pos)
j as integer : k as integer : l as integer
section as string
k = LEN(search)
l = 0
For j = pos to LEN(source)-k
If l=0
section=RIGHT$(LEFT$(source,j+k),k)
If section=search then out=j : l=1
endif
Next j
endfunction out
// my string-count function
function STR_count(source$,search$)
local x=0
local num=0
do
x=instr2(source$,search$,x+1)
if x=0 : exitfunction num : else : inc num : endif
loop
endfunction num
update original code:
set window on
Set Window size 800,600
Set Text Font "Lucida Console"
Set Text Size 14
function$="text_or_stuff('a',1,200,y,20000)"
print "Full: ";function$
print "Name: ";EXT_name(function$)
print "Parameters: ";EXT_args(function$)
print "Parameter-count:";EXT_count(function$,",")
print " "
for x=1 to EXT_count(function$,",")
print "Parameter ";x;": ";rem_quote(EXT_param(function$,x,","))
next x
wait key
end
// returns the name of the function in the given function-string
function EXT_name(String$)
start=Instr(String$,"(",1)-1
Name$=fast left$(String$,start)
endfunction Name$
// returns the number of arguments in the given function-string
function EXT_count(String$,seperator$)
Args$=EXT_args(String$)
num=string count(Args$,seperator$)+1
endfunction num
// returns the Nth parameter of the given function-string
function EXT_param(String$,N,seperator$)
c=0
Args$=EXT_args(String$)
param$=""
repeat
x=Instr(Args$,seperator$,1)
if x=0 then param$=Args$ : exit
param$=fast Left$(Args$,x-1)
Args$=fast Right$(Args$,fast len(Args$)-x)
inc c
until c=N
endfunction param$
// returns the arguments (/paramaters) of the given function-string
// just meant to be used internally ;)
function EXT_args(String$)
_start=Instr(String$,"(")+1
_end=Instr(String$,")")
arg$=Mid$(String$,_start,_end-_start)
if _start=0 and _end=0 then arg$=String$
endfunction arg$
function rem_quote(String$)
if asc(fast Left$(String$,1))=34 or fast Left$(String$,1)="'"
String$=fast Right$(String$,fast len(String$)-1)
endif
if asc(fast Right$(String$,1))=34 or fast Right$(String$,1)="'"
String$=fast Left$(String$,fast len(String$)-1)
endif
endfunction String$
Added rem_quote(s$) to remove qutoes from e.g. 'lol' or "lol" (if there are any)