| 1 |
/* |
| 2 |
* The Regina Rexx Interpreter |
| 3 |
* Copyright (C) 1992 Anders Christensen <[email protected]> |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 2 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* |
| 21 |
* Tests all builtin functions of rexx, except from: |
| 22 |
* |
| 23 |
* linein, linout, lines, charin, charout, chars |
| 24 |
* --> tested in fileio.rexx |
| 25 |
* |
| 26 |
* queued |
| 27 |
* --> tested in stack.rexx |
| 28 |
* |
| 29 |
* random |
| 30 |
* --> tested in trip.rexx |
| 31 |
*/ |
| 32 |
|
| 33 |
|
| 34 |
/* trace ?int */ |
| 35 |
written = 0 |
| 36 |
options FIND_BIF |
| 37 |
parse version intr ver . |
| 38 |
parse source os . |
| 39 |
If Substr(intr,1,11) = 'REXX-Regina' Then intr = 'regina' |
| 40 |
If Substr(intr,1,14) = 'REXX:Open-REXX' Then intr = 'unirexx' |
| 41 |
If Substr(intr,1,8) = 'REXX/imc' Then intr = 'rexximc' |
| 42 |
|
| 43 |
/* ======================= ABBREV ============================== */ |
| 44 |
call notify 'abbrev' |
| 45 |
call ch abbrev('information','info',4) ,1 |
| 46 |
call ch abbrev('information','',0) ,1 |
| 47 |
call ch abbrev('information','Info',4) ,0 |
| 48 |
call ch abbrev('information','info',5) ,0 |
| 49 |
call ch abbrev('information','info ') ,0 |
| 50 |
call ch abbrev('information','info',3) ,1 |
| 51 |
call ch abbrev('info','information',3) ,0 |
| 52 |
call ch abbrev('info','info',5) ,0 |
| 53 |
|
| 54 |
|
| 55 |
/* ========================== ABS ============================== */ |
| 56 |
call notify 'abs' |
| 57 |
call ch abs(-12.345) ,12.345 |
| 58 |
call ch abs(12.345) ,12.345 |
| 59 |
call ch abs(-0.0) ,0 |
| 60 |
call ch abs(0.0) ,0 |
| 61 |
|
| 62 |
/* ======================== ADDRESS ============================== */ |
| 63 |
call notify 'address' |
| 64 |
select |
| 65 |
when intr = 'regina' then |
| 66 |
do |
| 67 |
call ch address(), 'SYSTEM' |
| 68 |
call ch address('I'), 'INPUT NORMAL' |
| 69 |
call ch address('O'), 'REPLACE NORMAL' |
| 70 |
call ch address('E'), 'REPLACE NORMAL' |
| 71 |
address system with input fifo 'MYQUEUE' output stem mystem. error append stream 'my.err' |
| 72 |
call ch address('I'), 'INPUT FIFO MYQUEUE' |
| 73 |
call ch address('O'), 'REPLACE STEM MYSTEM.' |
| 74 |
call ch address('E'), 'APPEND STREAM my.err' |
| 75 |
/* |
| 76 |
* Reset address to default |
| 77 |
*/ |
| 78 |
Address System WITH INPUT NORMAL OUTPUT NORMAL ERROR NORMAL |
| 79 |
end |
| 80 |
when intr = 'unirexx' then call ch address(), 'CMD' |
| 81 |
when intr = 'rexximc' then call ch address(), 'UNIX' |
| 82 |
otherwise nop |
| 83 |
end |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
/* ========================== ARG ============================== */ |
| 88 |
call notify 'arg' |
| 89 |
call testarg2 1,,2 |
| 90 |
call testarg1 |
| 91 |
signal afterarg |
| 92 |
|
| 93 |
testarg1: |
| 94 |
call ch arg() ,'0' |
| 95 |
call ch arg(1) ,'' |
| 96 |
call ch arg(2) ,'' |
| 97 |
call ch arg(1,'e') ,'0' |
| 98 |
call ch arg(1,'O') ,'1' |
| 99 |
return |
| 100 |
|
| 101 |
testarg2: |
| 102 |
call ch arg() ,'3' |
| 103 |
call ch arg(1) ,'1' |
| 104 |
call ch arg(2) ,'' |
| 105 |
call ch arg(3) ,'2' |
| 106 |
call ch arg(4) ,'' |
| 107 |
call ch arg(1,'e') ,'1' |
| 108 |
call ch arg(2,'E') ,'0' |
| 109 |
call ch arg(2,'O') ,'1' |
| 110 |
call ch arg(3,'o') ,'0' |
| 111 |
call ch arg(4,'o') ,'1' |
| 112 |
return |
| 113 |
|
| 114 |
afterarg: |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
/* ========================= B2X =============================== */ |
| 119 |
call notify 'b2x' |
| 120 |
call ch b2x(''), '' |
| 121 |
call ch b2x('0'), '0' |
| 122 |
call ch b2x('1'), '1' |
| 123 |
call ch b2x('10'), '2' |
| 124 |
call ch b2x('010'), '2' |
| 125 |
call ch b2x('1010'), 'A' |
| 126 |
|
| 127 |
call ch b2x('1 0101'), '15' |
| 128 |
call ch b2x('1 01010101'), '155' |
| 129 |
call ch b2x('1 0101 0101'), '155' |
| 130 |
call ch b2x('10101 0101'), '155' |
| 131 |
call ch b2x('0000 00000000 0000'), '0000' |
| 132 |
call ch b2x('11111111 11111111'), 'FFFF' |
| 133 |
|
| 134 |
|
| 135 |
/* ======================= BITAND ============================== */ |
| 136 |
call notify 'bitand' |
| 137 |
call ch bitand( '123456'x, '3456'x ), '101456'x |
| 138 |
call ch bitand( '3456'x, '123456'x, '99'x ), '101410'x |
| 139 |
call ch bitand( '123456'x,, '55'x), '101454'x |
| 140 |
call ch bitand( 'foobar' ), 'foobar' |
| 141 |
call ch bitand( 'FooBar' ,, 'df'x), 'FOOBAR' /* for ASCII */ |
| 142 |
|
| 143 |
|
| 144 |
/* ======================== BITOR ============================== */ |
| 145 |
call notify 'bitor' |
| 146 |
call ch bitor( '123456'x, '3456'x ), '367656'x |
| 147 |
call ch bitor( '3456'x, '123456'x, '99'x ), '3676df'x |
| 148 |
call ch bitor( '123456'x,, '55'x), '577557'x |
| 149 |
call ch bitor( 'foobar' ), 'foobar' |
| 150 |
call ch bitor( 'FooBar' ,, '20'x), 'foobar' /* for ASCII */ |
| 151 |
|
| 152 |
|
| 153 |
/* ======================= BITXOR ============================== */ |
| 154 |
call notify 'bitxor' |
| 155 |
call ch bitxor( '123456'x, '3456'x ), '266256'x |
| 156 |
call ch bitxor( '3456'x, '123456'x, '99'x ), '2662cf'x |
| 157 |
call ch bitxor( '123456'x,, '55'x), '476103'x |
| 158 |
call ch bitxor( 'foobar' ), 'foobar' |
| 159 |
call ch bitxor( 'FooBar' ,, '20'x), 'fOObAR' /* for ASCII */ |
| 160 |
|
| 161 |
|
| 162 |
/* ======================== C2D ============================== */ |
| 163 |
call notify 'c2d' |
| 164 |
call ch c2d( 'ff80'x, 1), '-128' |
| 165 |
call ch c2d( 'foo' ) , '6713199' |
| 166 |
call ch c2d( 'bar' ), '6447474' |
| 167 |
call ch c2d( '' ), '0' |
| 168 |
call ch c2d( '101'x ), '257' |
| 169 |
call ch c2d( 'ff'x ), '255' |
| 170 |
call ch c2d( 'ffff'x), '65535' |
| 171 |
call ch c2d( 'ffff'x, 2), '-1' |
| 172 |
call ch c2d( 'ffff'x, 1), '-1' |
| 173 |
call ch c2d( 'fffe'x, 2), '-2' |
| 174 |
call ch c2d( 'fffe'x, 1), '-2' |
| 175 |
call ch c2d( 'ffff'x, 3), '65535' |
| 176 |
call ch c2d( 'ff7f'x, 1), '127' |
| 177 |
call ch c2d( 'ff7f'x, 2), '-129' |
| 178 |
call ch c2d( 'ff7f'x, 3), '65407' |
| 179 |
call ch c2d( 'ff80'x, 1), '-128' |
| 180 |
call ch c2d( 'ff80'x, 2), '-128' |
| 181 |
call ch c2d( 'ff80'x, 3), '65408' |
| 182 |
call ch c2d( 'ff81'x, 1), '-127' |
| 183 |
call ch c2d( 'ff81'x, 2), '-127' |
| 184 |
call ch c2d( 'ff81'x, 3), '65409' |
| 185 |
call ch c2d( 'ffffffffff'x, 5), '-1' |
| 186 |
|
| 187 |
|
| 188 |
/* ======================== C2X ============================== */ |
| 189 |
call notify 'c2x' |
| 190 |
call ch c2x( 'foobar'), '666F6F626172' |
| 191 |
call ch c2x( '' ), '' |
| 192 |
call ch c2x( '101'x ), '0101' |
| 193 |
call ch c2x( '0123456789abcdef'x ), '0123456789ABCDEF' |
| 194 |
call ch c2x( 'ffff'x ), 'FFFF' |
| 195 |
call ch c2x( 'ffffffff'x ), 'FFFFFFFF' |
| 196 |
|
| 197 |
|
| 198 |
/* ======================= CENTER ============================== */ |
| 199 |
call notify 'center' |
| 200 |
call ch center('****',8,'-') ,'--****--' |
| 201 |
call ch center('****',7,'-') ,'-****--' |
| 202 |
call ch center('*****',8,'-') ,'-*****--' |
| 203 |
call ch center('*****',7,'-') ,'-*****-' |
| 204 |
call ch center('12345678',4,'-') ,'3456' |
| 205 |
call ch center('12345678',5,'-') ,'23456' |
| 206 |
call ch center('1234567',4,'-') ,'2345' |
| 207 |
call ch center('1234567',5,'-') ,'23456' |
| 208 |
|
| 209 |
|
| 210 |
/* ===================== CHANGESTR ============================= */ |
| 211 |
call notify 'changestr' |
| 212 |
if ver > 4 Then |
| 213 |
do |
| 214 |
Call ch changestr('a','fred','c') , 'fred' |
| 215 |
Call ch changestr('','','x') , '' |
| 216 |
Call ch changestr('a','abcdef','x') , 'xbcdef' |
| 217 |
Call ch changestr('0','0','1') , '1' |
| 218 |
Call ch changestr('a','def','xyz') , 'def' |
| 219 |
Call ch changestr('a','','x') , '' |
| 220 |
Call ch changestr('','def','xyz') , 'def' |
| 221 |
Call ch changestr('abc','abcdef','xyz') , 'xyzdef' |
| 222 |
Call ch changestr('abcdefg','abcdef','xyz') , 'abcdef' |
| 223 |
Call ch changestr('abc','abcdefabccdabcd','z') , 'zdefzcdzd' |
| 224 |
end |
| 225 |
|
| 226 |
/* ====================== COMPARE ============================== */ |
| 227 |
call notify 'compare' |
| 228 |
call ch compare('foo', 'bar') , 1 |
| 229 |
call ch compare('foo', 'foo') , 0 |
| 230 |
call ch compare(' ', '' ) , 0 |
| 231 |
call ch compare('foo', 'f', 'o') , 0 |
| 232 |
call ch compare('foobar', 'foobag'), 6 |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
/* ======================= COPIES ============================== */ |
| 237 |
call notify 'copies' |
| 238 |
call ch copies('foo',3) , 'foofoofoo' |
| 239 |
call ch copies('x', 10) , 'xxxxxxxxxx' |
| 240 |
call ch copies('', 50) , '' |
| 241 |
call ch copies('', 0) , '' |
| 242 |
call ch copies('foobar',0 ) , '' |
| 243 |
|
| 244 |
/* ===================== COUNTSTR ============================== */ |
| 245 |
call notify 'countstr' |
| 246 |
if ver > 4 Then |
| 247 |
do |
| 248 |
Call ch countstr('','') , 0 |
| 249 |
Call ch countstr('a','abcdef') , 1 |
| 250 |
Call ch countstr(0,0) , 1 |
| 251 |
Call ch countstr('a','def') , 0 |
| 252 |
Call ch countstr('a','') , 0 |
| 253 |
Call ch countstr('','def') , 0 |
| 254 |
Call ch countstr('abc','abcdef') , 1 |
| 255 |
Call ch countstr('abcdefg','abcdef') , 0 |
| 256 |
Call ch countstr('abc','abcdefabccdabcd') , 3 |
| 257 |
end |
| 258 |
|
| 259 |
/* ===================== DATATYPE ============================== */ |
| 260 |
call notify 'datatype' |
| 261 |
call ch datatype('foobar'), 'CHAR' |
| 262 |
call ch datatype('foo bar'), 'CHAR' |
| 263 |
call ch datatype('123.456.789'), 'CHAR' |
| 264 |
call ch datatype('123.456'), 'NUM' |
| 265 |
call ch datatype(''), 'CHAR' |
| 266 |
call ch datatype('DeadBeef','A'), '1' |
| 267 |
call ch datatype('Dead Beef','A'), '0' |
| 268 |
call ch datatype('1234ABCD','A'), '1' |
| 269 |
call ch datatype('','A'), '0' |
| 270 |
call ch datatype('foobar','B'), '0' |
| 271 |
call ch datatype('01001101','B'), '1' |
| 272 |
call ch datatype('0110 1101','B'), '1' |
| 273 |
call ch datatype('0110 110','B'), '0' |
| 274 |
call ch datatype('','B'), '1' |
| 275 |
call ch datatype('foobar','L'), '1' |
| 276 |
call ch datatype('FooBar','L'), '0' |
| 277 |
call ch datatype('foo bar','L'), '0' |
| 278 |
call ch datatype('','L'), '0' |
| 279 |
call ch datatype('foobar','M'), '1' |
| 280 |
call ch datatype('FooBar','M'), '1' |
| 281 |
call ch datatype('foo bar','M'), '0' |
| 282 |
call ch datatype('FOOBAR','M'), '1' |
| 283 |
call ch datatype('','M'), '0' |
| 284 |
call ch datatype('foo bar','N'), '0' |
| 285 |
call ch datatype('1324.1234','N'), '1' |
| 286 |
call ch datatype('123.456.789','N'), '0' |
| 287 |
call ch datatype('','N'), '0' |
| 288 |
call ch datatype('foo bar','S'), '0' |
| 289 |
call ch datatype('??@##_Foo$Bar!!!','S'), '1' |
| 290 |
call ch datatype('999e+9','S'), '1' |
| 291 |
call ch datatype('','S'), '0' |
| 292 |
call ch datatype('foo bar','U'), '0' |
| 293 |
call ch datatype('Foo Bar','U'), '0' |
| 294 |
call ch datatype('FOOBAR','U'), '1' |
| 295 |
call ch datatype('','U'), '0' |
| 296 |
|
| 297 |
numeric digits 9 |
| 298 |
call ch datatype('Foobar','W'), '0' |
| 299 |
call ch datatype('123','W'), '1' |
| 300 |
call ch datatype('12.3','W'), '0' |
| 301 |
call ch datatype('','W'), '0' |
| 302 |
call ch datatype('123.123','W'), '0' |
| 303 |
call ch datatype('123.123E3','W'), '1' |
| 304 |
call ch datatype('123.0000003','W'), '0' |
| 305 |
call ch datatype('123.0000004','W'), '0' |
| 306 |
call ch datatype('123.0000005','W'), '0' |
| 307 |
call ch datatype('123.0000006','W'), '0' |
| 308 |
call ch datatype(' 23','W'), '1' |
| 309 |
call ch datatype(' 23 ','W'), '1' |
| 310 |
call ch datatype('23 ','W'), '1' |
| 311 |
call ch datatype('123.00','W'), '1' |
| 312 |
call ch datatype('123000E-2','W'), '1' |
| 313 |
call ch datatype('123000E+2','W'), '1' |
| 314 |
|
| 315 |
call ch datatype('Foobar','X'), '0' |
| 316 |
call ch datatype('DeadBeef','X'), '1' |
| 317 |
call ch datatype('A B C','X'), '0' |
| 318 |
call ch datatype('A BC DF','X'), '1' |
| 319 |
call ch datatype('123ABC','X'), '1' |
| 320 |
call ch datatype('123AHC','X'), '0' |
| 321 |
call ch datatype('','X'), '1' |
| 322 |
|
| 323 |
call ch datatype('0.000E-2','w'), '1' |
| 324 |
call ch datatype('0.000E-1','w'), '1' |
| 325 |
call ch datatype('0.000E0','w'), '1' |
| 326 |
call ch datatype('0.000E1','w'), '1' |
| 327 |
call ch datatype('0.000E2','w'), '1' |
| 328 |
call ch datatype('0.000E3','w'), '1' |
| 329 |
call ch datatype('0.000E4','w'), '1' |
| 330 |
call ch datatype('0.000E5','w'), '1' |
| 331 |
call ch datatype('0.000E6','w'), '1' |
| 332 |
|
| 333 |
call ch datatype('0E-1','w'), '1' |
| 334 |
call ch datatype('0E0','w'), '1' |
| 335 |
call ch datatype('0E1','w'), '1' |
| 336 |
call ch datatype('0E2','w'), '1' |
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
/* ====================== DELSTR ============================== */ |
| 341 |
call notify 'delstr' |
| 342 |
call ch delstr('Med lov skal land bygges', 6), 'Med l' |
| 343 |
call ch delstr('Med lov skal land bygges', 6,10), 'Med lnd bygges' |
| 344 |
call ch delstr('Med lov skal land bygges', 1), '' |
| 345 |
call ch delstr('Med lov skal', 30), 'Med lov skal' |
| 346 |
call ch delstr('Med lov skal', 8,8), 'Med lov' |
| 347 |
call ch delstr('Med lov skal', 12), 'Med lov ska' |
| 348 |
call ch delstr('Med lov skal', 13), 'Med lov skal' |
| 349 |
call ch delstr('Med lov skal', 14), 'Med lov skal' |
| 350 |
call ch delstr('', 30), '' |
| 351 |
|
| 352 |
/* ====================== DELWORD ============================== */ |
| 353 |
call notify 'delword' |
| 354 |
call ch delword('Med lov skal land bygges', 3), 'Med lov ' |
| 355 |
call ch delword('Med lov skal land bygges', 1), '' |
| 356 |
call ch delword('Med lov skal land bygges', 1,1), 'lov skal land bygges' |
| 357 |
call ch delword('Med lov skal land bygges', 2,3), 'Med bygges' |
| 358 |
call ch delword('Med lov skal land bygges', 2,10), 'Med ' |
| 359 |
call ch delword('Med lov skal land bygges', 3,2), 'Med lov bygges' |
| 360 |
call ch delword('Med lov skal land bygges', 3,2), 'Med lov bygges' |
| 361 |
call ch delword('Med lov skal land bygges', 3,2), 'Med lov bygges' |
| 362 |
call ch delword('Med lov skal land bygges', 3,0), 'Med lov skal land bygges' |
| 363 |
call ch delword('Med lov skal land bygges', 10), 'Med lov skal land bygges' |
| 364 |
call ch delword('Med lov skal land bygges', 9,9), 'Med lov skal land bygges' |
| 365 |
call ch delword('Med lov skal land bygges', 1,0), 'Med lov skal land bygges' |
| 366 |
call ch delword(' Med lov skal', 1,0), ' Med lov skal' |
| 367 |
call ch delword(' Med lov skal ', 4), ' Med lov skal ' |
| 368 |
call ch delword('', 1), '' |
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
/* ====================== DIGITS ============================== */ |
| 373 |
call notify 'digits' |
| 374 |
call ch digits(), '9' |
| 375 |
|
| 376 |
|
| 377 |
/* ======================= D2C ============================== */ |
| 378 |
call notify 'd2c' |
| 379 |
call ch d2c(127), '7f'x |
| 380 |
call ch d2c(128), '80'x |
| 381 |
call ch d2c(129), '81'x |
| 382 |
call ch d2c(1), '01'x |
| 383 |
call ch d2c(-1,1), 'FF'x |
| 384 |
call ch d2c(-127,1), '81'x |
| 385 |
call ch d2c(-128,1), '80'x |
| 386 |
call ch d2c(-129,1), '7F'x |
| 387 |
call ch d2c(-1,2), 'FFFF'x |
| 388 |
call ch d2c(-127,2), 'FF81'x |
| 389 |
call ch d2c(-128,2), 'FF80'x |
| 390 |
call ch d2c(-129,2), 'FF7F'x |
| 391 |
call ch d2c(129,0), '' |
| 392 |
call ch d2c(129,1), '81'x |
| 393 |
call ch d2c(256+129,2), '0181'x |
| 394 |
call ch d2c(256*256+256+129,3), '010181'x |
| 395 |
|
| 396 |
|
| 397 |
/* ======================= D2X ============================== */ |
| 398 |
call notify 'd2x' |
| 399 |
/* call ch d2x(0), '0' */ |
| 400 |
call ch d2x(127), '7F' |
| 401 |
call ch d2x(128), '80' |
| 402 |
call ch d2x(129), '81' |
| 403 |
call ch d2x(1), '1' |
| 404 |
call ch d2x(-1,2), 'FF' |
| 405 |
call ch d2x(-127,2), '81' |
| 406 |
call ch d2x(-128,2), '80' |
| 407 |
call ch d2x(-129,2), '7F' |
| 408 |
call ch d2x(-1,3), 'FFF' |
| 409 |
call ch d2x(-127,3), 'F81' |
| 410 |
call ch d2x(-128,4), 'FF80' |
| 411 |
call ch d2x(-129,5), 'FFF7F' |
| 412 |
call ch d2x(129,0), '' |
| 413 |
call ch d2x(129,2), '81' |
| 414 |
call ch d2x(256+129,4), '0181' |
| 415 |
call ch d2x(256*256+256+129,6), '010181' |
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
/* ===================== ERRORTEXT ============================== */ |
| 420 |
call notify 'errortext' |
| 421 |
call ch errortext(10), 'Unexpected or unmatched END' |
| 422 |
call ch errortext(40), 'Incorrect call to routine' |
| 423 |
call ch errortext(50), 'Unrecognized reserved symbol' |
| 424 |
call ch errortext( 1), '' |
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
/* ======================== FORM ============================== */ |
| 429 |
call notify 'form' |
| 430 |
call ch form(), 'SCIENTIFIC' |
| 431 |
|
| 432 |
|
| 433 |
/* ======================= FORMAT ============================== */ |
| 434 |
call notify 'format' |
| 435 |
call ch format(12.34), '12.34' |
| 436 |
call ch format(12.34,4), ' 12.34' |
| 437 |
call ch format(12.34,4,4), ' 12.3400' |
| 438 |
call ch format(12.34,4,1), ' 12.3' |
| 439 |
call ch format(12.35,4,1), ' 12.4' |
| 440 |
call ch format(12.34,,4), '12.3400' |
| 441 |
call ch format(12.34,4,0), ' 12' |
| 442 |
|
| 443 |
call ch format(99.995,3,2), '100.00' |
| 444 |
call ch format(0.111,,4), '0.1110' |
| 445 |
call ch format(0.0111,,4), '0.0111' |
| 446 |
call ch format(0.00111,,4), '0.0011' |
| 447 |
call ch format(0.000111,,4), '0.0001' |
| 448 |
call ch format(0.0000111,,4), '0.0000' |
| 449 |
call ch format(0.00000111,,4), '0.0000' |
| 450 |
call ch format(0.555,,4), '0.5550' |
| 451 |
call ch format(0.0555,,4), '0.0555' |
| 452 |
call ch format(0.00555,,4), '0.0056' |
| 453 |
call ch format(0.000555,,4), '0.0006' |
| 454 |
call ch format(0.0000555,,4), '0.0001' |
| 455 |
call ch format(0.00000555,,4), '0.0000' |
| 456 |
call ch format(0.999,,4), '0.9990' |
| 457 |
call ch format(0.0999,,4), '0.0999' |
| 458 |
call ch format(0.00999,,4), '0.0100' |
| 459 |
call ch format(0.000999,,4), '0.0010' |
| 460 |
call ch format(0.0000999,,4), '0.0001' |
| 461 |
call ch format(0.00000999,,4), '0.0000' |
| 462 |
call ch format(0.455,,4), '0.4550' |
| 463 |
call ch format(0.0455,,4), '0.0455' |
| 464 |
call ch format(0.00455,,4), '0.0046' |
| 465 |
call ch format(0.000455,,4), '0.0005' |
| 466 |
call ch format(0.0000455,,4), '0.0000' |
| 467 |
call ch format(0.00000455,,4), '0.0000' |
| 468 |
|
| 469 |
call ch format(1.00000045,,6), '1.000000' |
| 470 |
call ch format(1.000000045,,7), '1.0000001' /* this is an error in TRL */ |
| 471 |
call ch format(1.0000000045,,8), '1.00000000' |
| 472 |
|
| 473 |
call ch format(12.34,,,,0), '1.234E+1' |
| 474 |
call ch format(12.34,,,3,0), '1.234E+001' |
| 475 |
call ch format(12.34,,,3,), '12.34' |
| 476 |
call ch format(1.234,,,3,0), '1.234 ' |
| 477 |
call ch format(12.34,3,,,0), ' 1.234E+1' |
| 478 |
call ch format(12.34,,2,,0), '1.23E+1' |
| 479 |
call ch format(12.34,,3,,0), '1.234E+1' |
| 480 |
call ch format(12.34,,4,,0), '1.2340E+1' |
| 481 |
call ch format(12.345,,3,,0), '1.235E+1' |
| 482 |
|
| 483 |
call ch format(99.999,,,,), '99.999' |
| 484 |
call ch format(99.999,,2,,), '100.00' |
| 485 |
call ch format(99.999,,2,,2), '1.00E+2' |
| 486 |
call ch format(.999999,,4,2,2), '1.0000' |
| 487 |
call ch format(.999999,,5,2,2), '9.99999E-01' |
| 488 |
call ch format(.9999999,,5,2,2), '1.00000 ' |
| 489 |
call ch format(.999999,,6,2,2), '9.999990E-01' |
| 490 |
call ch format(90.999,,0), '91' |
| 491 |
call ch format(0099.999,5,3,,), ' 99.999' |
| 492 |
|
| 493 |
call ch format(0.0000000000000000001,4), ' 1E-19' |
| 494 |
call ch format(0.0000000000000000001,4,4), ' 1.0000E-19' |
| 495 |
call ch format(0.0000001,4,,,3), ' 1E-7' |
| 496 |
call ch format(0.0000001,4,4,,3), ' 1.0000E-7' |
| 497 |
call ch format(0.000001,4,4,,3), ' 0.0000' |
| 498 |
call ch format(0.0000001,4,5,,2), ' 1.00000E-7' |
| 499 |
call ch format(0.0000001,4,4,4,3), ' 1.0000E-0007' |
| 500 |
call ch format(1000,4,4,,3), ' 1.0000E+3' |
| 501 |
|
| 502 |
call ch format(0.0000000000000000000001), '1E-22' |
| 503 |
call ch format(0.0000000000000000000001,,,0,), '0.0000000000000000000001' |
| 504 |
call ch format(0.0000001,,,0,3), '0.0000001' |
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
/* ======================== FUZZ ============================== */ |
| 509 |
call notify 'fuzz' |
| 510 |
call ch fuzz(), '0' |
| 511 |
|
| 512 |
|
| 513 |
/* ======================= INSERT ============================== */ |
| 514 |
call notify 'insert' |
| 515 |
call ch insert('abc','def'), 'abcdef' |
| 516 |
call ch insert('abc','def',2), 'deabcf' |
| 517 |
call ch insert('abc','def',3), 'defabc' |
| 518 |
call ch insert('abc','def',5), 'def abc' |
| 519 |
call ch insert('abc','def',5,,'*'), 'def**abc' |
| 520 |
call ch insert('abc','def',5,4,'*'), 'def**abc*' |
| 521 |
call ch insert('abc','def',,0), 'def' |
| 522 |
call ch insert('abc','def',2,1), 'deaf' |
| 523 |
|
| 524 |
|
| 525 |
/* ====================== LASTPOS ============================== */ |
| 526 |
call notify 'lastpos' |
| 527 |
call ch lastpos('b', 'abc abc'), 6 |
| 528 |
call ch lastpos('b', 'abc abc',5), 2 |
| 529 |
call ch lastpos('b', 'abc abc',6), 6 |
| 530 |
call ch lastpos('b', 'abc abc',7), 6 |
| 531 |
call ch lastpos('x', 'abc abc'), 0 |
| 532 |
call ch lastpos('b', 'abc abc',20), 6 |
| 533 |
call ch lastpos('b', ''), 0 |
| 534 |
call ch lastpos('', 'c'), 0 |
| 535 |
call ch lastpos('', ''), 0 |
| 536 |
call ch lastpos('b', 'abc abc',20), 6 |
| 537 |
call ch lastpos('bc', 'abc abc'), 6 |
| 538 |
call ch lastpos('bc ', 'abc abc',20), 2 |
| 539 |
call ch lastpos('abc', 'abc abc',6), 1 |
| 540 |
call ch lastpos('abc', 'abc abc'), 5 |
| 541 |
call ch lastpos('abc', 'abc abc',7), 5 |
| 542 |
|
| 543 |
|
| 544 |
/* ======================== LEFT ============================== */ |
| 545 |
call notify 'left' |
| 546 |
call ch left('foobar',1), 'f' |
| 547 |
call ch left('foobar',0), '' |
| 548 |
call ch left('foobar',6), 'foobar' |
| 549 |
call ch left('foobar',8), 'foobar ' |
| 550 |
call ch left('foobar',8,'*'), 'foobar**' |
| 551 |
call ch left('foobar',1,'*'), 'f' |
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
/* ======================= LENGTH ============================== */ |
| 556 |
call notify 'length' |
| 557 |
call ch length(''), 0 |
| 558 |
call ch length('a'), 1 |
| 559 |
call ch length('abc'), 3 |
| 560 |
call ch length('abcdefghij'), 10 |
| 561 |
|
| 562 |
|
| 563 |
/* ======================= LOWER =============================== */ |
| 564 |
call notify 'lower' |
| 565 |
call ch lower('FOOBAR',2,3), 'FoobAR' |
| 566 |
call ch lower('FOOBAR',3), 'FOobar' |
| 567 |
call ch lower('FOOBAR',3,8), 'FOobar ' |
| 568 |
call ch lower('FOOBAR',3,8,'*'), 'FOobar**' |
| 569 |
call ch lower('FOOBAR',6,3), 'FOOBAr' |
| 570 |
call ch lower('FOOBAR',8,3), 'FOOBAR' |
| 571 |
|
| 572 |
|
| 573 |
/* ======================== MAX ============================== */ |
| 574 |
call notify 'max' |
| 575 |
call ch max( 10.1 ), '10.1' |
| 576 |
call ch max( -10.1, 3.8 ), '3.8' |
| 577 |
call ch max( 10.1, 10.2, 10.3 ), '10.3' |
| 578 |
call ch max( 10.3, 10.2, 10.3 ), '10.3' |
| 579 |
call ch max( 10.1, 10.2, 10.3 ), '10.3' |
| 580 |
call ch max( 10.1, 10.4, 10.3 ), '10.4' |
| 581 |
call ch max( 10.3, 10.2, 10.1 ), '10.3' |
| 582 |
call ch max( 1, 2, 4, 5 ), '5' |
| 583 |
call ch max( -0, 0 ), '0' |
| 584 |
call ch max( 1,2,3,4,5,6,7,8,7,6,5,4,3,2 ), '8' |
| 585 |
|
| 586 |
|
| 587 |
/* ======================== MIN ============================== */ |
| 588 |
call notify 'min' |
| 589 |
call ch min( 10.1 ), '10.1' |
| 590 |
call ch min( -10.1, 3.8 ), '-10.1' |
| 591 |
call ch min( 10.1, 10.2, 10.3 ), '10.1' |
| 592 |
call ch min( 10.1, 10.2, 10.1 ), '10.1' |
| 593 |
call ch min( 10.1, 10.2, 10.3 ), '10.1' |
| 594 |
call ch min( 10.4, 10.1, 10.3 ), '10.1' |
| 595 |
call ch min( 10.3, 10.2, 10.1 ), '10.1' |
| 596 |
call ch min( 5, 2, 4, 1 ), '1' |
| 597 |
call ch min( -0, 0 ), '0' |
| 598 |
call ch min( 8,2,3,4,5,6,7,1,7,6,5,4,3,2 ), '1' |
| 599 |
|
| 600 |
/* ====================== OVERLAY ============================== */ |
| 601 |
call notify 'overlay' |
| 602 |
call ch overlay('foo', 'abcdefghi',3,4,'*'), 'abfoo*ghi' |
| 603 |
call ch overlay('foo', 'abcdefghi',3,2,'*'), 'abfoefghi' |
| 604 |
call ch overlay('foo', 'abcdefghi',3,4,), 'abfoo ghi' |
| 605 |
call ch overlay('foo', 'abcdefghi',3), 'abfoofghi' |
| 606 |
call ch overlay('foo', 'abcdefghi',,4,'*'), 'foo*efghi' |
| 607 |
call ch overlay('foo', 'abcdefghi',9,4,'*'), 'abcdefghfoo*' |
| 608 |
call ch overlay('foo', 'abcdefghi',10,4,'*'), 'abcdefghifoo*' |
| 609 |
call ch overlay('foo', 'abcdefghi',11,4,'*'), 'abcdefghi*foo*' |
| 610 |
call ch overlay('', 'abcdefghi',3), 'abcdefghi' |
| 611 |
call ch overlay('foo', '',3), ' foo' |
| 612 |
call ch overlay('', '',3,4,'*'), '******' |
| 613 |
call ch overlay('', ''), '' |
| 614 |
|
| 615 |
/* ======================== POS ============================== */ |
| 616 |
call notify 'pos' |
| 617 |
call ch pos('foo','a foo foo b'), 3 |
| 618 |
call ch pos('foo','a foo foo',3), 3 |
| 619 |
call ch pos('foo','a foo foo',4), 7 |
| 620 |
call ch pos('foo','a foo foo b',30), 0 |
| 621 |
call ch pos('foo','a foo foo b',1), 3 |
| 622 |
call ch pos('','a foo foo b'), 0 |
| 623 |
call ch pos('foo',''), 0 |
| 624 |
call ch pos('',''), 0 |
| 625 |
call ch pos('b','a'), 0 |
| 626 |
call ch pos('b','b'), 1 |
| 627 |
call ch pos('b','abc'), 2 |
| 628 |
call ch pos('b','def'), 0 |
| 629 |
call ch pos('foo','foo foo b'), 1 |
| 630 |
|
| 631 |
if intr = 'regina' then do |
| 632 |
call ch index('a foo foo b','foo'), 3 |
| 633 |
call ch index('a foo foo','foo',3), 3 |
| 634 |
call ch index('a foo foo','foo',4), 7 |
| 635 |
call ch index('a foo foo b','foo',30), 0 |
| 636 |
call ch index('a foo foo b','foo',1), 3 |
| 637 |
call ch index('a foo foo b',''), 0 |
| 638 |
call ch index('','foo'), 0 |
| 639 |
call ch index('',''), 0 |
| 640 |
call ch index('a','b'), 0 |
| 641 |
call ch index('b','b'), 1 |
| 642 |
call ch index('abc','b'), 2 |
| 643 |
call ch index('def','b'), 0 |
| 644 |
call ch index('foo foo b','foo'), 1 |
| 645 |
end |
| 646 |
|
| 647 |
/* ====================== REVERSE ============================== */ |
| 648 |
call notify 'reverse' |
| 649 |
call ch reverse('foobar'), 'raboof' |
| 650 |
call ch reverse(''), '' |
| 651 |
call ch reverse('fubar'), 'rabuf' |
| 652 |
call ch reverse('f'), 'f' |
| 653 |
call ch reverse(' foobar '), ' raboof ' |
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
/* ======================= RIGHT ============================== */ |
| 658 |
call notify 'right' |
| 659 |
call ch right('',4), ' ' |
| 660 |
call ch right('foobar',0), '' |
| 661 |
call ch right('foobar',3), 'bar' |
| 662 |
call ch right('foobar',6), 'foobar' |
| 663 |
call ch right('foobar',8), ' foobar' |
| 664 |
call ch right('foobar',8,'*'), '**foobar' |
| 665 |
call ch right('foobar',4,'*'), 'obar' |
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
/* ======================== SIGN ============================== */ |
| 670 |
call notify 'sign' |
| 671 |
call ch sign('0'), 0 |
| 672 |
call ch sign('-0'), 0 |
| 673 |
call ch sign('0.4'), 1 |
| 674 |
call ch sign('-10'), -1 |
| 675 |
call ch sign('15'), 1 |
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
/* ===================== SOURCELINE ============================== */ |
| 680 |
call notify 'sourceline' |
| 681 |
parse source . . srcfile . |
| 682 |
call ch sourceline(), lines(srcfile,'C') /* don't work for stdin */ |
| 683 |
call ch sourceline(whatline()-2), ' parse source . . srcfile .' |
| 684 |
call ch sourceline(whatline()-4), "call notify 'sourceline'" |
| 685 |
|
| 686 |
signal aftersrc |
| 687 |
whatline: return sigl |
| 688 |
aftersrc: |
| 689 |
|
| 690 |
|
| 691 |
/* ======================== SPACE ============================== */ |
| 692 |
call notify 'space' |
| 693 |
call ch space(' foo ') ,'foo' |
| 694 |
call ch space(' foo') ,'foo' |
| 695 |
call ch space('foo ') ,'foo' |
| 696 |
call ch space(' foo ') ,'foo' |
| 697 |
call ch space(' foo bar ') ,'foo bar' |
| 698 |
call ch space(' foo bar ') ,'foo bar' |
| 699 |
call ch space(' foo bar ',2) ,'foo bar' |
| 700 |
call ch space(' foo bar ',,'-') ,'foo-bar' |
| 701 |
call ch space(' foo bar ',2,'-') ,'foo--bar' |
| 702 |
call ch space(' f-- b-- ',2,'-') ,'f----b--' |
| 703 |
call ch space(' f o o b a r ',0) ,'foobar' |
| 704 |
|
| 705 |
|
| 706 |
/* ======================= STRIP ============================== */ |
| 707 |
call notify 'strip' |
| 708 |
call ch strip(' foo bar '), 'foo bar' |
| 709 |
call ch strip(' foo bar ','L'), 'foo bar ' |
| 710 |
call ch strip(' foo bar ','T'), ' foo bar' |
| 711 |
call ch strip(' foo bar ','B'), 'foo bar' |
| 712 |
call ch strip(' foo bar ','B','*'), ' foo bar ' |
| 713 |
call ch strip(' foo bar',,'r'), ' foo ba' |
| 714 |
call ch strip(' foo' || '0a'x || '09'x || ' '), 'foo' /* this is not an error */ |
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
/* ======================= SUBSTR ============================== */ |
| 719 |
call notify 'substr' |
| 720 |
call ch substr('foobar',2,3), 'oob' |
| 721 |
call ch substr('foobar',3), 'obar' |
| 722 |
call ch substr('foobar',3,6), 'obar ' |
| 723 |
call ch substr('foobar',3,6,'*'), 'obar**' |
| 724 |
call ch substr('foobar',6,3), 'r ' |
| 725 |
call ch substr('foobar',8,3), ' ' |
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
/* ======================= SUBWORD ============================== */ |
| 730 |
call notify 'subword' |
| 731 |
call ch subword(' to be or not to be ',5), 'to be' |
| 732 |
call ch subword(' to be or not to be ',6), 'be' |
| 733 |
call ch subword(' to be or not to be ',7), '' |
| 734 |
call ch subword(' to be or not to be ',8,7), '' |
| 735 |
call ch subword(' to be or not to be ',3,2), 'or not' |
| 736 |
call ch subword(' to be or not to be ',1,2), 'to be' |
| 737 |
call ch subword(' to be or not to be ',4,2), 'not to' |
| 738 |
call ch subword('abc de f', 3), 'f' |
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
/* ======================= SYMBOL ============================== */ |
| 743 |
|
| 744 |
call notify 'symbol' |
| 745 |
parse value 'foobar' with alpha 1 beta 1 omega 1 gamma.foobar |
| 746 |
omega = 'FOOBAR' |
| 747 |
call ch symbol('HEPP'), 'LIT' |
| 748 |
call ch symbol('ALPHA'), 'VAR' |
| 749 |
call ch symbol('Un*x'), 'BAD' |
| 750 |
call ch symbol('gamma.delta'), 'LIT' |
| 751 |
call ch symbol('gamma.FOOBAR'), 'VAR' |
| 752 |
call ch symbol('gamma.alpha'), 'LIT' |
| 753 |
call ch symbol('gamma.omega'), 'VAR' |
| 754 |
call ch symbol('gamma.Un*x'), 'LIT' |
| 755 |
call ch symbol('Un*x.gamma'), 'BAD' |
| 756 |
call ch symbol('!!'), 'LIT' |
| 757 |
call ch symbol(''), 'BAD' |
| 758 |
call ch symbol('00'x), 'BAD' |
| 759 |
call ch symbol('foo-bar'), 'BAD' |
| 760 |
|
| 761 |
|
| 762 |
/* ======================= TRACE ============================== */ |
| 763 |
|
| 764 |
|
| 765 |
/* ====================== TRANSLATE ============================== */ |
| 766 |
call notify 'translate' |
| 767 |
call ch translate('Foo Bar'), 'FOO BAR' |
| 768 |
call ch translate('Foo Bar',,''), 'Foo Bar' |
| 769 |
call ch translate('Foo Bar','',), ' ' |
| 770 |
call ch translate('Foo Bar','',,'*'), '*******' |
| 771 |
call ch translate('Foo Bar',xrange('01'x,'ff'x)), 'Gpp!Cbs' |
| 772 |
call ch translate('','klasjdf','woieruw'), '' |
| 773 |
call ch translate('foobar','abcdef','fedcba'), 'aooefr' |
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
/* ======================= TRUNC ============================== */ |
| 778 |
call notify 'trunc' |
| 779 |
call ch trunc(1234.5678, 2), '1234.56' |
| 780 |
call ch trunc(-1234.5678), '-1234' |
| 781 |
call ch trunc(.5678), '0' |
| 782 |
call ch trunc(.00123), '0' |
| 783 |
call ch trunc(.00123,4), '0.0012' |
| 784 |
call ch trunc(.00127,4), '0.0012' |
| 785 |
call ch trunc(.1678), '0' |
| 786 |
call ch trunc(1234.5678), '1234' |
| 787 |
call ch trunc(4.5678, 7), '4.5678000' |
| 788 |
|
| 789 |
call ch trunc(10000005.0,2), 10000005.00 |
| 790 |
call ch trunc(10000000.5,2), 10000000.50 |
| 791 |
call ch trunc(10000000.05,2), 10000000.10 |
| 792 |
call ch trunc(10000000.005,2), 10000000.00 |
| 793 |
|
| 794 |
call ch trunc(10000005.5,2), 10000005.50 |
| 795 |
call ch trunc(10000000.55,2), 10000000.60 |
| 796 |
call ch trunc(10000000.055,2), 10000000.10 |
| 797 |
call ch trunc(10000000.0055,2), 10000000.00 |
| 798 |
|
| 799 |
call ch trunc(10000000.04,2), 10000000.00 |
| 800 |
call ch trunc(10000000.045,2), 10000000.00 |
| 801 |
call ch trunc(10000000.45,2), 10000000.50 |
| 802 |
|
| 803 |
call ch trunc(10000000.05,2), 10000000.10 |
| 804 |
call ch trunc(10000000.05,2), 10000000.10 |
| 805 |
call ch trunc(10000000.05,2), 10000000.10 |
| 806 |
|
| 807 |
call ch trunc(99999999.,2), 99999999.00 |
| 808 |
call ch trunc(99999999.9,2), 99999999.90 |
| 809 |
call ch trunc(99999999.99,2), 100000000.00 |
| 810 |
|
| 811 |
call ch trunc(1E2,0), 100 |
| 812 |
call ch trunc(12E1,0), 120 |
| 813 |
call ch trunc(123.,0), 123 |
| 814 |
call ch trunc(123.1,0), 123 |
| 815 |
call ch trunc(123.12,0), 123 |
| 816 |
call ch trunc(123.123,0), 123 |
| 817 |
call ch trunc(123.1234,0), 123 |
| 818 |
call ch trunc(123.12345,0), 123 |
| 819 |
|
| 820 |
call ch trunc(1E2,1), 100.0 |
| 821 |
call ch trunc(12E1,1), 120.0 |
| 822 |
call ch trunc(123.,1), 123.0 |
| 823 |
call ch trunc(123.1,1), 123.1 |
| 824 |
call ch trunc(123.12,1), 123.1 |
| 825 |
call ch trunc(123.123,1), 123.1 |
| 826 |
call ch trunc(123.1234,1), 123.1 |
| 827 |
call ch trunc(123.12345,1), 123.1 |
| 828 |
|
| 829 |
call ch trunc(1E2,2), 100.00 |
| 830 |
call ch trunc(12E1,2), 120.00 |
| 831 |
call ch trunc(123.,2), 123.00 |
| 832 |
call ch trunc(123.1,2), 123.10 |
| 833 |
call ch trunc(123.12,2), 123.12 |
| 834 |
call ch trunc(123.123,2), 123.12 |
| 835 |
call ch trunc(123.1234,2), 123.12 |
| 836 |
call ch trunc(123.12345,2), 123.12 |
| 837 |
|
| 838 |
call ch trunc(1E2,3), 100.000 |
| 839 |
call ch trunc(12E1,3), 120.000 |
| 840 |
call ch trunc(123.,3), 123.000 |
| 841 |
call ch trunc(123.1,3), 123.100 |
| 842 |
call ch trunc(123.12,3), 123.120 |
| 843 |
call ch trunc(123.123,3), 123.123 |
| 844 |
call ch trunc(123.1234,3), 123.123 |
| 845 |
call ch trunc(123.12345,3), 123.123 |
| 846 |
|
| 847 |
call ch trunc(1E2,4), 100.0000 |
| 848 |
call ch trunc(12E1,4), 120.0000 |
| 849 |
call ch trunc(123.,4), 123.0000 |
| 850 |
call ch trunc(123.1,4), 123.1000 |
| 851 |
call ch trunc(123.12,4), 123.1200 |
| 852 |
call ch trunc(123.123,4), 123.1230 |
| 853 |
call ch trunc(123.1234,4), 123.1234 |
| 854 |
call ch trunc(123.12345,4), 123.1234 |
| 855 |
|
| 856 |
call ch trunc(1E2,5), 100.00000 |
| 857 |
call ch trunc(12E1,5), 120.00000 |
| 858 |
call ch trunc(123.,5), 123.00000 |
| 859 |
call ch trunc(123.1,5), 123.10000 |
| 860 |
call ch trunc(123.12,5), 123.12000 |
| 861 |
call ch trunc(123.123,5), 123.12300 |
| 862 |
call ch trunc(123.1234,5), 123.12340 |
| 863 |
call ch trunc(123.12345,5), 123.12345 |
| 864 |
|
| 865 |
|
| 866 |
/* ======================= UPPER =============================== */ |
| 867 |
call notify 'upper' |
| 868 |
call ch upper('foobar',2,3), 'fOOBar' |
| 869 |
call ch upper('foobar',3), 'foOBAR' |
| 870 |
call ch upper('foobar',3,8), 'foOBAR ' |
| 871 |
call ch upper('foobar',3,8,'*'), 'foOBAR**' |
| 872 |
call ch upper('foobar',6,3), 'foobaR' |
| 873 |
call ch upper('foobar',8,3), 'foobar' |
| 874 |
call ch upper('foobar',1,1), 'Foobar' |
| 875 |
|
| 876 |
|
| 877 |
/* ======================= VALUE ============================== */ |
| 878 |
call notify 'value' |
| 879 |
x.a = 'asdf' |
| 880 |
x.b = 'foo' |
| 881 |
x.c = 'A' |
| 882 |
a = 'B' |
| 883 |
b = 'C' |
| 884 |
c = 'A' |
| 885 |
|
| 886 |
call ch value('a'), 'B' |
| 887 |
call ch value(a), 'C' |
| 888 |
call ch value(c), 'B' |
| 889 |
call ch value('c'), 'A' |
| 890 |
call ch value('x.A'), 'foo' |
| 891 |
call ch value(x.B), 'B' |
| 892 |
call ch value('x.B'), 'A' |
| 893 |
call ch value('x.'||a), 'A' |
| 894 |
call ch value(value(x.b)), 'C' |
| 895 |
|
| 896 |
xyzzy = 'foo' |
| 897 |
call ch value('xyzzy'), 'foo' |
| 898 |
call ch value('xyzzy','bar'), 'foo' |
| 899 |
call ch value('xyzzy'), 'bar' |
| 900 |
call ch value('xyzzy','bar'), 'bar' |
| 901 |
call ch value('xyzzy'), 'bar' |
| 902 |
call ch value('xyzzy','foo'), 'bar' |
| 903 |
call ch value('xyzzy'), 'foo' |
| 904 |
|
| 905 |
xyzzy = 'void' |
| 906 |
if os = 'UNIX' | os = 'AMIGA' Then |
| 907 |
envvar = '$xyzzy' |
| 908 |
else |
| 909 |
envvar = '%xyzzy%' |
| 910 |
call value 'xyzzy', 'bar', 'ENVIRONMENT' |
| 911 |
call ch value('xyzzy', 'bar', 'ENVIRONMENT'), 'bar' |
| 912 |
call ch value('xyzzy',, 'ENVIRONMENT'), 'bar' |
| 913 |
call ch value('xyzzy', , 'ENVIRONMENT'), 'echo'(envvar) |
| 914 |
call ch value('xyzzy', 'foo', 'ENVIRONMENT'), 'bar' |
| 915 |
call ch value('xyzzy', 'bar', 'ENVIRONMENT'), 'foo' |
| 916 |
call ch value('xyzzy', , 'ENVIRONMENT'), 'echo'(envvar) |
| 917 |
call ch value('xyzzy', , 'ENVIRONMENT'), 'bar' |
| 918 |
call ch value('xyzzy', 'foo', 'ENVIRONMENT'), 'bar' |
| 919 |
call ch value('xyzzy', , 'ENVIRONMENT'), 'echo'(envvar) |
| 920 |
|
| 921 |
|
| 922 |
/* ======================= VERIFY ============================== */ |
| 923 |
call notify 'verify' |
| 924 |
call ch verify('foobar', 'barfo', N, 1), 0 |
| 925 |
call ch verify('foobar', 'barfo', M, 1), 1 |
| 926 |
call ch verify('', 'barfo'), 0 |
| 927 |
call ch verify('foobar', ''), 1 |
| 928 |
call ch verify('foobar', 'barf', N, 3), 3 |
| 929 |
call ch verify('foobar', 'barf', N, 4), 0 |
| 930 |
call ch verify('', ''), 0 |
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
/* ======================== WORD ============================== */ |
| 935 |
call notify 'word' |
| 936 |
call ch word('This is certainly a test',1), 'This' |
| 937 |
call ch word(' This is certainly a test',1), 'This' |
| 938 |
call ch word('This is certainly a test',1), 'This' |
| 939 |
call ch word('This is certainly a test',2), 'is' |
| 940 |
call ch word('This is certainly a test',2), 'is' |
| 941 |
call ch word('This is certainly a test',5), 'test' |
| 942 |
call ch word('This is certainly a test ',5), 'test' |
| 943 |
call ch word('This is certainly a test',6), '' |
| 944 |
call ch word('',1), '' |
| 945 |
call ch word('',10), '' |
| 946 |
call ch word('test ',2), '' |
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
/* ====================== WORDINDEX ============================== */ |
| 951 |
call notify 'wordindex' |
| 952 |
call ch wordindex('This is certainly a test',1), '1' |
| 953 |
call ch wordindex(' This is certainly a test',1), '3' |
| 954 |
call ch wordindex('This is certainly a test',1), '1' |
| 955 |
call ch wordindex(' This is certainly a test',1), '3' |
| 956 |
call ch wordindex('This is certainly a test',2), '6' |
| 957 |
call ch wordindex('This is certainly a test',2), '8' |
| 958 |
call ch wordindex('This is certainly a test',2), '6' |
| 959 |
call ch wordindex('This is certainly a test',2), '8' |
| 960 |
call ch wordindex('This is certainly a test',5), '21' |
| 961 |
call ch wordindex('This is certainly a test',5), '23' |
| 962 |
call ch wordindex('This is certainly a test ',5), '21' |
| 963 |
call ch wordindex('This is certainly a test ',6), '0' |
| 964 |
call ch wordindex('This is certainly a test',6), '0' |
| 965 |
call ch wordindex('This is certainly a test',7), '0' |
| 966 |
call ch wordindex('This is certainly a test ',7), '0' |
| 967 |
|
| 968 |
|
| 969 |
/* ===================== WORDLENGTH ============================== */ |
| 970 |
call notify 'wordlength' |
| 971 |
call ch wordlength('This is certainly a test',1), '4' |
| 972 |
call ch wordlength('This is certainly a test',2), '2' |
| 973 |
call ch wordlength('This is certainly a test',5), '4' |
| 974 |
call ch wordlength('This is certainly a test ',5), '4' |
| 975 |
call ch wordlength('This is certainly a test',6), '0' |
| 976 |
call ch wordlength('',1), '0' |
| 977 |
call ch wordlength('',10), '0' |
| 978 |
|
| 979 |
|
| 980 |
/* ====================== WORDPOS ============================== */ |
| 981 |
call notify 'wordpos' |
| 982 |
call ch wordpos('This','This is a small test'), 1 |
| 983 |
call ch wordpos('test','This is a small test'), 5 |
| 984 |
call ch wordpos('foo','This is a small test'), 0 |
| 985 |
call ch wordpos(' This ','This is a small test'), 1 |
| 986 |
call ch wordpos('This',' This is a small test'), 1 |
| 987 |
call ch wordpos('This','This is a small test'), 1 |
| 988 |
call ch wordpos('This','this is a small This'), 5 |
| 989 |
call ch wordpos('This','This is a small This'), 1 |
| 990 |
call ch wordpos('This','This is a small This',2), 5 |
| 991 |
call ch wordpos('is a ','This is a small test'), 2 |
| 992 |
call ch wordpos('is a ','This is a small test'), 2 |
| 993 |
call ch wordpos(' is a ','This is a small test'), 2 |
| 994 |
call ch wordpos('is a ','This is a small test',2), 2 |
| 995 |
call ch wordpos('is a ','This is a small test',3), 0 |
| 996 |
call ch wordpos('is a ','This is a small test',4), 0 |
| 997 |
call ch wordpos('test ','This is a small test'), 5 |
| 998 |
call ch wordpos('test ','This is a small test',5), 5 |
| 999 |
call ch wordpos('test ','This is a small test',6), 0 |
| 1000 |
call ch wordpos('test ','This is a small test '), 5 |
| 1001 |
call ch wordpos(' test','This is a small test ',6), 0 |
| 1002 |
call ch wordpos('test ','This is a small test ',5), 5 |
| 1003 |
call ch wordpos(' ','This is a small test'), 0 |
| 1004 |
call ch wordpos(' ','This is a small test',3), 0 |
| 1005 |
call ch wordpos('','This is a small test',4), 0 |
| 1006 |
call ch wordpos('test ',''), 0 |
| 1007 |
call ch wordpos('',''), 0 |
| 1008 |
call ch wordpos('',' '), 0 |
| 1009 |
call ch wordpos(' ',''), 0 |
| 1010 |
call ch wordpos(' ','',3), 0 |
| 1011 |
call ch wordpos(' a ',''), 0 |
| 1012 |
call ch wordpos(' a ','a'), 1 |
| 1013 |
|
| 1014 |
call ch find('This is a small test','This'), 1 |
| 1015 |
call ch find('This is a small test','test'), 5 |
| 1016 |
call ch find('This is a small test','foo'), 0 |
| 1017 |
call ch find('This is a small test',' This '), 1 |
| 1018 |
call ch find(' This is a small test','This'), 1 |
| 1019 |
call ch find('This is a small test','This'), 1 |
| 1020 |
call ch find('this is a small This','This'), 5 |
| 1021 |
call ch find('This is a small This','This'), 1 |
| 1022 |
call ch find('This is a small This','This',2), 5 |
| 1023 |
call ch find('This is a small test','is a '), 2 |
| 1024 |
call ch find('This is a small test','is a '), 2 |
| 1025 |
call ch find('This is a small test',' is a '), 2 |
| 1026 |
call ch find('This is a small test','is a ',2), 2 |
| 1027 |
call ch find('This is a small test','is a ',3), 0 |
| 1028 |
call ch find('This is a small test','is a ',4), 0 |
| 1029 |
call ch find('This is a small test','test '), 5 |
| 1030 |
call ch find('This is a small test','test ',5), 5 |
| 1031 |
call ch find('This is a small test','test ',6), 0 |
| 1032 |
call ch find('This is a small test ','test '), 5 |
| 1033 |
call ch find('This is a small test ',' test',6), 0 |
| 1034 |
call ch find('This is a small test ','test ',5), 5 |
| 1035 |
call ch find('This is a small test',' '), 0 |
| 1036 |
call ch find('This is a small test',' ',3), 0 |
| 1037 |
call ch find('This is a small test','',4), 0 |
| 1038 |
call ch find('','test '), 0 |
| 1039 |
call ch find('',''), 0 |
| 1040 |
call ch find(' ',''), 0 |
| 1041 |
call ch find('',' '), 0 |
| 1042 |
call ch find('',' ',3), 0 |
| 1043 |
call ch find('',' a '), 0 |
| 1044 |
call ch find('a',' a '), 1 |
| 1045 |
|
| 1046 |
|
| 1047 |
/* ======================= WORDS ============================== */ |
| 1048 |
call notify 'words' |
| 1049 |
call ch words('This is certainly a test'), 5 |
| 1050 |
call ch words(' This is certainly a test'), 5 |
| 1051 |
call ch words('This is certainly a test'), 5 |
| 1052 |
call ch words('This is certainly a test '), 5 |
| 1053 |
call ch words(' hepp '), 1 |
| 1054 |
call ch words(' hepp hepp '), 2 |
| 1055 |
call ch words(''), 0 |
| 1056 |
call ch words(' '), 0 |
| 1057 |
|
| 1058 |
|
| 1059 |
/* ======================= XRANGE ============================== */ |
| 1060 |
call notify 'xrange' |
| 1061 |
call ch xrange('f','r'), 'fghijklmnopqr' |
| 1062 |
call ch xrange('7d'x,'83'x), '7d7e7f80818283'x |
| 1063 |
call ch xrange('a','a'), 'a' |
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
/* ======================== X2B ============================== */ |
| 1068 |
call ch x2b('416263'), '010000010110001001100011' |
| 1069 |
call ch x2b('DeadBeef'), '11011110101011011011111011101111' |
| 1070 |
call ch x2b('1 02 03'), '00010000001000000011' |
| 1071 |
call ch x2b('102 03'), '00010000001000000011' |
| 1072 |
call ch x2b('102'), '000100000010' |
| 1073 |
call ch x2b('11 2F'), '0001000100101111' |
| 1074 |
call ch x2b(''), '' |
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
/* ======================== X2C ============================== */ |
| 1080 |
call notify 'x2c' |
| 1081 |
call ch x2c('416263'), 'Abc' |
| 1082 |
call ch x2c('DeadBeef'), 'deadbeef'x |
| 1083 |
call ch x2c('1 02 03'), '010203'x |
| 1084 |
call ch x2c('11 0222 3333 044444'), '1102223333044444'x |
| 1085 |
call ch x2c(''), '' |
| 1086 |
call ch x2c('2'), '02'x |
| 1087 |
call ch x2c('1 02 03'), '010203'x |
| 1088 |
|
| 1089 |
|
| 1090 |
|
| 1091 |
/* ======================== X2D ============================== */ |
| 1092 |
call notify 'x2d' |
| 1093 |
call ch x2d( 'ff80', 2), '-128' |
| 1094 |
call ch x2d( 'ff80', 1), '0' |
| 1095 |
call ch x2d( 'ff 80', 1), '0' |
| 1096 |
call ch x2d( '' ), '0' |
| 1097 |
call ch x2d( '101' ), '257' |
| 1098 |
call ch x2d( 'ff' ), '255' |
| 1099 |
call ch x2d( 'ffff'), '65535' |
| 1100 |
|
| 1101 |
call ch x2d( 'ffff', 2), '-1' |
| 1102 |
call ch x2d( 'ffff', 1), '-1' |
| 1103 |
call ch x2d( 'fffe', 2), '-2' |
| 1104 |
call ch x2d( 'fffe', 1), '-2' |
| 1105 |
call ch x2d( 'ffff', 4), '-1' |
| 1106 |
call ch x2d( 'ffff', 2), '-1' |
| 1107 |
call ch x2d( 'fffe', 4), '-2' |
| 1108 |
call ch x2d( 'fffe', 2), '-2' |
| 1109 |
|
| 1110 |
call ch x2d( 'ffff', 3), '-1' |
| 1111 |
call ch x2d( '0fff'), '4095' |
| 1112 |
call ch x2d( '0fff', 4), '4095' |
| 1113 |
call ch x2d( '0fff', 3), '-1' |
| 1114 |
call ch x2d( '07ff'), '2047' |
| 1115 |
call ch x2d( '07ff', 4), '2047' |
| 1116 |
call ch x2d( '07ff', 3), '2047' |
| 1117 |
|
| 1118 |
call ch x2d( 'ff7f', 1), '-1' |
| 1119 |
call ch x2d( 'ff7f', 2), '127' |
| 1120 |
call ch x2d( 'ff7f', 3), '-129' |
| 1121 |
call ch x2d( 'ff7f', 4), '-129' |
| 1122 |
call ch x2d( 'ff7f', 5), '65407' |
| 1123 |
|
| 1124 |
call ch x2d( 'ff80', 1), '0' |
| 1125 |
call ch x2d( 'ff80', 2), '-128' |
| 1126 |
call ch x2d( 'ff80', 3), '-128' |
| 1127 |
call ch x2d( 'ff80', 4), '-128' |
| 1128 |
call ch x2d( 'ff80', 5), '65408' |
| 1129 |
|
| 1130 |
call ch x2d( 'ff81', 1), '1' |
| 1131 |
call ch x2d( 'ff81', 2), '-127' |
| 1132 |
call ch x2d( 'ff81', 3), '-127' |
| 1133 |
call ch x2d( 'ff81', 4), '-127' |
| 1134 |
call ch x2d( 'ff81', 5), '65409' |
| 1135 |
|
| 1136 |
call ch x2d( 'ffffffffffff', 12), '-1' |
| 1137 |
|
| 1138 |
/* ======================= JUSTIFY ============================= */ |
| 1139 |
call notify 'justify' |
| 1140 |
if intr = 'regina' Then Do |
| 1141 |
call ch justify('Dette er en test',20,'-'), 'Dette--er---en--test' |
| 1142 |
call ch justify('Dette er en test',10,'-'), 'Dette-er-e' |
| 1143 |
|
| 1144 |
call ch justify(' Dette er en test',25), 'Dette er en test' |
| 1145 |
call ch justify('Dette er en test',24), 'Dette er en test' |
| 1146 |
call ch justify('Dette er en test',23), 'Dette er en test' |
| 1147 |
call ch justify('Dette er en test',22), 'Dette er en test' |
| 1148 |
call ch justify('Dette er en test ',21), 'Dette er en test' |
| 1149 |
call ch justify(' Dette er en test',20), 'Dette er en test' |
| 1150 |
call ch justify('Dette er en test',19), 'Dette er en test' |
| 1151 |
call ch justify('Dette er en test',18), 'Dette er en test' |
| 1152 |
call ch justify('Dette er en test',17), 'Dette er en test' |
| 1153 |
call ch justify('Dette er en test ',16), 'Dette er en test' |
| 1154 |
call ch justify(' Dette er en test',15), 'Dette er en tes' |
| 1155 |
call ch justify('Dette er en test',14), 'Dette er en te' |
| 1156 |
call ch justify('Dette er en test',13), 'Dette er en t' |
| 1157 |
call ch justify('Dette er en test',12), 'Dette er en ' |
| 1158 |
call ch justify('Dette er en test ',11), 'Dette er en' |
| 1159 |
call ch justify('Dette er en test',10), 'Dette er e' |
| 1160 |
|
| 1161 |
call ch justify('Dette er en test',0), '' |
| 1162 |
call ch justify('foo',10), 'foo ' |
| 1163 |
call ch justify('',10), ' ' |
| 1164 |
End |
| 1165 |
|
| 1166 |
say ' ' |
| 1167 |
|
| 1168 |
exit 0 |
| 1169 |
|
| 1170 |
|
| 1171 |
ch: procedure expose sigl |
| 1172 |
parse arg first, second |
| 1173 |
if first \== second then do |
| 1174 |
say |
| 1175 |
say 'first= /'first'/' |
| 1176 |
say 'second=/'second'/' |
| 1177 |
say 'FuncTrip: error in ' sigl':' sourceline(sigl) ; end |
| 1178 |
return |
| 1179 |
|
| 1180 |
|
| 1181 |
notify: |
| 1182 |
parse arg word . |
| 1183 |
written = written + length(word) + 2 |
| 1184 |
if written>75 then do |
| 1185 |
written = length(word) |
| 1186 |
say ' ' |
| 1187 |
end |
| 1188 |
call charout , word || ', ' |
| 1189 |
return |
| 1190 |
|
| 1191 |
|
| 1192 |
error: |
| 1193 |
say 'Error discovered in function insert()' |
| 1194 |
return |
| 1195 |
|