Announcement

Collapse
No announcement yet.

Opt-Tech sort ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Opt-Tech sort ?

    I'm reworking some very old programs and moving from Microsoft BC v7 to
    PB Dos ( and maybe on to PB CC or PB Win ). This is just something I'm doing
    to learn more about the PB products.

    In checking out the older messages, Mike Doty seemed to be the only one
    who confessed to actually using this product with PB Dos. I used it in several
    programs under BC v7 but have hit a snag in trying to get it to work with
    PB Dos. I built a sort.pbl with sortibmb.obj & sort.obj & sw10k.obj ( which I
    think are the necessary parts ). but when I compile the program I get a
    fix-up overflow and at this point I'm stumped. So I'm asking for a little help.
    Is there something extra I need to do to create the .pbl correctly or some
    option when doing the $Link statement?

    Any help is appreciated.

    Thanks.

  • #2
    Not sure exactly what the problem is but if I remove sw10k.obj from the pbl
    then the compiler doesn't have any problems. The reason that I included it
    was that it was difficult under BC v7 to free up memory for the sort program
    to use as work space/buffers/whatever. so we included a 10k area in the
    program for it to use. I would like to continue to do this but until someone
    who knows for sure how to fix it I'll see if I can free up some memory in
    PB Dos for it to use.

    Off to create some temp files & a test program. I'll be back later.

    [ LATER ]
    Ignore what I said about it compiling after removing sw10k.obj.
    When I started creating the test program, I noticed that a WHOLE lot
    of my original program had vanished. Something must have went BLIP
    between compiles. lucky that backup file was still okay. Without the
    sw10k.obj, the compiler gives "Unresolved EXTERNAL: SW_PARA".
    back to the documentation.
    [ /LATER ]
    Last edited by Paul D. Elliott; 15 Nov 2007, 01:14 PM.

    Comment


    • #3
      I wish you had given the exact error message number. I only found these two relating to FIXUP errors..
      Error 514: Invalid fixup

      You tried to $LINK an .OBJ file which contains an invalid fixup
      requirement. For example, while it is legal to define initialized
      data in the 'DATA' segment (or one equated with $ALIAS), it must
      contain only static constants (numbers or characters). It may not
      include any "pointers" which reference a code or data label, thus
      requiring a link-time "fixup". Such pointers may only appear in
      a segment other than 'DATA.

      Error 515: Fixup overflow

      You tried to $LINK an .obj file containing a reference to a
      code or data item which is not in the segment where PowerBASIC
      expected it to be. A NEAR reference to an item which is in a
      different segment will cause this error.

      I had recalled something about "fixup" and "initialized data" which is what I thought of when you said you 'reserved' some work space.

      FWIW, you can tell your program to reserve some memory using MEMSET. You can set it to, say, 640 K minus whatever workspace you'll need at runtime. I've forgotten how to specify that in 20-bit format, but since you are still working with MS-DOS I'm sure you will know how.

      MCM
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Michael,

        Thanks for checking. It was Error #515. But I finally found my copy of the
        Opt-Tech documentation ( moved across the country a couple months ago
        and while most things are out of the boxes, I haven't managed to sort all
        the computer books back in decent order ). Seems that I can't call the sort
        using the same .obj files that I used in BC v7. I would have to use the
        SortRes.exe program ( which would probably have to be loaded before my
        program starts and tie up a bunch of memory the whole time my programs
        are running ). So I'm checking into other programs. One of which is yours.
        You mentioned it in one of the messages from back around 2000. So I sent
        you a message.

        I'll continue checking and post info when I find something useful.

        Comment


        • #5
          Code:
          'Here is a shell method with the current version of the sort.
          'Some of the statements here used Crescent Software.
           
          SUB Sorter (OldNamePassed$, NewNamePassed$, Control$, NumRecs&, RetCode%)
           'Note JN not supported in Windows Opt-Tech Sort - Use N
           OldName$ = OldNamePassed$
           NewName$ = NewNamePassed$
           Control$ = UCASE$(Control$)
           SortProgram$ = DataBaseDir$ + "OTSORT.EXE"        'use 16-bit
           IF Win32 THEN
            IF OldName$ = NewName$ THEN  'and using 32-bit sorting
             RenameFlag = 1             'can't use same input/output file
             NewName$ = DataBaseDir$ + MID$(STR$(INT(TIMER)), 2) + ".tmp"
            END IF
           
            SortProgram$ = DataBaseDir$ + "OTSW32D.EXE"  '32-bit sort pgm
            I = INSTR(Control$, "OVER 4B")  'not allowed in 32-bit sort
            IF I > 0 THEN Control$ = LEFT$(Control$, I - 1)
            org$ = SortProgram$ + " " + OldName$ + " " + NewName$ + " /" + Control$
            
           ELSE  'DOS
            org$ = SortProgram$ + " " + OldName$ + " " + NewName$ + " /" + Control$
           END IF
           filenum = FREEFILE
           ControlFile$ = DataBaseDir$ + "TEMP" + MachineNumber$ + ".TMP"
           OPEN ControlFile$ FOR OUTPUT SHARED AS #filenum
           PRINT #filenum, Control$
           'PRINT "Control statement$ "; Control$
           CLOSE #filenum
           org$ = SortProgram$ + " " + OldName$ + " " + NewName$ + " " + ControlFile$
           'Put this back
           IF TraceOn THEN
             CLS
             PRINT "Shell Statement "; org$
             PRINT "Control"; Control$
             PRINT "Press any key to shell": xx$ = INPUT$(1)
           ELSE
             'org$ = org$ + " >NUL"   'always hide sorting put back later
           END IF
           
           'CALL ShellOutDisable
           'CALL CatchError
           SHELL org$
           'CALL GetError(ErrorLevel%)
           'CALL ShellOutEnable
           NumRecs& = -1   'so no error displayed, don't know number
           RetCode = 0     'so no error displayed
           IF ErrorLevel THEN
             'CLS
             PRINT "ErrorLevel"; ErrorLevel; " Unable to sort file.  Press any key"
             xx$ = INPUT$(1)
             EXIT SUB
           END IF
           CALL MhKill(ControlFile$ + CHR$(0), Ecode)
           IF TraceOn THEN PRINT "Status deleting "; ControlFile$; Ecode
           IF RenameFlag THEN
             CALL MhKill(OldName$ + CHR$(0), Ecode)
             IF TraceOn THEN PRINT "Status deleting "; OldName$; Ecode
             CALL mhRename(NewName$ + CHR$(0), OldName$ + CHR$(0), Ecode)
             IF TraceOn THEN PRINT "Status renaming to "; NewName$; Ecode
           END IF
           IF TraceOn THEN
             PRINT "Press any key to continue"
             xx$ = INPUT$(1)
           END IF
           
          END SUB

          Comment


          • #6
            You know, these 'private messages' are a really nice feature of this new forum software.

            When you see something in one of the source code postings which could, uh, um, er, 'use some enhancement' it's nice to be able to send an off-line note.. especially when the poster does not include an email address in the source code.

            I sent the file. Note the doc file in the ZIP has a *.doc" extension, but it's really just a text file.

            (There was no MS-WORD for MS-DOS and ".doc" was not "reserved" by systems, so we used meaningful file extensions then... very handy considering there was also no such thing as "long file names" at that time).

            I guess it's true that old code never dies..... (eg, this is for PB/DOS 3.2!).

            MCM
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Speaking of which.....

              There's no reason you can't SHELL a PB/CC program from your MS-DOS program. And unless I am mistaken, one of the example prorgams shipped with PB/CC is a file sorter ... very usable when you can't sort using the MS-DOS sort because the file is too big.

              No reason you couldn't modify that program or create your own PB/CC program to operate as a command-line utility if you pass it the sort specs...e.g.
              Code:
              SHELL "disksort.exe filein;fileout;keyoffset;keylen;keytype"
              (Hey, what a great idea for someone who wants to write something for Mr. Purvis' contest, huh?)

              MCM
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                Also speaking of which (wrong operating system forum I know, I know)...

                Would there be any interest in some kind of sort DLL which supports "release-return" type calls?

                ie.
                Code:
                  hSort = [B]SetSortSpecs[/B](something)
                  FOR Z = 1 to NUmberOfRecords
                    Get Input Record
                    Add key(s) 
                    CALL      [B]ReleaseToSort [/B] (hSort, record) 
                  NEXT
                 ' now return all released records in sorted order using SortSpecs
                  FOR Z = 1 TO NumberOfRecords
                    Record = [B]ReturnFromSort[/B] (hSort)    
                 NEXT
                Bold = functions in a DLL

                Something like that?

                ????

                Another Contest Idea?

                MCM
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  Michael,

                  Thank you very much! I'll use it whenever the files need simple sorting by
                  a single key ( which is most of the time ). At the moment, I don't want to
                  have to fiddle with the data to handle sorts with multi-keys of which one
                  is ascending & one is descending ( as in ascending on doctor and decending
                  on date or length-of-stay ). For those few sorts, I'll use the command-line
                  version of Opt-Tech sort.

                  I've never tried running a PB CC program under pure DOS. The computer I'm
                  doing this development on is running FreeDOS and these programs were all
                  developed long before Windows was born.

                  As for "release-return", I know the DOS version of Opt-Tech sort had this.
                  I think the Windows version did too but I've only used it with Delphi.
                  Eventually I'll check if this all works with PB Win. But for now, my little
                  stumbling block has been jumped over.

                  Once again, THANKS!




                  Mike,

                  Thanks for the example. I wasn't sure if PB grabbed all memory and then you
                  had to compact/free some to run other programs. I was just trying to do
                  things the same way that I had in the past ( which was to link in the .obj
                  instead of shelling out to run an exe ). And the samples from Opt-Tech all
                  showed loading the resident version of the sort and calling it.

                  Thanks for the help. I'll probably be back when I hit the next bump.

                  Comment


                  • #10
                    >As for "release-return", I know the DOS version of Opt-Tech sort had this.

                    Release-return comes from The Almighty's Language of Choice: COBOL.
                    Code:
                    SORT sort-file 
                      INPUT    PROCEDURE IS paragraph-name1   <<<< where you RELEASE
                      OUTPUT PROCEDURE IS paragraph-name 2 <<<<  where you RETURN
                    END-SORT
                    ....
                    MCM
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      At the moment, I don't want to have to fiddle with the data to handle sorts with multi- keys of which one is ascending & one is descending ( as in ascending on doctor and decending on date or length-of-stay ).
                      I actually did a multi-key sort - using ARRAY SORT. The code is public domain for PB-DOS, another one of my old articles for Basically Speaking. Maybe I can dig that out, too. (I know it's available at the IMS web site. Find the issue with the article "Multi-Key Sorting Revisited"... should be 1996, 1997 or 1998 or so).

                      But -- Doctor? Length of Stay?

                      If you are doing healthcare stuff and are desirous of handling the ANSI ASC X12N documents ("the HIPAA EDI") directly, I have several products which might be of interest to you. I've been doing healthcare EDI since before the HIPAA was passed in 1996.

                      Commercial payers weren't doing a whole lot of ANSI X12 then (mostly used NSF format flat files), but Medicare was. Yes, that's right: your tax dollars actually supported what turned out to be a "leader" in the field of electronic healthcare transaction processing.

                      MCM
                      [email protected]
                      Michael Mattias
                      Tal Systems (retired)
                      Port Washington WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment


                      • #12
                        Originally posted by Paul D. Elliott View Post
                        At the moment, I don't want to have to fiddle with the data to handle sorts with multi-keys of which one is ascending & one is descending ( as in ascending on doctor and decending on date or length-of-stay ).
                        When we wanted to do descending sort on a numeric field in IMS, we stored the nine's complement in the database. For example, for a Julian date of YYDDD, we stored 99999 - YYDDD. This way, we could sort the resulting field in combination with others in ascending order.
                        Regards,
                        Bob

                        Comment


                        • #13
                          >... in IMS,

                          IMS? Woo. I thought discussions of MS-DOS were about as ancient as it got here. Wrong-O.
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                          • #14
                            Raat

                            As for "release-return", I know the DOS version of Opt-Tech sort had this.
                            Current version still has what they call RAAT (Record At A Time)
                            Memory usage is far better than with the DOS version.
                            Here are some of the newer features:
                            http://www.opttech.com/latestversion.htm

                            Comment


                            • #15
                              Originally posted by Michael Mattias View Post
                              >... in IMS,

                              IMS? Woo. I thought discussions of MS-DOS were about as ancient as it got here. Wrong-O.
                              It may be old, but it works just as well now as it did then. Just because something is younger doesn't mean it's better.
                              Regards,
                              Bob

                              Comment


                              • #16
                                Mike,

                                In your sample code, you mention that you use routines from Crescent.
                                I've got their QuickPak Pro dated 10/5/92 ( not exactly sure but it seems
                                to be later than v4.01 ... some fool forgot to label the disks at to version
                                number & date received ... sometimes Crescent didn't do much more than
                                put a sequence # on them ). Are these programs/routines compatible
                                with PB Dos v3.5?

                                I will probably go ahead and install just to see what is there. Then try to
                                find the manuals ( I did a cross country move a couple months ago ...
                                most everything is out of the boxes but I haven't sorted the computer
                                books in any kind of order yet ). At the time I was actively doing DOS
                                programming ( '84 thru '95 ), I had kept up products from MicroHelp and
                                Crescent and used whichever did what I needed. Towards the end I
                                mostly used Muscle from MicroHelp but the earlier programs tended to use
                                MicroHelp's ToolBox II & Mach2.

                                Thanks for your help.

                                Comment


                                • #17
                                  The Crescent code is not needed since it can be replaced with KILL, RENAME, NAME, etc ... from the compiler used.
                                  It was just copied from another application to post something quickly.

                                  Comment


                                  • #18
                                    Ok. I thought you might have been using it to get the exit code from the
                                    Shell statement. I'll just redirect the sort screen output to a file and parse
                                    it looking for errors or counts.

                                    Thanks.

                                    Comment


                                    • #19
                                      Correct, and you can definitely use other means to see if successful.
                                      The updated version of the sort eliminates running out of memory.

                                      Comment


                                      • #20
                                        Ok. I thought you might have been using it to get the exit code from the
                                        Shell statement
                                        Code:
                                        ' EXECDOS.BAS
                                        ' Execute an exteernal program as a child proccess, interrogate
                                        ' it's return code.
                                        ' For PB/DOS 3.2
                                        ' Author: Michael Mattias Racine WI 
                                        ' from original version for Microsoft QuickBASIC by Ethan Winer.
                                        
                                        
                                        '============================================================
                                        '     SUB TO Execute a program as a child process           
                                        ' Function value = return code of process; if < 0, error is 
                                        ' -1 * (dos error)
                                        '============================================================
                                        
                                        ' REG equates as expected in REGS.INC
                                        DEFINT A-Z
                                        FUNCTION DosExecute% (Program$, Parameter$) LOCAL
                                          '---- Prepare the program name and parameter strings for processing.  DOS
                                          '     requires that the parameter string hold the length of the parameter
                                          '     text, followed by the parameter text, and then followed by a CHR$(13)
                                          '     Enter byte.  The parameter block holds two CHR$(0) bytes followed by
                                          '     the address and segment of the parameter string.
                                          '
                                          DIM Block   AS LOCAL STRING * 14    'this is the DOS parameter block
                                          DIM Parm    AS LOCAL STRING * 80    'and this is the actual parameter text
                                        
                                          DIM ZBuffer AS LOCAL STRING * 80    'this holds a copy of the program name
                                        
                                          SaveDefSeg = pbvDefSeg
                                          DEF SEG
                                          DefaultDS = pbvDefSeg
                                          Zero$ = CHR$(0)                  'invoke CHR$() only once for efficiency
                                          DOS = &H21                       'saves a few bytes
                                          ZBuffer$ = Program$ + Zero$      'make an ASCIIZ string for DOS
                                        
                                          LSET Parm$ = CHR$(LEN(Parameter$)) + Parameter$ + CHR$(13)
                                          LSET Block$ = Zero$ + Zero$ + MKI$(VARPTR(Parm$)) + MKI$(VARSEG(Parm$))
                                        
                                          Dummy& = SETMEM(-500000)         'free up memory for the program being run
                                          REG %RegAX, &h4B00
                                          REG %RegDX, VARPTR (ZBuffer$)
                                          REG %RegES, VARSEG(Block$)
                                          REG %RegBX, VARPTR(Block$) 
                                          REG %RegDS, DefaultDS
                                          CALL INTERRUPT DOS
                                          Flags = REG(0)
                                          ReturnAX = REG(%RegAX)
                                          IF (Flags AND 1) THEN          'DOS error trying to run the program?
                                            DosExecute% = -(ReturnAX)    'yes, set function value to -1 * error code
                                            GOTO Execute.Done            'and jump to reclaim memory
                                          END IF
                                        
                                          REG %RegAX, &H4D00               'retrieve subordinate process code
                                          CALL Interrupt DOS
                                          DosExecute% = REG (%RegAX)          'set function value to exit code
                                        
                                        Execute.Done:
                                          Dummy& = SETMEM(500000)          'reclaim the memory relinquished eariler
                                          DEF SEG = SaveDefSeg             ' restore DS to what it was at entry.
                                        
                                        END FUNCTION
                                        Michael Mattias
                                        Tal Systems (retired)
                                        Port Washington WI USA
                                        [email protected]
                                        http://www.talsystems.com

                                        Comment

                                        Working...
                                        X