1. <pre style="font-family: verdana, arial, 'Times New Roman', serif;font-size:10px;"> 2. GALiRe 2,1,2-b Inventory 3. -- aAScript 4. 5. 6. 7. CONDITIONALS 8. tertiary: (EXP ? RET1 : RET0) 9. if( EXP ) {} else if( EXP ) {} else {} -- FILE_OK, MDARY_OK 10. 11. 12. 13. 14. LOOP 15. while( EXP ) {} -- FILES, TYPEOF (partial), MDARY_OK 16. 17. if EXP takes the form $ = %: 18. loop through each set of hash returning the key to $ each time 19. 20. elsif EXP takes the form $=IN1 and $<=>IN2 and $MATH: 21. set $ to IN1 and loop, incrementing $ by MATH until IN1 <=> IN2 22. 23. elsif EXP takes the form VAR = @ OR VAR = # (file): 24. loop through each value/line returning the value to VAR each time 25. 26. if the individual value of @ is an array (MDARY): 27. if VAR: ? 28. return the entire array to @VAR as an array and set ?VAR to 2 29. elsif VAR: @ 30. return the entire array to the VAR array 31. elsif VAR: $ 32. return the length of the array to VAR 33. 34. else (individual value of @/# (file) is a scalar): 35. if VAR: $ 36. return the value to VAR 37. elsif VAR: @ 38. return the value to VAR (should be scalar) 39. elsif VAR: ? 40. return the value to $VAR and set ?VAR to 1 41. elsif VAR: % 42. return the value to VAR (should be scalar) 43. 44. else 45. loops until EXP is false 46. 47. 48. 49. 50. METHOD 51. -- FILE_OK -- CANT IMPORT ARRAYS (YET) 52. method IN1( IN2 ) {} 53. 54. IN2 can be a variable or a list of variables 55. execute the method by &IN1 or &IN1(IN2) 56. 57. 58. 59. 60. shortcut assignment operators 61. works on scalars only (+= and =+ works as concatenators otherwise) 62. **= *= += -= /= %= -- ex) A /= B means A = A/B 63. =** =* =+ =- =/ =% -- ex) A =/ B means A = B/A 64. 65. 66. 67. 68. VARS 69. docReferrer 70. docLocation 71. browserInfo 72. queryString 73. requestMethod "POST" "GET" or "UPLOAD" 74. %POST 75. %GET 76. %UPLOAD 77. %"FILE_NAME" - name of the <file> <i>TAG</i> 78. "name" 79. "type" 80. "format" ('binary' or 'ascii') 81. "isbinary"or "isBinary" (0/1) 82. "isascii" or "isAscii" or "isASCII" (0/1) 83. "size" 84. "contents" (contents of file) 85. 86. 87. 88. 89. incremental (++) and decremental (--) 90. -- scalar only, MDARY 91. only works on tokens $, @ (multi-level) and % (acting as string only) 92. takes the form ++IN1/--IN1 OR IN1++/IN1-- 93. if ++IN1 then return value before incrementing, else return after incrementing (same for --) 94. 95. 96. 97. 98. array concatenation @+@ 99. works with multi-level 100. 101. 102. 103. 104. add( IN1 ) to( IN2 )X -DESTRUCTIVE 105. -- FILES, MDARY_OK, TYPEOF, hashes -- one at a time 106. X can be b (begenning), anything else renders as e (end) 107. 108. if IN2: @ 109. if IN1: !@ (stringVar) 110. treat IN1 as list, break up at commas and store as array 111. else 112. retrieve values of array 113. 114. if X: b 115. append each value to beginning of IN2 (in reverse order) 116. else 117. append each value to end of IN2 118. 119. return new length of IN2 120. 121. elsif IN2: % 122. IN1 can hold hash stubs, which is then added to IN2 (order doesn't matter) 123. IN1 can also hold another hash (combines it with IN2 hash) 124. IN1 can hold an array 125. base indices used - 0,1,2 ..., unless an array value has '=' in it 126. if a value has '=', then split it at the = and use key=value format 127. IN1 can also hold a stringVar (0 used as key) 128. return new number of values (keys) in IN2 129. 130. elsif IN2: # (DB) 131. IN1 should hold hash stubs, which are then added to the database at IN2 as a new row 132. or it can contain a hash, which are then added to the database IN2 as new row 133. return success fail (1/0) 134. 135. elsif IN2: # (file) 136. if IN1: !@ (stringVar) 137. treat IN1 as list, break up at commas and store as array 138. else 139. retrieve values of array 140. 141. if X: b 142. append each value to beginning of IN2 (in reverse order) 143. else 144. append each value to end of IN2 145. 146. set IN2 as altered 147. return new length of IN2 148. 149. else 150. IN1 can be a stringVar only 151. 152. if X: b 153. append to beginning of IN2 154. else 155. append to end of IN2 156. 157. return new strlen of IN2 158. 159. 160. 161. 162. IN1 beginsWith( IN2 ) OR IN1 endsWith( IN2 )X -NON_DESTRUCTIVE 163. -- first letter (scalar) or first element (array) or first line (file) -- FILES, TYPEOF, MDARY_OK -- ONLY GOES DEPTH OF 1 WITH MDARY (keeps parens -- 1,2,(2,3),5 -- ) 164. X can be i (case-insensitive), anything else renders as (case-sensitive) 165. 166. NOTE: this can also take the form b( IN1 IN2 )X OR e( IN1 IN2 )X 167. IN2 can be a stringVar only (or REGEX if IN1 is a stringVar) 168. 169. if IN1: @ 170. retrieve values of array, if beginsWith then store first value, otherwise store last value 171. 172. elsif IN1: # (file) 173. retrieve lines of file, if beginsWith then store first line, otherwise store last line 174. 175. else 176. if IN2: !REGEX 177. if beginsWith then store first character, otherwise store last character 178. else 179. store IN2 180. 181. evaluate, return 0/1 182. 183. 184. 185. 186. compare( IN1 )X and( IN2 ) OR contrast( IN1 )X and( IN2 ) -NON_DESTRUCTIVE 187. X can be k (keys) and v (values) -- defaults k 188. 189. IN1 must be same type as IN2 190. 191. combine IN1 and IN2 and store 192. 193. if IN1: @ OR # (file) 194. if compare then return array of intersection, otherwise return array of difference 195. 196. elsif IN1: % 197. compute intersection of hashes (based on k,v,kv) 198. if X: kv 199. return hash of intersection/difference where both k and v pair matched/contrasted 200. else 201. return array of intersection/difference where k (or v) matched/contrasted 202. 203. 204. 205. 206. IN1 contains( IN2 )X OR IN1 lacks( IN2 )X -NON_DESTRUCTIVE 207. -- FILES, TYPEOF, MDARY_OK 208. X can be i (case-insensitive), else renders as (case-sensitive) 209. X can also be k (keys) and v (values) -- defaults k 210. 211. NOTE: this can also take the form c( IN1 IN2 )X OR l( IN1 IN2 )X 212. 213. if IN1: @ 214. if IN2: @ 215. evaluate if IN1 contains all IN2, return 0/1 216. else 217. IN2 can be REGEX or a string (match entire value) 218. evaluate if IN2 is any value in IN1, return 0/1 219. 220. elsif IN1: # (file) 221. IN2 can be REGEX or a string (match entire line) 222. evaluate if IN2 is any value in IN1, return 0/1 223. 224. elsif IN1: % 225. if X: kv 226. evaluate whether either k or v, return 0/1 227. else 228. evaluate whether either k (or v), return 0/1 229. 230. else 231. IN2 can be REGEX only 232. evaluate and return 0/1 233. 234. 235. 236. 237. delete( IN1 ) -DESTRUCTIVE 238. 239. if IN1: @ 240. if IN1 specifies a higher level only remove that level, otherwise delete the @ 241. 242. elsif IN1: % 243. if IN1 specifies a higher level only remove that level, otherwise delete the % 244. 245. elsif IN1: # 246. delete the filehandle only 247. 248. else 249. delete the variable 250. 251. return 0/1 (fail/success) 252. 253. 254. 255. 256. indexOf( IN1 )X in( IN2 )X OR lastIndexOf( IN1 )X in( IN2 )X -NON_DESTRUCTIVE 257. -- FILES, TYPEOF, MDARY_OK, no hashes 258. X can be i (case-insensitive), anything else renders as (case-sensitive) 259. 260. NOTE: return value starts at -1 (no instances returns -1) 261. 262. if IN2: # (file) OR @ 263. IN1 can be stringVar or REGEX 264. return first/last value instance of IN1 in IN2 265. 266. else 267. IN1 can be stringVar only (REGEX treated as stringVar) 268. return first/last instance of IN1 in IN2 269. 270. 271. 272. 273. IN1 isDefined() -NON_DESTRUCTIVE 274. 275. NOTE: this can be done by asking if (IN1) as well 276. 277. if IN1: @ 278. IN1 can be multi-level 279. evaluate, return 0/1 280. 281. elsif IN1: % 282. IN1 can be whole hash or one value 283. evaluate, return 0/1 284. 285. elsif IN1: # 286. evaluate if filehandle exists, return 0/1 287. 288. else 289. evaluate if variable exists, return 0/1 290. 291. 292. 293. 294. join( IN1 )X by( IN2 ) OR join( IN1 )X -NON_DESTRUCTIVE 295. -- FILES, MDARY_OK, TYPEOF -- collapses MDARYs and joins them by commas, hashes 296. X can be k (key) or v (value) -- defaults v 297. 298. NOTE: if IN2 doesn't exist, default to comma "," 299. 300. if IN1: # (file) 301. retrieve file and store as array 302. 303. elsif IN1: % 304. if X: k 305. store keys as array 306. else 307. store values as array 308. 309. else 310. IN1 can be an array only 311. 312. retrieve array and store 313. 314. join values of store by IN2 and return as string 315. 316. 317. 318. 319. lc( IN1 ) where( IN2 ) OR uc( IN1 ) where( IN2 ) -NON_DESTRUCTIVE 320. -- DBA 321. 322. NOTE: also takes for forms lower, lowercase, upper, and uppercase 323. IN1 MUST be a database filehandle 324. IN2 is a where() match and may contain functions 325. 326. retrieve rows from database where IN2 is true 327. uppercase/lowercase them 328. return as an array 329. 330. 331. 332. 333. lc( IN1 )X OR uc( IN1 )X -NON_DESTRUCTIVE 334. -- FILES, MDARY_OK, TYPEOF, DBA 335. X can be k (key) and v (value) -- defaults v 336. 337. NOTE: also takes for forms lower, lowercase, upper, and uppercase 338. IN1 can be array, file, database, hash, or stringVar 339. 340. return evaluated as respective 341. 342. 343. 344. 345. lcfirst( IN1 ) where( IN2 ) OR ucfirst( IN1 ) where( IN2 ) -NON_DESTRUCTIVE 346. -- DBA 347. 348. IN1 MUST be a database filehandle 349. IN2 is a where() match and may contain functions 350. 351. retrieve rows from database where IN2 is true 352. uppercase/lowercase the first character of each cell 353. return as an array 354. 355. 356. 357. 358. lcfirst( IN1 )X OR ucfirst( IN1 )X -NON_DESTRUCTIVE 359. -- FILES, TYPEOF, MDARY_OK, DBA 360. X can be k (key) and v (value) -- defaults v 361. 362. IN1 can be array, file, database, hash, or stringVar 363. 364. return evaluated as respective 365. 366. 367. 368. 369. length( IN1 ) -NON_DESTRUCTIVE 370. -- FILES, TYPEOF, MDARY_OK, DIR, DBA 371. 372. NOTE: also takes for form lengthOf( IN1 ) 373. can handle file, array, stringVar, hash 374. 375. if IN1: stringVar 376. return text length 377. else 378. return number of values 379. 380. 381. 382. 383. random( IN1 ) -NON_DESTRUCTIVE 384. -- scalar, arrays 385. 386. if IN1: @ 387. randomize the order of the values in the array 388. else 389. if IN1 is a range (#-#) then generate a random number from lower to upper bound 390. otherwise generate a random number from 0 to IN1 391. 392. return respective 393. 394. 395. 396. 397. remove( IN1 )X from( IN2 ) -DESTRUCTIVE 398. -- index/range (array/file), key (hash), pattern/range (scalar), FILES, TYPEOF, MDARY_OK, DBA 399. X can be g (global removal) and i (case-insesitive) -- defaulting to (case-sensitive) and (single-instance) 400. 401. if IN2: @ 402. IN1 can be "duplicate", "duplicates", "first", "last", an integer, a startLen (start,length) or range (#-#) 403. returns what is removed 404. 405. elsif IN2: # (file) 406. IN1 can be "duplicate", "duplicates", "first", "last", an integer, a startLen (start,length) or range (#-#) 407. NOTE: this alters the file itself 408. returns what is removed 409. 410. elsif IN2: # (DBA) 411. IN1 is the name of a column, must be used in conjunction with where() statement (right now) 412. NOTE: this alters the table itself 413. returns what is removed 414. 415. elsif IN2: % 416. IN1 can be "duplicate", "duplicates", or an integer 417. return what is removed 418. 419. else 420. IN1 can be "duplicate", "duplicates", REGEX, or a stringVar 421. takes heed of X 422. return what is removed 423. 424. 425. 426. 427. replace( IN1 )X with( IN2 )X in( IN3 )X -NON_DESTRUCTIVE 428. -- FILES, TYPEOF, DBA, MDARY_OK -- ONLY GOES DEPTH OF 1 WITH MDARY (keeps parens -- 1,2,(2,3),5 -- ), hashes - must be global for literal hash 429. X can be k (keys) and v (values) -- defaults v 430. X can be i (case-insensitive) -- defaults (case-sensitive) 431. X can be g (global replace) -- defaults (single-instance) 432. 433. if IN1: startLen OR range OR integer AND IN3: @ OR # (file) 434. splice and return new respective 435. 436. elsif IN1: startLen OR range OR integer AND IN3: stringVar 437. substr and return new string 438. 439. elsif IN3: @ OR # (file) 440. IN1 should be REGEX or stringVar 441. replace in each value and return new respective 442. 443. elsif IN3: # (DBA) 444. IN1 should be a column name, can be used with a where() statement 445. replace in each value and return new respective 446. 447. elsif IN3: % 448. IN1 should be REGEX or stringVar 449. replace in each key/value (based on X) and return new hash 450. 451. else 452. IN1 should be REGEX (stringVar treated as REGEX) 453. replaces and returns string 454. 455. 456. 457. 458. reverse( IN1 ) -DESTRUCTIVE 459. -- FILES, TYPEOF, DBA, MDARY_OK - should be depth of 1 only, hashes 460. 461. if IN1: @ 462. reverse array order and return new array 463. 464. elsif IN1: % 465. reverse keys and values and returns new hash 466. 467. elsif IN1: # (file) 468. reverse lines of file and returns as array 469. NOTE: this alters the file itself 470. 471. else 472. stringVar only 473. reverses the text and returns the new string 474. 475. 476. 477. 478. round( IN1 ) by( IN2 ) OR round( IN1 ) -NON_DESTRUCTIVE 479. -- scalar, MDARY, TYPEOF 480. 481. NOTE: this can also take the form round( IN1 ) to( IN2 ) 482. NOTE: if IN2 doesn't exist, default to 1 483. 484. if IN1: @ 485. round each value of array to IN2 and return as array 486. else 487. round IN1 to IN2 and return as string 488. 489. 490. 491. 492. sort( IN1 ) by( IN2 ) OR sort( IN1 ) -DESTRUCTIVE, unless for a DB 493. -- FILES, TYPEOF, DBA, MDARY_OK - rigged up -- uses first elements of MDARYs --- parens removed temporarily 494. 495. IN2 can be "A-Z" ("letters"), "Z-A", "0-9" ("numbers"), or "9-0" 496. NOTE: if IN2 doesn't exist, default to "letters" ("A-Z") 497. 498. if IN1: # (file) 499. sort the array by IN2 and return as array 500. else 501. IN1 must be an array 502. sort IN1 by IN2 and return as array 503. 504. 505. 506. 507. split( IN1 ) by( IN2 ) -NON_DESTRUCTIVE 508. -- scalar, arrays into hashes 509. 510. IN2 can be REGEX or stringVar 511. 512. if IN1: @ 513. split each value of the array by IN2 and return as hash (left of split becomes key) 514. else 515. IN1 must be stringVar 516. split IN1 by IN2 and return as array 517. 518. 519. 520. 521. select( IN1 )X from( IN2 ) where( IN3 ) -NON_DESTRUCTIVE 522. -- DBA 523. X can be i (case-insensitive) -- defaults (case-sensitive) 524. 525. IN2 MUST be a database filehandle 526. IN3 is a where() match and may contain functions 527. 528. retrieve IN1 rows from database where IN3 is true 529. return as array 530. 531. 532. 533. 534. select( IN1 )X from( IN2 )X -NON_DESTRUCTIVE 535. -- FILES, TYPEOF, MDARY_OK, hashes, DBA, DIR 536. X can be i (case-insensitive) -- defaults (case-sensitive) 537. X can be k (keys) and v (values) -- defaults v 538. 539. if IN1: startLen OR range OR integer AND !REGEX 540. if IN2: # (DB) 541. retrieve IN1 rows from database and return as array 542. elsif IN2: # (file) 543. return line(s) from file according to IN1 as array 544. elsif IN2: @ 545. return value(s) from array according to IN1 as array 546. else 547. return substr WRT IN1 as string 548. 549. else 550. IN2 cannot be scalar 551. IN1 can be "keys" or "values" or stringVar 552. 553. if IN2: # (DB) 554. retrieve IN1 rows from database and return as array 555. elsif IN2: # (file) OR @ 556. if IN1: REGEX 557. returns where line/array value matches IN1 as array 558. else 559. returns where line/array value equal IN1 as array 560. elsif IN2: # (DIR) 561. if IN1: REGEX 562. returns where filename matches IN1 as array 563. else 564. returns where filename value equal IN1 as array 565. elsif IN2: % 566. if IN1: "keys" 567. return keys of hash as array 568. elsif IN1: "values" 569. return values of hash as array 570. else 571. return match in hash based on X as hash 572. 573. 574. 575. 576. valueOf( IN1 ) -NON_DESTRUCTIVE 577. - FILES, MDARY_OK, TYPEOF, DBA, DIR 578. 579. NOTE: this can also take the form value( IN1 ) 580. 581. if IN1: # (file) 582. returns entire file as array 583. elsif IN1: # (DB) 584. returns all columns and rows from database as array 585. else 586. returns value of IN1 587. 588. 589. 590. 591. submit( IN1 ) -DESTRUCTIVE 592. - FILES 593. 594. save file and return 0/1 on fail/success 595. 596. 597. 598. 599. close( IN1 ) -DESTRUCTIVE 600. - FILES, DBA, DIR 601. 602. if IN1: # (file) 603. saves file, removes the IN1 filehandle, and returns 1 604. elsif IN1: # (DB) 605. optimizes the table, removes the IN1 filehandle, and returns 1 606. elsif IN1: # (DIR) 607. removes the IN1 filehandle, and returns 1 608. 609. 610. 611. 612. reset( IN1 ) -DESTRUCTIVE 613. - FILES 614. 615. clears out the IN1 filehandle and resets it to the value of the file, returns 0/1 on fail/success 616. 617. 618. 619. 620. open( IN1 ) as( IN2 ) -DESTRUCTIVE 621. - FILES, DBA, DIR 622. 623. opens the file, directory, or database, creates the IN2 filehandle, and returns 0/1 on fail/success 624. if file doesn't exist ... create it and continue 625. 626. 627. 628. 629. multiply( IN1 ) by( IN2 ) -NON_DESTRUCTIVE 630. -- FILE_OK, TYPEOF, MDARY_OK, no hashes 631. 632. NOTE: IN2 must be between 2 and 500 633. 634. repeat the string/array IN2 times and return as respective 635. 636. 637. 638. 639. charAt( IN1 ) in( IN2 ) -NON_DESTRUCTIVE 640. -- scalar only 641. 642. IN1 must be an integer starting at 0 643. returns the character in IN2 at position IN1 644. 645. 646. 647. 648. solve( IN1 ) -NON_DESTRUCTIVE 649. -- scalar only 650. 651. solves IN1 mathematically and returns the value 652. 653. 654. 655. 656. return( IN1 ) -NON_DESTRUCTIVE 657. -- FILE_OK 658. 659. return IN1 (for methods) 660. 661. 662. 663. 664. quit() OR die() 665. -- FILE_OK 666. 667. NOTE: this can also take the form quit; and die; 668. 669. exits scripting, no returns 670. 671. 672. 673. 674. next; OR continue; 675. -- FILE_OK, MDARY_OK 676. 677. skips the rest of the loop and starts on the next loop, returns nothing 678. 679. 680. 681. 682. info( IN1 ) -NON_DESTRUCTIVE 683. 684. IN1 should be the name of a file 685. returns a hash containing information about the file 686. mdate = date last modified 687. mtime = time (since epoch) last modified 688. size = file size (in bytes) 689. ftype = file type (binary/ascii/empty) 690. stype = type of system data (directory/file) 691. isdir = is a directory 692. isfile = is a file 693. isascii = is ascii (text) 694. isbinary = is binary 695. 696. 697. 698. 699. move( IN1 ) to( IN2 ) -NON_DESTRUCTIVE 700. 701. IN1 should be the name of a file 702. IN2 should be the destination (folder) 703. returns success/fail (1/0) 704. 705. 706. 707. 708. rename( IN1 ) to( IN2 ) -NON_DESTRUCTIVE 709. 710. IN1 should be the name of a file 711. IN2 should be the new name of the file 712. returns success/fail (1/0) 713. 714. 715. 716. 717. break; OR last; 718. -- FILE_OK, MDARY_OK 719. 720. quits the current loop and returns nothing 721. 722. 723. 724. 725. print( IN1 ) 726. -- FILE_OK, MDARY_OK 727. 728. NOTE: this can also take the form print ""; and print VAR; 729. 730. prints IN1 to the output stream 731. 732. 733. 734. 735. 736. printc( IN1 ) 737. -- FILE_OK, MDARY_OK 738. 739. NOTE: this can also take the form printc ""; and printc VAR; 740. 741. print IN1 as code to the output stream (GALiRe tags) 742. 743. 744. 745. 746. 747. </pre>
Back to /SampleHost/