* RFR009.QM * Written By Tom Hogshead * [ See RFRMxx.QM For Use ] * 8/25/91 * Key Subfile Description Bytes * ===== ============== ============================================= ====== * @(7) --Sort Column Block and Adjacent Text 44 * in DESCENDING Order (Tim Farley) * @(9) --Sort Column Block and Adjacent Text 13 * CASE INSENSITIVE * @(0) --Sort Column Block and Adjacent Text 43 * in REVERSE Order * * @(2) --Sort Column Block in DESCENDING Order, 43 * Adjacent Text Unchanged * @(8) --Sort Column Block RANDOMLY, 33 * Adjacent Text Unchanged * * @(3) --Convert Vertical to Horizontal Column Block 38 * @(4) --Convert Horizontal to Vertical Column Block 47 * @(5) --Convert Vertical to Horizontal Column Block, 34 * Horizontal Entries NOT Separated by Space * @(6) --Convert Horizontal to Vertical Column Block, 44 * Horizontal Entries NOT Separated by Space * {e:\up\RFRM*}--Return To RFRMxx.QM * *-- eoi *  * ---------------------------------------------------------------------- * @(2) Sort Column Block In Descending Order, * Adjacent Text Unchanged * ---------------------------------------------------------------------- * This macro sorts only the entries in a column block in reverse order. * It leaves all text surrounding the column block in the same position * before and after. See @7 for limitations. @2 macrobegin OneWindow GotoBlockBeg JFalse ENDSORT: EditFile "NUL" Return Quit GoToBlockBeg EditFile Return MoveBlock Sort DELALL: DelLine JTrue DELALL: UnKill UNDELALL: CursorDown UnKill JTrue UNDELALL: DelLine CursorUp EndLine CursorLeft Markcolumn BegFile Cut Quit Paste UnMarkBlock ENDSORT: * * 59 bytes Tue 04-20-1991 11:13:21 (TF @0, TH added size) * 43 bytes Thu 08-15-1991 12:42:05 (TH @2) * Marking col 3: * v * 0 0 877 0 * 1 1 abc 1 * 2 2 275 2 * 3 3 970 3 * 4 4 345 4 * 5 5 615 5 * 6 6 075 6 * 7 7 710 7 * 8 8 186 8 * 9 9 421 9 * a a DEF a * b b 520 b * becomes * 0 0 abc 0 * 1 1 DEF 1 * 2 2 970 2 * 3 3 877 3 * 4 4 710 4 * 5 5 615 5 * 6 6 520 6 * 7 7 421 7 * 8 8 345 8 * 9 9 275 9 * a a 186 a * b b 075 b *  * ---------------------------------------------------------------------- * @(3) Convert Vertical to Horizontal Column Block * With Horizontal Entries Separated by a Single Space * ---------------------------------------------------------------------- * This macro converts a vertical column block to a horizontal single * line column block with horizontal entries separated by a single * space. Block may be open or closed. * 1 becomes 1 2 3 * 2 * 3 @3 MacroBegin OneWindow * EditFile "NUL" Return * Edit NUL file Quit * Quit NUL file if loaded GotoBlockBeg * Return to where we started jfalse END: * If not closed, nothing was marked, end HorizontalWindow * Make window 2 EditFile Return * Load NUL MoveBlock * Move block to NULs8 LOOP: * EndLine * Move to char after last in line *-- JoinLine with single space at join point, per JG CursorRight * Make 2 spaces CursorRight * JoinLine * Join line CursorLeft * DelRtWord * Make one space *-- * jtrue LOOP: * Loop until done EndLine * Position for mark MarkCharacter * Mark line as character block Cut * Cut new block to scrap Quit * Quit NUL PrevWindow * Return to file we started in OneWindow * Close all windows Paste * Paste new block back at start of old END: * * UnmarkBlock * Unmark new block * * 38 bytes Thu 08-15-1991 15:35:40 (TH @3) *  * ---------------------------------------------------------------------- * @(4) Convert Horizontal to Vertical Column Block, * Horizontal Entries Separated by Space * ---------------------------------------------------------------------- * This macro converts a horizontal single line column block, with * horizontal entries separated by a single space, to a vertical column * block. Block may be open or closed. * 1 2 3 becomes 1 * 2 * 3 @4 MacroBegin OneWindow * AltWordSet * For all block entries EditFile "NUL" Return * Edit NUL file Quit * Quit NUL file if loaded GotoBlockBeg * Return to where we started jfalse END: * If not closed, nothing was marked, end HorizontalWindow * Make window 2 EditFile Return * Load NUL MoveBlock * Move block to NULs8 UnmarkBlock * Unmark block for screen appearance WordRight * Move to second entry in block LOOP: * EndLine * Test if at end of line Jfalse NEXT: * If so, we're done splitting PrevPosition *ELSE return to where we were CursorLeft * Move left to blank space DelCh * Delete blank space SplitLine * Split line WordRight * Move to column entry we just split WordRight * Move to next column entry to split jump LOOP: * Loop again NEXT: * Come here when finished splitting CursorLeft * Position cursor on last char in block MarkColumn * Start column block mark on last char BegFile * Get all column as block Cut * Cut new block to scrap Quit * Quit NUL PrevWindow * Return to file we started in OneWindow * Close all windows Paste * Paste new block back at start of old END: * DefaultWordSet * Reset * UnmarkBlock * Unmark new block * * 47 bytes Thu 08-15-1991 15:36:00 (TH @4) *  * ---------------------------------------------------------------------- * @(5) Convert Vertical to Horizontal Column Block * With Horizontal Entries NOT Separated by a Single Space * ---------------------------------------------------------------------- * This macro converts a vertical column block to a horizontal single * line column block with horizontal entries NOT separated by a single * space. Block may be open or closed. * 1 becomes 123 * 2 * 3 @5 MacroBegin OneWindow * EditFile "NUL" Return * Edit NUL file Quit * Quit NUL file if loaded GotoBlockBeg * Return to where we started jfalse END: * If not closed, nothing was marked, end HorizontalWindow * Make window 2 EditFile Return * Load NUL MoveBlock * Move block to NUL LOOP: EndLine * Move to char after last in line JoinLine * Join line jtrue LOOP: * Loop until done EndLine * Position for mark MarkCharacter * Mark line as character block Cut * Cut new block to scrap Quit * Quit NUL PrevWindow * Return to file we started in OneWindow * Close all windows Paste * Paste new block back at start of old END: * * UnmarkBlock * Unmark new block * * 34 bytes Thu 08-15-1991 15:39:00 (TH @5) *  * ---------------------------------------------------------------------- * @(6) Convert Horizontal to Vertical Column Block, * Horizontal Entries NOT Separated by Space * ---------------------------------------------------------------------- * This macro converts a horizontal single line column block, with * horizontal entries NOT separated by a single space, to a vertical * column block. Block may be open or closed. * 123 becomes 1 * 2 * 3 @6 MacroBegin OneWindow * EditFile "NUL" Return * Edit NUL file Quit * Quit NUL file if loaded GotoBlockBeg * Return to where we started jfalse END: * If not closed, nothing was marked, end HorizontalWindow * Make window 2 EditFile Return * Load NUL MoveBlock * Move block to NUL UnmarkBlock * Unmark block for screen appearance LOOP: * CursorRight * Move to next char SplitLine * Split line Begline * Back to begline CursorDown * Move down to next line EndLine * Test if line is blank Jfalse NEXT: * If so, we're done splitting PrevPosition *ELSE return to where we were jump LOOP: * Loop again NEXT: * Come here when finished splitting CursorUp * Move up to last char line BegLine * Position cursor on last char in block MarkColumn * Start column block mark on last char BegFile * Get all column as block Cut * Cut new block to scrap Quit * Quit NUL PrevWindow * Return to file we started in OneWindow * Close all windows Paste * Paste new block back at start of old END: * * UnmarkBlock * Unmark new block * * 44 bytes Thu 08-15-1991 15:40:21 (TH @6) *  * ---------------------------------------------------------------- * @(7) Sort Column Block and Adjacent Text In Descending Order * Written by Tim Farley with Modifications by Tom Hogshead * --------------------------------------------------------------- * This macro is a modification to a macro written by Tim Farley of * SemWare in Macros Conference 3, Message #60, 4/30/90, to sort a * column block and all adjacent text in reverse or descending order. I * was working on some sorting macros and found quite by accident that * Tim's macro was inadvertently deleting a line. I found I could * correct this condition by removing one extra "DelLine CursorUp". At * the same time I went ahead and changed Tim's non-existent temporary * file to NUL, which is faster especially in large directories, quit * NUL first, in case it was already loaded, to insure correct ring * positions, and moved DelLine to delete the extra blank lines, to * delete it while in the NUL file, not the current file. * @7 has the same effect on lines containing the column block as does * 'sort', ie text adjacent to the column block is sorted also. Tim's * idea using the Kill Buffer to reverse sort lines is very creative. As * he suggested, I set QConfig Kill Buffer 300 lines. Thanks again to * Tim for the macro. It has been useful lately, and has been the basis * for developing the other sorting macros here. * As an example using @7, col 1 marked as an open or closed column * block, and all adjacent text is sorted in reverse order as shown in * col 2: * Before After * ======== ======= * v * 877 abc * abc DEF * 275 970 * 970 877 * 345 710 * 615 615 * 075 520 * 710 421 * 186 345 * 421 275 * DEF 186 * 520 075 * Similarly marking col 3 here: * v * 0 0 877 0 * 1 1 abc 1 * 2 2 275 2 * 3 3 970 3 * 4 4 345 4 * 5 5 615 5 * 6 6 075 6 * 7 7 710 7 * 8 8 186 8 * 9 9 421 9 * a a DEF a * b b 520 b * becomes * 1 1 abc 1 * a a DEF a * 3 3 970 3 * 0 0 877 0 * 7 7 710 7 * 5 5 615 5 * b b 520 b * 9 9 421 9 * 4 4 345 4 * 2 2 275 2 * 8 8 186 8 * 6 6 075 6 * NOTE: Since this macro uses the Kill Buffer to reverse the * lines, it cannot sort more lines than will fit in your * Kill Buffer. See (G)eneral options in the configuration * program for setting this value--it defaults to only 30 * lines so BE CAREFUL! I set the maximum number of * Kill Buffer entries to 300. * * Do NOTE the notation in the comment: you are limited to the size * of your Kill Buffer with this macro. @7 macrobegin GotoBlockBeg OneWindow Sort EditFile "NUL" Return *| Quit *| GotoBlockEnd JFalse ENDSORT: *|b MarkLine EditFile Return *| MoveBlock * DelLine *|b DELALL: DelLine JTrue DELALL: * UnKill *|b UNDELALL: CursorDown UnKill JTrue UNDELALL: DelLine CursorUp MarkLine BegFile DelLine *| PrevFile MoveBlock NextFile Quit GotoBlockBeg UnMarkBlock ENDSORT: * * 59 bytes Tue 04-20-1991 11:13:21 (TF @0, TH added size line) * 46 bytes Thu 08-15-1991 12:42:26 (TH @7, mod to Tim Farley @0 |) * 44 bytes Sun 08-25-1991 17:38:41 (TH @7, |b) *  * ---------------------------------------------------------------------- * @(8) Randomly Sort a Column Block of Up to 999 Entries * ---------------------------------------------------------------------- * To run, mark a column block to be randomly sorted, either open or * closed. This macro will randomly sort up to 999 entries in a column * block and leave the text adjacent to the column block in it's * original position. The results are the same as randomly sorting a * one dimmensional matrix composed of entries in the column block. * A file named RAND containing numbers 1 to 999 randomly sorted is used * as the sorting key. A temporary block containing both the block to * be sorted adjacent to the random numbers is sorted using the random * numbers as the sort key. Thus, sorting the random numbers into an * ascending sorted set sorts the original marked block into a random * set. The file RAND must be present in the current directory and is * included in AMACxx.ZIp. If RAND does not exist, it can easily made * by first removing the asterisks and spaces in col 1 in the table * below, formatting the 999 random sorted numbers to a right margin * width of 4, and then saving the single column formatted numbers to a * file named RAND. * As an example, col 1 when marked as an open or closed column block, * becomes randomly sorted as shown in col 2: * Before After * ======== ======= * 075 877 * 186 abc * 275 275 * 345 970 * 421 345 * 520 615 * 615 075 * 710 710 * 877 186 * 970 421 * abc DEF * DEF 520 @8 MacroBegin EditFile "rand" Return * Load random number file Quit * Quit for ring position GotoBlockBeg * Return to where we started EditFile Return * Load random number file as next file EndLine CursorRight * Position one space rt of fist rand # MoveBlock * Move unsorted block here GoToBlockEnd * Position to re-mark UnmarkBlock * Unmark CursorLeft * Pos cur on last char in unsorted block MarkColumn * Start column block BegFile * Get random #'s in block Sort * Sort CursorRight CursorRight * Remove random #'s from block CursorRight CursorRight * Block is now what is was. but random PrevFile * Return to starting file MoveBlock * Move random sorted back where it was * UnmarkBlock * Unmark new block * * 33 bytes Sun 08-25-1991 13:52:16 (TH @8) * Numbers 1 to 999 Randomly Sorted * --------------------------------- * This table contains numbers 1 to 999 randomly sorted. Statisticians * will argue this is not 'truly random' and it is not but it is * sufficiently random for our column block sorting purposes. There are * no repeating numbers. This Table is included as a single column * file RAND in AMACxx.ZIP. * 487 671 332 471 727 897 478 551 054 371 080 856 987 821 634 338 937 * 614 562 020 171 932 705 601 274 791 824 477 663 552 343 223 288 654 * 273 205 945 480 317 533 903 685 740 725 187 017 722 560 530 842 087 * 777 192 142 452 319 523 208 181 732 704 126 218 014 568 672 780 809 * 517 033 365 940 883 430 024 215 750 426 380 347 774 606 314 433 009 * 377 869 359 836 595 876 963 456 715 929 060 015 658 861 481 773 095 * 799 674 217 212 182 984 018 804 174 151 993 771 520 335 778 386 388 * 858 287 695 465 684 593 522 008 488 123 930 240 119 692 531 267 730 * 437 483 406 472 770 188 742 516 027 905 264 250 807 374 494 915 969 * 967 454 259 137 550 859 589 245 447 213 741 953 958 270 926 957 230 * 952 475 801 868 253 285 921 466 702 130 204 302 819 041 237 282 016 * 207 911 640 418 754 244 308 559 175 114 738 525 792 584 173 553 510 * 950 147 720 779 894 539 977 994 597 411 030 068 665 912 655 689 604 * 822 872 052 443 312 354 440 962 736 546 249 996 986 337 716 034 512 * 134 760 942 381 504 895 128 301 339 619 113 368 825 916 358 254 395 * 690 403 133 966 563 749 390 954 216 242 132 913 664 333 980 726 050 * 112 315 307 449 693 622 806 349 476 887 227 631 382 823 366 444 698 * 796 263 839 350 091 362 446 906 324 460 526 295 814 651 904 461 143 * 981 659 458 177 850 002 805 121 591 127 412 345 222 029 931 110 457 * 224 759 498 751 877 473 746 888 391 555 202 252 363 794 923 387 389 * 509 629 649 164 956 357 160 865 524 628 998 209 180 396 818 681 084 * 815 062 728 739 378 648 505 450 265 623 933 656 206 427 320 574 423 * 492 612 990 666 064 239 178 679 639 183 144 025 844 766 299 556 860 * 616 328 569 641 225 790 266 318 469 573 135 019 441 094 784 892 290 * 321 118 072 511 697 831 808 482 834 548 734 896 420 083 012 590 294 * 322 499 158 811 057 161 786 587 783 146 709 820 832 576 975 733 234 * 255 131 501 810 917 537 138 214 246 982 257 286 088 907 099 355 645 * 624 884 919 846 141 085 793 829 098 409 870 513 694 346 802 109 296 * 617 199 944 714 721 081 871 642 003 683 341 262 280 719 021 983 788 * 878 627 150 102 168 899 464 490 758 922 495 845 946 797 528 397 048 * 067 547 544 340 231 163 170 585 660 854 691 961 139 069 269 789 900 * 518 474 542 575 445 186 889 647 763 169 947 997 298 036 424 063 047 * 251 326 610 643 848 491 276 948 497 538 626 361 309 379 195 633 172 * 713 696 880 106 743 535 260 093 570 400 277 529 289 035 621 484 976 * 191 717 241 800 369 652 124 837 179 413 653 891 762 583 637 198 686 * 767 097 795 292 011 090 376 197 416 885 890 586 306 554 031 037 782 * 863 038 108 840 404 600 724 785 851 422 079 572 442 991 699 949 185 * 051 879 372 284 744 828 712 925 271 383 941 053 951 753 056 431 414 * 233 023 066 293 935 167 272 703 417 010 602 247 909 070 210 965 875 * 155 873 125 992 765 467 657 162 673 960 248 042 370 032 669 615 351 * 618 902 221 843 635 103 540 502 830 157 152 236 256 219 752 040 866 * 228 410 082 421 775 995 356 489 508 959 943 235 914 434 089 327 541 * 360 493 781 156 661 076 682 934 189 149 352 813 166 936 567 978 988 * 565 577 107 367 708 670 353 867 620 927 968 462 769 407 013 459 761 * 201 920 373 688 862 402 608 316 527 772 707 855 632 939 148 581 325 * 086 438 841 566 435 159 348 874 297 448 549 045 220 268 261 344 519 * 468 078 129 756 401 005 607 331 073 419 184 096 582 545 405 729 100 * 432 817 757 677 985 668 609 190 532 194 826 594 058 833 755 710 071 * 979 881 864 662 028 893 193 092 342 507 625 238 074 882 075 455 588 * 394 592 313 375 646 852 229 105 748 723 278 803 334 485 007 111 415 * 731 598 506 928 989 711 910 291 596 901 580 898 768 700 678 203 500 * 451 605 453 153 077 044 835 515 104 004 279 776 065 305 470 999 561 * 857 101 258 399 364 243 816 039 955 329 061 116 310 908 747 043 281 * 336 384 603 972 964 463 571 644 630 226 543 049 650 970 745 787 847 * 176 115 924 812 001 534 687 122 503 667 232 735 304 579 154 398 557 * 886 022 638 680 436 496 145 675 385 006 578 564 392 486 439 059 283 * 211 737 849 429 974 971 136 514 200 718 558 536 599 165 300 701 140 * 117 120 973 838 393 026 613 764 479 196 827 275 408 046 425 706 611 * 311 676 055 918 303 323 938 428 330 636 521 853 798 *  *------------------------------------------- * @(9) Sort Column Block, Case Insensitive *------------------------------------------- * This macro sorts a column block in ascending order and is case * INSENSITIVE. I do not know the author, but recall I found it on the * SemWare BBS. We copy the sort key block, upper case it, and sort on * the copy. Then we delete the copy, leaving the original lines as * they were, except sorted: @9 macrobegin gotoblockbeg copyblock jfalse NOBLOCK: onewindow upper sort deleteblock NOBLOCK: * * 13 bytes Mon 08-20-1990 07:17:25 (TH @9) *  * ------------------------------------------ * @(0) Sort Column Block in Reverse Order * ------------------------------------------ * This macro is based on the technique used by Tim Farley in @7. @0 * sorts a column block and text outside the column block in REVERSE * order, not DESCENDING like @7, i.e. the last column entry becomes the * first, and so on. @0 has the same effect on text outside the column * block as 'sort'. Results are the same as if the column block were a * one dimmensional matrix and it was inverted. * NOTE: Since this macro uses the Kill Buffer to reverse the * lines, it cannot sort more lines than will fit in your * Kill Buffer. See (G)eneral options in the configuration * program for setting this value--it defaults to only 30 * entries in column block. I set the maximum number of * Kill Buffer entries to 300. * Do NOTE the notation in the comment: you are limited to the size * of your Kill Buffer with this macro. * Before After * ======== ======= * abc 075 * DEF 186 * 970 275 * 877 345 * 710 421 * 615 520 * 520 615 * 421 710 * 345 877 * 275 970 * 186 DEF * 075 abc @0 macrobegin OneWindow GotoBlockBeg EditFile "NUL" Return Quit GotoBlockEnd JFalse ENDSORT: MarkLine EditFile Return MoveBlock DELALL: DelLine JTrue DELALL: UNDELALL: CursorDown UnKill JTrue UNDELALL: DelLine CursorUp MarkLine BegFile CursorDown PrevFile MoveBlock NextFile Quit GotoBlockBeg UnMarkBlock ENDSORT: * * 43 bytes Sun 08-25-1991 17:23:40 (TH @0)