Code structure diagramming?

Started by John Montenigro, June 04, 2014, 12:16:23 AM

Previous topic - Next topic

John Montenigro

I recall someone had created a tool for PBDOS that produced a "condensed" outline of all SUBs and FUNCTIONs in a source file, showing only the prototype line, calls, and the "END SUB/FUNCTION" statement. It helped you to see the "flow" of the program.

Is there any such capability in FF, or in an existing external tool?

Seems I've patched together a lot of modules and .INC files, and have managed to create some circular calls. I'm going a bit cross-eyed trying to trace the flow of code, and figured I'd ask before taking a possibly unnecessary side-trip...

Thanks for any help you can provide,
-John

Eddy Van Esch

John,
I don't know of such a tool but have you considered using the TRACE command ?
Eddy

Rolf Brandt

In FF3 you find under the menu <View> the following items:

<View> <Fold all Subs/Functions>
   and
<Expand all Subs/Functions>

Is it that what you are looking for?
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

John Montenigro

@Eddy,
I don't know that command. I'll look it up in the Help File.

@Rolf,
Similar... This FF3 Fold command collapses the entire Sub/Function. I would not like to normal PB commands, but I would still like to see any calls to, or invocations of, other Subs/Functions.
Also, this command still shows comments; I would not need to see comments.

Thanks for the replies!
-John


John Montenigro

Ah HA!

I did some software archaeology, and in my PBDOS file collection, found that the program was BASFLOW.BAS:

'   Quick Basic Program Analyzer
'
'   Author: Clyde F. Coulter, Jr.
'     Date: 9-27-88
'
'       (C) Copr Clyde F. Coulter, jr.
'       All Rights Reserved.

Below is a sample of its output.

Thanks for jogging my memory! I'm going to see if there's any way I can adapt or re-create this useful tool...
-John


Quotebasflow.bas                 Program Statistics            07-22-1997 08:35:58

Program Tree

        INPUTDATA:

        RESDATA:

        RESV40:

        MAIN:
          └─GOSUB SETSWITCH
          └─GOSUB GETPARM
          └─GOSUB SETSWITCH
          └─GOSUB PASSONE
          │   └─GOSUB GETWORD
          │   └─GOSUB GETWORD
          │   └─GOSUB CHKWORD
          └─GOSUB PRTTOF
          └─GOSUB PASSTWO
          │   └─GOSUB PRTTOF
          └─GOSUB PRTTOF
          └─GOSUB PRTTREE
          │   └─GOSUB PRTTOF
          │   └─GOSUB PRTTOF
          │   └─GOSUB TREESUB
          │   │   └─GOSUB PRTTOF
          │   │   └─GOSUB TREESUB
          │   │       └─GOSUB PRTTOF
          │   │       └─GOSUB TREESUB
          │   │           └─GOSUB PRTTOF
          │   │           └─GOSUB TREESUB
          │   └─GOSUB PRTTOF
          └─GOSUB PRTTOF
          └─GOSUB XREFLABELS
          │   └─GOSUB SORTLABELS
          │   └─GOSUB PRTTOF
          │   └─GOSUB PRTTOF
          │   └─GOSUB PRTTOF
          │   └─GOSUB PRTTOF
          │   └─GOSUB PRTTOF
          │   └─GOSUB PRTTOF
          │   └─GOSUB PRTTOF
          │   └─GOSUB PRTTOF
          └─GOSUB PRTTOF
          └─GOSUB PRTRSVCNT
          │   └─GOSUB PRTTOF
          │   └─GOSUB PRTTOF
          └─GOSUB PRTTOF
          └─GOSUB PRTSTRDATA
          │   └─GOSUB PRTTOF
          │   └─GOSUB SORTSTRDATA
          │   └─GOSUB PRTTOF
          │   └─GOSUB PRTTOF
          └─GOSUB PRTTOF
          └─GOSUB PRTTOF

        GETPARM:

        SETSWITCH:

        PASSONE:
basflow.bas                 Program Statistics            07-22-1997 08:35:58

          └─GOSUB GETWORD
          └─GOSUB GETWORD
          └─GOSUB CHKWORD

        PASSTWO:
          └─GOSUB PRTTOF

        GETWORD:

        CHKWORD:

        SORTLABELS:

        SORTSTRDATA:

        PRTSTRDATA:
          └─GOSUB PRTTOF
          └─GOSUB SORTSTRDATA
          └─GOSUB PRTTOF
          └─GOSUB PRTTOF

        PRTTOF:

        XREFLABELS:
          └─GOSUB SORTLABELS
          └─GOSUB PRTTOF
          └─GOSUB PRTTOF
          └─GOSUB PRTTOF
          └─GOSUB PRTTOF
          └─GOSUB PRTTOF
          └─GOSUB PRTTOF
          └─GOSUB PRTTOF
          └─GOSUB PRTTOF

        PRTTREE:
          └─GOSUB PRTTOF
          └─GOSUB PRTTOF
          └─GOSUB TREESUB
          │   └─GOSUB PRTTOF
          │   └─GOSUB TREESUB
          │       └─GOSUB PRTTOF
          │       └─GOSUB TREESUB
          │           └─GOSUB PRTTOF
          │           └─GOSUB TREESUB
          │               └─GOSUB PRTTOF
          │               └─GOSUB TREESUB
          └─GOSUB PRTTOF

        TREESUB:
          └─GOSUB PRTTOF
          └─GOSUB TREESUB
              └─GOSUB PRTTOF
              └─GOSUB TREESUB
                  └─GOSUB PRTTOF
                  └─GOSUB TREESUB
                      └─GOSUB PRTTOF
                      └─GOSUB TREESUB
                          └─GOSUB PRTTOF
                          └─GOSUB TREESUB

basflow.bas                 Program Statistics            07-22-1997 08:35:59

        PRTRSVCNT:
          └─GOSUB PRTTOF
          └─GOSUB PRTTOF

basflow.bas                 Program Statistics            07-22-1997 08:35:59

Program Labels

        CHKWORD:............. 461 382

        GETPARM:............. 312 223 225 238
        GETWORD:............. 403 373 380

        INPUTDATA:........... 86 171

        MAIN:................ 157

        PASSONE:............. 357 267
        PASSTWO:............. 392 282
        PRTRSVCNT:........... 834 290
        PRTSTRDATA:.......... 595 292
        PRTTOF:.............. 645 276 285 287 289 291 298 304 396 596 627 634
                              668 681 688 694 711 723 728 731 740 760 774 807
                              851 864
        PRTTREE:............. 739 286

        RESDATA:............. 110 99
        RESV40:.............. 143 245

        SETSWITCH:........... 326 229 239
        SORTLABELS:.......... 558 667
        SORTSTRDATA:......... 576 602

        TREESUB:............. 778 762 810

        XREFLABELS:.......... 665 288

18   Labels


Program Variables

        #1................... 262 266 271 278 281
        #2................... 273 299 300 301 302 394 597 598 599 600 614 615
                              617 619 620 635 636 637 653 655 656 669 670 679
                              691 692 695 696 697 709 721 726 729 741 742 752
                              757 766 772 805 835 836 848 849 858 862 873

        %FALSE............... 31 31 81 158 187 190 191 197 200 201 207 358 359
                              359 359 362 370 374 378 383 393 410 419 463 472
                              508 514 549 561 579
        %TRUE................ 31 175 181 198 203 206 224 268 303 329 343 372
                              375 376 406 418 431 447 468 476 506 511 547

        A$................... 36 38 40 41 43 44 44 46 47 47 47 49 51 51 51 52
                              54 57 60 61 67 71 101 103 104 105 106 178 179 179
                              180 184 185 189 195 195 196 199 208 211 213 218
                              246 247 248 249 434 435 437 707 708 714
        A.................... 30
        ALLDELIM$............ 84 413 417

        C$................... 58 61 62 66 66 67 412 413
        C.................... 647 651
        CMD$................. 168 169 218 218 221 221 237 313 314 315 316 317
                              318 318 319 319 319
        CNT.................. 606 611 611 615
basflow.bas                 Program Statistics            07-22-1997 08:35:59

        COLON$............... 751 757 758
        CURALPHA$............ 673 678 682 847 853
        CURLINE.............. 263 265 265 270 274 280 280 394 438 484 486 492

        DEFINED.............. 472 476 480
        DELIM$............... 375 417 419 421 424 426
        DELIM................ 410 411 413 414 416 417 418

        ENDPTR............... 104 521 521 524 524 527 527 530 530 534 534 537
                              537
        EOJ.................. 158 224 261 264 268 272 279 303 329 343 654
        EOL.................. 358 378 379 393 406 409 431 447
        ETIME!............... 296 297

        FNTRIM$.............. 36 54 179 221 318 319 360 443 446
        FNUPCASE$............ 57 71 179 360

        I.................... 37 38 39 40 41 49 50 51 51 52 58 60 61 67 70 80
                              81 82 102 104 107 107 233 234 253 254 313 314 314
                              315 315 316 316 317 318 335 336 340 346 347 348
                              363 364 366 366 368 410 411 412 414 414 421 425
                              426 426 427 428 441 442 442 443 444 462 464 465
                              465 466 466 471 473 474 475 479 482 483 484 484
                              484 486 486 562 563 563 564 564 565 567 580 581
                              581 582 582 583 583 584 586 607 608 609 610 613
                              676 677 684 686 687 689 701 705 707 724 754 755
                              756 764 783 787 793 794 802 803 804 808 822 841
                              842 844 868
        INFNAME$............. 223 224 253 255 255 262 278 655

        J.................... 474 475 483 484 484 539 540 541 541 684 685 706

        K.................... 796 797 798 818 839 848 852 859 859 860 861 873
        KI................... 782 799 800 801 802 804 804 808 813 823

        LABEL$............... 33 474 475 482 483 484 484 484 486 486 492 563
                              563 564 564 673 677 684 686 687 689 701 705 707
        LABEL................ 370 372 374 375 376 383 449 481 491 496
        LEVEL................ 747 779 779 809 826 826
        LL................... 705 706
        LNDX................. 159 473 489 489 492 559 676
        LPROMPT$............. 174 177

        M.................... 539 542 542 544 544 685 685 685 686
        MAXIMUM.............. 559 562 568 577 580 587
        MAXLEVEL............. 744 762 809
        MAXLINES............. 257 257 298 396 626 634 681 688 694 711 723 728
                              731 760 774 807 851 864

        N.................... 706 707 715 746 748 775
        NDX.................. 358 378 393 410 428 430 434 443 443 444 446
        NEWALPHA$............ 677 678 682 839 846 847 853
        NP................... 172 173
        NUMLABELS............ 674 691 717 717
        NUMLINES............. 270 300
        NUMVARS.............. 674 719 719 729

        OK................... 463 464 468
        OUTFNAME$............ 225 226 227 228 231 233 234 234 257 273 646

basflow.bas                 Program Statistics            07-22-1997 08:35:59

        PGMLINE$............. 266 281 360 371 371 394
        PL$.................. 360 361 363 364 366 366 366 405 405 411 412 426
                              430 434 443 446 686 702 702 704 704 704 708 709
                              712 714 714 721
        PLINE................ 275 285 287 289 291 298 395 395 396 596 601 601
                              621 621 625 625 626 634 638 638 646 657 668 671
                              671 680 680 681 688 693 693 694 698 698 710 710
                              711 722 722 723 727 727 728 730 730 731 740 743
                              743 759 759 760 773 773 774 806 806 807 837 837
                              848 848 850 850 851 863 863 864 874 874
        PREVDEF.............. 359 506 508
        PREVEND.............. 359 518 547 549
        PREVGO$.............. 500 512
        PREVGO............... 359 419 449 499 511 514
        PT$.................. 756 757 785 793 794 800 804 805 820

        QPOS................. 425 434 434
        QUOTE................ 58 59 63 63 65 362 364 364 365

        R$................... 856 857 857 857 858
        R.................... 647 651
        RDEF$................ 97 505
        REDO................. 175 176 181 187 191 197 200 203 207 210 216
        REQUIRED............. 174 180
        RESERVED$............ 100 105 105 248 248 462 465 465 466 540 541 840
                              841 844 870
        RNDX................. 838 843 856 867 867
        RSVCNT............... 34 79 290 516 521 521 524 524 527 527 530 530 534
                              534 537 537 544 544 843 856

        SI................... 604 605 607 608 614 617 619 620 623 624 629 629
                              630 630 631 631
        SNDX................. 436 436 437 438 577 605 607 630
        SP................... 780 780 782 783 784 785 820 821 822 823 825 825
        SRCLST............... 79 277
        STIME!............... 259 297
        STRDATA$............. 33 437 581 581 582 582 608 608 609 610 616 617
                              619 620 623 624 630
        STRDATA.............. 79 292 433
        STRLINE.............. 33 438 583 583 614
        STRSIZE.............. 603 623 623 637
        STRSIZEALL........... 603 609 609 624 624 636
        SWAPED............... 561 565 568 568 569 579 584 587 587 588
        SWITCH$.............. 174 196 196 208 211 211 223 225 227 317 327 328
                              332 332 333 333 334 335 342 347
        SWITCH............... 33 81 242 243 277 286 288 290 292 340 347 433 495
                              516 531 666 744 845
        SWITCHES$............ 78 80 335
        SWVAL$............... 331 332 337 338
        SWVAL................ 337 338 339 339 340

        T$................... 231 232 232 232 749 752 766 788 788 790 790 805
                              827 827 827 844 846 858 858
        TI................... 750 753 754 756 756 761 764 765 769 838 840 841
                              844 844 868 870
        TMP$................. 517 520 523 526 529 533 539 539 540 540 794 797
                              797
        TNDX................. 159 497 497 498 500 500 746 796
        TREE$................ 34 498 500 500 748 748 753 754 756 765 769 784
                              787 797 798 798 799 800 801 802 804 813 821
basflow.bas                 Program Statistics            07-22-1997 08:35:59

        TREE................. 79 286 495 744
        TSTACK$.............. 34 784 785 820 821
        TSTACK............... 34 782 783 822 823
        TTIME!............... 297 302
        TYP$................. 490 491 492 672 687 689 690 716 718

        VALID$............... 174 183 184 194 195
        VALID................ 184 185 186
        VER4................. 79 242 243 531 845

        WORD$................ 376 376 381 404 409 443 446 450 450 451 462 465
                              466 475 492 498 500 505 510 512 517 519 522 525
                              528 532 546

        X.................... 173 216 219 647
        XREF................. 79 288 666

        YES.................. 186 190 198 201 206 210

        Z.................... 30

99   Variables
basflow.bas                 Program Statistics            07-22-1997 08:35:59


Program Lines:  875

Total Time: 3.570313



Knuth Konrad


John Montenigro

Thanks for that, Knuth, I'll check it out.
-John

Jim Dunn

Also, don't forget about Gary Beene... something called ProcSort:

http://www.garybeene.com/files/gbprocsort.zip
3.14159265358979323846264338327950
"Ok, yes... I like pie... um, I meant, pi."

John Montenigro

Thanks, Jim, have downloaded it and will check it out, too.
-John