4 * Revision 1.1 2001/04/04 05:43:39 wang
5 * First commit: compiles on Linux, Amiga, Windows, Windows CE, generic gcc
7 * Revision 1.3 1999/11/26 13:13:47 bnv
8 * Added: Windows CE support.
9 * Changed: To use the new macros.
11 * Revision 1.2 1998/11/26 09:47:11 bnv
12 * Changed: var 'match' in verify must be boolean
14 * Revision 1.1 1998/07/02 17:34:50 bnv
32 /* --------------------------------------------------------------- */
33 /* ABBREV(information,info[,length]) */
34 /* --------------------------------------------------------------- */
35 /* INDEX(haystack,needle[,start]) */
36 /* --------------------------------------------------------------- */
37 /* FIND(string,phrase[,start]) */
38 /* --------------------------------------------------------------- */
39 /* LASTPOS(needle,haystack[,start]) */
40 /* --------------------------------------------------------------- */
41 /* POS(needle,haystack[,start]) */
42 /* --------------------------------------------------------------- */
43 /* WORDPOS(phrase,string[,start]) */
44 /* --------------------------------------------------------------- */
46 R_SSoI( const int func
)
50 if (!IN_RANGE(2,ARGN
,3))
51 Lerror(ERR_INCORRECT_CALL
,0);
58 Licpy(ARGR
,Labbrev(ARG1
,ARG2
,l
));
62 Licpy(ARGR
,Lindex(ARG1
,ARG2
,l
));
66 Licpy(ARGR
,Lfind(ARG1
,ARG2
,l
));
70 Licpy(ARGR
,Llastpos(ARG1
,ARG2
,l
));
74 Licpy(ARGR
,Lpos(ARG1
,ARG2
,l
));
78 Licpy(ARGR
,Lwordpos(ARG1
,ARG2
,l
));
82 Lerror(ERR_INTERPRETER_FAILURE
,0);
86 /* --------------------------------------------------------------- */
87 /* CENTRE(string,length[,pad]) */
88 /* CENTER(string,length[,pad]) */
89 /* --------------------------------------------------------------- */
90 /* JUSTIFY(string,length[,pad]) */
91 /* --------------------------------------------------------------- */
92 /* LEFT(string,length[,pad]) */
93 /* --------------------------------------------------------------- */
94 /* RIGHT(string,length[,pad]) */
95 /* --------------------------------------------------------------- */
97 R_SIoC( const int func
)
102 if (!IN_RANGE(2,ARGN
,3))
103 Lerror(ERR_INCORRECT_CALL
,0);
111 Lcenter(ARGR
,ARG1
,l
,pad
);
115 Ljustify(ARGR
,ARG1
,l
,pad
);
119 Lleft(ARGR
,ARG1
,l
,pad
);
123 Lright(ARGR
,ARG1
,l
,pad
);
127 Lerror(ERR_INTERPRETER_FAILURE
,0);
131 /* --------------------------------------------------------------- */
133 /* --------------------------------------------------------------- */
135 /* --------------------------------------------------------------- */
137 /* --------------------------------------------------------------- */
139 /* --------------------------------------------------------------- */
141 /* --------------------------------------------------------------- */
142 /* REVERSE(string) */
143 /* --------------------------------------------------------------- */
145 /* --------------------------------------------------------------- */
147 /* --------------------------------------------------------------- */
149 /* --------------------------------------------------------------- */
150 /* -- WIN32_WCE -------------------------------------------------- */
152 /* --------------------------------------------------------------- */
154 /* --------------------------------------------------------------- */
156 R_S( const int func
)
161 if (ARGN
!=1) Lerror(ERR_INCORRECT_CALL
,0);
178 env
= getenv(LSTR(*ARG1
));
188 Licpy(ARGR
, LLEN(*ARG1
));
192 Licpy(ARGR
, Lwords(ARG1
));
205 if (Ldatatype(ARG1
,'S')==0) {
209 LINITSTR(str
); Lfx(&str
,LLEN(*ARG1
));
211 Lupper(&str
); LASCIIZ(str
);
212 RxVarFindOld(_Proc
[_rx_proc
].scope
,&str
,&found
);
231 size_t len
= LLEN(*ARG1
);
234 mbstowcs((TCHAR
*)(LSTR(*ARGR
)), LSTR(*ARG1
), len
+1);
236 LTYPE(*ARGR
) = LSTRING_TY
;
242 size_t len
= LLEN(*ARG1
)/2;
244 wcstombs(LSTR(*ARGR
), (TCHAR
*)(LSTR(*ARG1
)), len
);
246 LTYPE(*ARGR
) = LSTRING_TY
;
252 Lerror(ERR_INTERPRETER_FAILURE
,0);
255 /* --------------------------------------------------------------- */
256 /* DELSTR(string,n[,length]) */
257 /* --------------------------------------------------------------- */
258 /* DELWORD(string,n[,length]) */
259 /* --------------------------------------------------------------- */
260 /* SUBWORD(string,n[,length]) */
261 /* --------------------------------------------------------------- */
263 R_SIoI( const int func
)
267 if (!IN_RANGE(2,ARGN
,3))
268 Lerror(ERR_INCORRECT_CALL
,0);
275 Ldelstr(ARGR
,ARG1
,n
,l
);
279 Ldelword(ARGR
,ARG1
,n
,l
);
283 Lsubword(ARGR
,ARG1
,n
,l
);
287 Lerror(ERR_INTERPRETER_FAILURE
,0);
291 /* --------------------------------------------------------------- */
292 /* INSERT(new,target[,[n][,[length][,pad]]]) */
293 /* --------------------------------------------------------------- */
294 /* OVERLAY(new,target[,[n][,[length][,pad]]]) */
295 /* --------------------------------------------------------------- */
297 R_SSoIoIoC( const int func
)
302 if (!IN_RANGE(2,ARGN
,5))
303 Lerror(ERR_INCORRECT_CALL
,0);
312 Linsert(ARGR
,ARG1
,ARG2
,n
,l
,pad
);
316 Loverlay(ARGR
,ARG1
,ARG2
,n
,l
,pad
);
320 Lerror(ERR_INTERPRETER_FAILURE
,0);
324 /* --------------------------------------------------------------- */
325 /* CHANGESTR(searchstr,string,replacestr) */
326 /* --------------------------------------------------------------- */
331 Lerror(ERR_INCORRECT_CALL
,0);
335 Lchangestr(ARGR
,ARG1
,ARG2
,ARG3
);
338 /* --------------------------------------------------------------- */
339 /* COMPARE(string1,string2[,pad]) */
340 /* --------------------------------------------------------------- */
346 if (!IN_RANGE(2,ARGN
,3))
347 Lerror(ERR_INCORRECT_CALL
,0);
352 Licpy(ARGR
, Lcompare(ARG1
,ARG2
,pad
));
355 /* --------------------------------------------------------------- */
356 /* COPIES(string,n) */
357 /* --------------------------------------------------------------- */
364 Lerror(ERR_INCORRECT_CALL
,0);
366 must_exist(2); n
= Lrdint(ARG2
);
367 if (n
<0) Lerror(ERR_INCORRECT_CALL
,0);
369 Lcopies(ARGR
,ARG1
,n
);
372 /* --------------------------------------------------------------- */
373 /* SUBSTR(string,n[,[length][,pad]]) */
374 /* --------------------------------------------------------------- */
381 if (!IN_RANGE(2,ARGN
,4))
382 Lerror(ERR_INCORRECT_CALL
,0);
388 Lsubstr(ARGR
,ARG1
,n
,l
,pad
);
391 /* --------------------------------------------------------------- */
392 /* STRIP(string[,[<"L"|"T"|"B">][,char]]) */
393 /* --------------------------------------------------------------- */
400 if (!IN_RANGE(1,ARGN
,3))
401 Lerror(ERR_INCORRECT_CALL
,0);
404 if (exist(2)) { L2STR(ARG2
); action
= l2u
[(byte
)LSTR(*ARG2
)[0]]; }
406 Lstrip(ARGR
,ARG1
,action
,pad
);
409 /* --------------------------------------------------------------- */
410 /* TRANSLATE(string(,(tableo)(,(tablei)(,pad)))) */
411 /* --------------------------------------------------------------- */
418 if (!IN_RANGE(1,ARGN
,4))
419 Lerror(ERR_INCORRECT_CALL
,0);
441 Ltranslate(ARGR
,ARG1
,tableo
,tablei
,pad
);
444 /* --------------------------------------------------------------- */
445 /* VERIFY(string,reference[,[option][,start]]) */
446 /* --------------------------------------------------------------- */
453 if (!IN_RANGE(2,ARGN
,4))
454 Lerror(ERR_INCORRECT_CALL
,0);
460 match
= (l2u
[(byte
)LSTR(*ARG3
)[0]] == 'M');
463 Licpy(ARGR
,Lverify(ARG1
,ARG2
,match
,start
));
466 /* --------------------------------------------------------------- */
467 /* COUNTSTR(target,string) */
468 /* --------------------------------------------------------------- */
469 /* PUTENV(var,value) */
470 /* --------------------------------------------------------------- */
475 Lerror(ERR_INCORRECT_CALL
,0);
480 if (type
==f_countstr
)
482 Licpy(ARGR
,Lcountstr(ARG1
,ARG2
));
488 Licpy(ARGR
,setenv(LSTR(*ARG1
),LSTR(*ARG2
),TRUE
));
497 Licpy(ARGR
,putenv(LSTR(str
)));