Announcement

Collapse
No announcement yet.

Converting PB-DOS 3.5 Code to PBCC

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

  • Converting PB-DOS 3.5 Code to PBCC

    Had my first go at trying PBCC to see what it takes to convert my simple
    IO-DEMO program, samples of what I do to get formatted and controlled by
    my I/O procedures Data Input from users.

    You can download the PB-DOS 3.5 source code and IO-DEMO.EXE from: www.ottowipfel.btinternet.co.uk

    Seems that PBCC can not display Extended Keyboard Codes such as BOX lines
    in the Editor and therefore can not compile them to show on screen either ?

    After checking imcompatibilites first and removing a few signicant ones
    I compiled it. This is how it went:
    Code:
    ERROR 484 - [b]COLOR %B, %CY[/b]      - yes the constants are defined
    ERROR 484 - [b]CLS[/b] 
    ERROR 484 - a Line Label: [b]MENU:[/b]  
    ERROR 484 - [b]DIM HLPSCR(1:2000)[/b] to save screen displays into
    ERROR 484 - [b]CALL BGCOLOR[/b] a SUB to use all 16 Colors for background
    And that was just the first few lines !

    There is no way I am going to try to convert well tried and tested PB-DOS
    Source Code of my programmes, containing millions of lines, to anything
    else.

    I shall continue to fight to preserve the use of DOS for as long as live


    ------------------




    [This message has been edited by OTTO WIPFEL (edited April 13, 2002).]

  • #2
    Giving up so soon Otto? Come on! You can do it! The first step is to read the "Writing Programs in PB/CC" chapter in the on-line help file.

    Next, an Error 484 means that you did not enclose the code in a Sub/Function wrapper, as clearly described in the above chapter of the documentation.

    For example, the first part of your DOS code looks like this:
    Code:
     $STACK 16000
     $OPTION CNTLBREAK OFF
     $DYNAMIC
     
     DEFINT B-W, Y, Z
     DEFSTR  A
     DEFFLX  X
     
     %BCKSP =   8 : %TAB   =   9 : %RET   =  13 : %SPACE =  32 : %ESC   =  27
     %HOME  =  71 : %END   =  79 : %DEL   =  83 : %INS   =  82 : %PGUP  =  73
     %PGDN  =  81 : %CURSL =  75 : %CURSR =  77 : %CURSU =  72 : %CURSD =  80
     %CTLH  = 119 : %CTLE  = 117 : %CTLPU = 132 : %CTLPD = 118 : %CTLCL = 115
     %CTLCR = 116 : %SHTAB =  15 : %NUL   =   3
     %F1    =  59 : %F2    =  60 : %F3    =  61 : %F4    =  62 : %F5    =  63
     %F6    =  64 : %F7    =  65 : %F8   =   66 : %F9    =  67 : %F10   =  68
     %F11   = 133 : %F12   = 134 : %ZAP   = 147 : %SAVE  = 146 : %PASS  = 140
     
     %B     = 0   : %GY    =  8  : %F = 16   ' Blinking, add to ForeGround
     %BL    = 1   : %LB    =  9              ' Color for BRIGHT BackGround.
     %GR    = 2   : %LG    = 10
     %CY    = 3   : %LC    = 11
     %RE    = 4   : %LR    = 12
     %MA    = 5   : %LM    = 13
     %BR    = 6   : %YE    = 14
     %W     = 7   : %WW    = 15
     
     %CNA = 1 : %CNB =  5 : %CNC =  7        ' Normal Cursor
     %CHA = 1 : %CHB =  7 : %CHC =  6        ' Half Block Cursor
     %CBA = 1 : %CBB =  2 : %CBC =  1        ' Block Cursor
     %C0A = 0 : %C0B = 14 : %C0C =  0        ' No Cursor - or  0,0,0
     
     DIM HLPSCR(1:2000)
     DIM BOXSCR(1:2000)
     DIM OLDSCR(1:2000)
     DIM BROSCR(1:2000)
     DIM ABOX(1:24), FCOL(1:24), BCOL(1:24)
     
     MENU:
    'ßßßßß
        SCREEN ,,0,0: CALL BGCOLOR: LOCATE ,,0,0,0: COLOR %B,%CY,%CY : CLS
        MAP XPROG * 4
    
        COLOR %WW,%MA
        LOCATE 1,12: PRINT" ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» "
        LOCATE 2,12: PRINT" º  D A T A  I N P U T - P R O C E S S I N G  D E M O  º "
        LOCATE 3,12: PRINT" ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ "
    The first steps in translating the code to PB/CC should make it look something like this:
    Code:
    #COMPILE EXE
     DEFINT B-W, Y, Z
     DEFSTR  A
    ' DEFFLX  X -> data type conversion needed
     
     %BCKSP =   8 : %TAB   =   9 : %RET   =  13 : %SPACE =  32 : %ESC   =  27
     %HOME  =  71 : %END   =  79 : %DEL   =  83 : %INS   =  82 : %PGUP  =  73
     %PGDN  =  81 : %CURSL =  75 : %CURSR =  77 : %CURSU =  72 : %CURSD =  80
     %CTLH  = 119 : %CTLE  = 117 : %CTLPU = 132 : %CTLPD = 118 : %CTLCL = 115
     %CTLCR = 116 : %SHTAB =  15 : %NUL   =   3
     %F1    =  59 : %F2    =  60 : %F3    =  61 : %F4    =  62 : %F5    =  63
     %F6    =  64 : %F7    =  65 : %F8   =   66 : %F9    =  67 : %F10   =  68
     %F11   = 133 : %F12   = 134 : %ZAP   = 147 : %SAVE  = 146 : %PASS  = 140
     
     %B     = 0   : %GY    =  8  : %F = 16   ' Blinking, add to ForeGround
     %BL    = 1   : %LB    =  9              ' Color for BRIGHT BackGround.
     %GR    = 2   : %LG    = 10
     %CY    = 3   : %LC    = 11
     %RE    = 4   : %LR    = 12
     %MA    = 5   : %LM    = 13
     %BR    = 6   : %YE    = 14
     %W     = 7   : %WW    = 15
     
     %CNA = 1 : %CNB =  5 : %CNC =  7        ' Normal Cursor
     %CHA = 1 : %CHB =  7 : %CHC =  6        ' Half Block Cursor
     %CBA = 1 : %CBB =  2 : %CBC =  1        ' Block Cursor
     %C0A = 0 : %C0B = 14 : %C0C =  0        ' No Cursor - or  0,0,0
      
    #INCLUDE "LIB-PROC.BAS" ' Moved to the top to eliminate forward-reference problems
      
    FUNCTION PBMAIN
        DIM HLPSCR(1:2000)
        DIM BOXSCR(1:2000)
        DIM OLDSCR(1:2000)
        DIM BROSCR(1:2000)
        DIM ABOX(1:24), FCOL(1:24), BCOL(1:24)
     
     MENU:
    'ßßßßß
        CALL BGCOLOR  ' this seems unnecessary?
        CURSOR OFF
        COLOR %B,%CY
        CLS
    '    MAP XPROG * 4 -> data type conversion needed
     
        COLOR %WW,%MA
        LOCATE 1,12: PRINT" ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» "
        LOCATE 2,12: PRINT" º  D A T A  I N P U T - P R O C E S S I N G  D E M O  º "
        LOCATE 3,12: PRINT" ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ "
     
        WAITKEY$ ' pause to read the screen
    END FUNCTION
    A couple of notes for you, to help you get started:[list=1][*]Flex strings are not supported, so you'll need to revise that code to use UDTs, or some other data type.
    [*]The graphic-characters are displayed unusually in the IDE, since that displays ANSI text, but when such characters are displayed with the OEM (DOS) character set in the Console Window, they should show up fine.[/list=a]
    I hope this helps!

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      O.K. Lance, so I am not giving up converting this small program

      Also BTRIEVE needs FIELDS to OPEN or Create the Layout and Internal Index
      Keys Structure of a new file. The latter is one if it's unique features
      which make files virtually immun to power-outs, not losing indexes in memory
      nor leaving files open. It also rolls back to the last sound transaction
      processed when the file is opened again after such event.

      All files, BTRIEVE and other Random ones have one field only, containing
      one Flex String, mapped to the length of the Data records and sub-mapped
      into the individual record's Data fields.

      Doubt whether "TYPE" or "DIM" defining the structure of a record would work ?
      You know the saying; "If it works, don't change it".

      Can you imagine me having to do change all this and more in all my major programs ?
      Got a "Pistol-to-my-head" Smily ?

      I remembered having purchased the printed PBCC Manual. Will have a search for
      it. It is so much easier to learn from a printed manual (relaxing with a sip of your
      favourite ) than screwing up your eyes trying to read small fixed font Online Help.

      BTW, tried the old Ctrl-F1 on a highlighted code item and got the message
      that the PBCC Editor could not find WIN32API.Hlp. Where can I find that one !

      As I said before, what would we do without you


      ------------------




      [This message has been edited by OTTO WIPFEL (edited April 13, 2002).]

      Comment


      • #4
        Otto, the win32api.hlp file is
        here: http://www.powerbasic.com/files/pub/mstools/


        ------------------
        Client Writeup for the CPA

        buffs.proboards2.com

        Links Page

        Comment


        • #5
          How are you planning on using BTRIEV from your Windows app? Since Windows does not have a generic Flex string data type, some changes will be necesary to accomodate BTRIEV in Windows anyway.

          So on the face of it, your flex string appears to have a fixed length specified at compile-time, so using a fixed-length string may be a viable substitute.

          Where DB record formats and lengths vary, then the usual solution is to use a combination of UDTs, UNIONs, and pointers, along with a generic buffer to hold the data (declared to hold the largest possible record size).

          In use, you always load the data into the same buffer, but reference it using a UDT pointer. By combining all your UDT pointers into a UNION, you can simplify code in some cases too.

          For example (pseudocode)
          Code:
          TYPE RecType1
            sName AS STRING * 20
            sID   AS LONG
          END TYPE
          TYPE RecType2
            sID as LONG
            CreditLimit AS CURRENCY
          END TYPE
          UNION pRecType
            pRec1 AS RecType1 PTR
            pRec2 AS RecType2 PTR
          END UNION
          ...
          a$ = "some data" ' (ie, a$ could be filled from a disk record, or whatever)
          DIM pR as pRecType
          pR.pRec1 = STRPTR(a$) ' set up the pointer address - we use STRPTR for the dynamic string data address
           
          ' if the data is a 'type 1' record, we can use the 1st pointer to reference it
          PRINT [email protected]
           
          ' if the data is a 'type 2' record, we can use the 2nd pointer to reference it
          PRINT [email protected]
          The advantage of using a UNION of pointers is that by a single STRPTR assignment to any of the member pointers, the other member pointers all reference the same address.

          I hope this helps rather than confuse!


          ------------------
          Lance
          PowerBASIC Support
          mailto:[email protected][email protected]</A>
          Lance
          mailto:[email protected]

          Comment


          • #6
            Yes, it does help !

            Ok to use PBCC for new applications, but I would not want having to re-code all my
            existing and well tried programmes. In any case, they still work, if need be, from
            Windows up to 98 SE Desktops, looking more or less the same way as the PBCC Console
            window. And there is DOSEMU ? Waiting to hear more about it from DR-DOS tomorrow.

            The easy to use USING$ is also sadly missed. With Accounting Software a quick and
            easy way to format Numerical Data is a must. The work-around Function and FORMAT$
            are no viable alternatives.

            I make more mistakes changing existing code than writing new. This must also be the
            reason why MS manages to create more bugs than they fix with every Update

            I shall give it rest for now and have fun creating Web sites for my friends. The latest
            can be viewed at: www.bristolaero.btinternet.co.uk

            Took me a day to do it, hacking everything from his Web Site created by some other
            guys he paid to do it. Have a look what they call a Web site www.horders-tp.co.uk

            If it's that easy to to copy stuff from anybody's Web site, I am not surprised a lot of people
            and corporations are apprehensive about using it for serious stuff other than PORN



            [This message has been edited by OTTO WIPFEL (edited April 14, 2002).]

            Comment


            • #7
              [QUOTE]Originally posted by OTTO WIPFEL:

              The easy to use USING$ is also sadly missed. With Accounting Software a quick and
              easy way to format Numerical Data is a must. The work-around Function and FORMAT$
              are no viable alternatives.

              OTTO,

              I understand your feelings. I am just completing my 1st program
              conversion from PBDOS to PBCC. It was very frustrating at times.
              I use ascii box characters alot, print usings alot, etc. But I had
              to get around the DOS print driver problem. I have used alot of
              code from the forum as learning templates and modified them for my
              purposes. I think I can help with some ideas on how I am handling
              things, maybe they will help. I, too, am a solid DOS fan, but
              Windows does have some nice features - it's just getting to them.
              I am not planning on converting all my programs either (as I had
              origionally planned) - Just the ones that are really necessary.
              These PB forum guys really came through for me!
              Good Luck.
              Deon




              ------------------
              Deon Judkins
              Deon

              Comment

              Working...
              X