Announcement

Collapse
No announcement yet.

Search & Replace

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

  • Search & Replace

    I am new to PowerBasic for DOS in fact so new that the program
    should arrive this comming Monday or Tuesday.
    Hopefully I'd like to be ready for it with a min of down time.
    I have some old DOS programs written in Basic,Basica or GWbasic
    that will not run on my newly acquired Windows XP OS.
    PowerBasic for DOS therefore is the answer,in my efforts to
    prepare myself for problems someone might have experienced some
    of thse problems to help.
    I am told that it is possible some of the old DOS commands are
    not acceptable to PB for DOS. These will be rejected with a
    Syntax Error and prompt you to use a built in
    "Search & Replace"function asking for a replacement.
    I was made aware that there are certain variables that will
    not be accepted,example one that I have used is AT$,this could
    be a problem. Also commands such as PRINT,LPRINT & GOTO.
    Has anyone out there run into this if so what can be done to
    remendy the situation


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

  • #2
    Your question is kind of broad based so, I suppose, will be the
    answers.

    Yes, PB35 does have a search & replace function built into the
    editor. The sequence, in this instance is Cntl-Q-A. Enter what
    you want the editor to find then hit enter. You will then be
    asked what to replace it with. Then hit enter again. You will be
    then given some options. Entering U-G-N (without dashes) will
    replace EVERYTHING, from the cursor down without prompting,
    with the replacement text. You have to be careful about this. If
    you want to replace, for example, AT$ (recommended) with TEMP$,
    it will replace AT$ with TEMP$, MAT$ with MTEMP$... I think you
    get the idea.

    When you get your compiler, hopefully soon, don't hesitate to
    ask when you get really stumped over something. Remember, the
    only stupid questions are those that go unasked.


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




    [This message has been edited by Mel Bishop (edited January 26, 2003).]
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

    Comment


    • #3
      Mel thanks for your fast reply you are correct,not to ask
      questions because you feel it may sound stupid is downright dumb.
      I have been guilty of that in the past let me emphasize that
      with a question,will I be able to modify,update my programs after
      they have been processed thru PB for DOS
      Example using the old basica system and after loading my program I was
      I was able to LIST this program to modify and/or update the
      program. Is that feature still available once the program is
      processed thru PB for DOS
      Thanks Again
      John Romano


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

      Comment


      • #4
        Originally posted by John Romano:
        ...I was able to LIST this program...Is that feature still available...
        Kinda-sorta-in-a-way. The PB editor is actually a line oriented
        word processor. Once you enter the .BAS file, you can have at it
        for modifying, adding, deleting, whatever. You can print out the
        entire file or just selected blocks.

        I know this is going to sound wrong (and I don't mean it to be)
        but before asking any more questions, maybe you better wait until
        you get the package in the mail and play with it for a while.
        After all, that's half the fun of programming.


        ------------------
        There are no atheists in a fox hole or the morning of a math test.
        If my flag offends you, I'll help you pack.

        Comment


        • #5
          Check out PB/DOS File Library: Tools & Utilities There are some handy conversion utilities in there. Qb2Pb (v2) helps with quickbasic conversion. I used it, and it works, although I still had lots of other work to do by hand to really take advantage of PB.

          As a strategy for your conversion efforts, I think you should really dig in to the PB manuals first, and expect to rewrite lots of code. Not because you need to, but because you can improve it a whole lot under PB if you know about the great improvements that are available. I found that a lot of the lame and awkward things that bugged me under QB have been replaced by much better methods, and it was worth the work. Then again, I can be a fussy bugger at times. I found that in the process, I took care of any last compatability details because I was rebuilding the code anyways. The result is code that I actually like: bravo to PB.

          I also strongly suggest that you use a windows text editor for your bulk programming. I really like Editpad Pro. It has really handy things like tabbed multi documents, document comparison, very powerful regex pattern matching for search and replace, copy-append, and launch document to an app from user defined menu. With a bit of clever you can do very precise s&r operations that would be much safer than in the PB IDE. Heck, we have Win based machines for ease of use right? So I find it fastest to skip PB's IDE except for debugging. I also suggest that you can compile from the command line, and since PB lets you put all the options inside your program, you don't even have any command line arguments most of the time. I will repeat that EditpadPro is very good. There are a lot of other great things this program does that you have to try to appreciate. And no, I don't get a commision, it's just really good stuff.

          Best of luck.

          ------------------
          What can go wrong will go wrong.
          Anything can go wrong.
          What hasn't?!?!

          [This message has been edited by Criss French (edited January 29, 2003).]
          What can go wrong will go wrong.
          Anything can go wrong.
          What hasn't?!?!

          Comment


          • #6
            John
            Make sure your GWBasic/Basica files have been saved with the
            ",a" switch in the GWBasic/Basica editor Like so (replace PROGRAM.BAS
            with the name of your program):

            LOAD "PROGRAM.BAS
            SAVE "PROGRAM.BAS",A

            Note the ",a" ^^. If you do not use this switch your code
            will just be tokenized gibberish when you load it with any other
            editor(IIRC).

            Buck


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


            [This message has been edited by Buck Huffman (edited January 29, 2003).]

            Comment


            • #7
              Buck:
              Thanks for your response,let me review your message. I'm to
              LOAD then SAVE any of my old BASICA/GWBASIC programs using
              the original BASICA/GWBASIC format or enviroment. It is at
              this time and when in the SAVE mode I must add the ,A switch.

              I then transfer this newly saved program (w/switch)into my
              PowerBASIC for DOS using FILE OPEN (load) & F9 to RUN.
              Is this correct?




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

              Comment


              • #8
                Once you save the file in BASICA/GWBASIC with the ",A" suffix, then the file will contain plain ASCII test, which is then compatible with PowerBASIC, and can be loaded into the IDE for editing and compiling, etc.

                In other words (IOW), the 'SAVE "filename",A' step in BASICA/GWBASIC is a once-only operation that is required to convert a tokenized .BAS file into plain ASCII format.

                If you do not have access to BASICA/GWBASIC any more, then you will find various tools to help convert the files from tokenized to ASCII in the DOS TOOLS section of the DOWNLOAD area at http://www.powerbasic.com/files/pub/tools/dos/

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

                Comment


                • #9
                  Lance
                  I had to set up my old Win95 to do it but based on the results
                  I was partly successful. I will look into DOS TOOLS.
                  Transferring this modified program (with the ,A switch)back into
                  the C drive of the new computer and dbl clicking on the Icon it
                  automatically goes to WordPad and I can view the entire program.
                  It is if I LISTED it using the old basica format. There is an
                  added advantage now I can scroll thru the entire 27000 lines.
                  I can now load (using OPEN)it into PowerBASIC and I can now view
                  the first 43/50 lines (Computer is set for 43/50 lines) I cannot
                  scroll.
                  I try to RUN (F9)and nothing happens program,will not execute?

                  I wrote a simple program using some of the std commands directly
                  using PowerBASIC. I wrote,saved it and ran it,
                  EXAMPLE:
                  100 PRINT"This is an addition program"
                  110 INPUT"Type in first No........=";A
                  120 INPUT"Type in second No.......=";B
                  130 C=A+B
                  140 PRINT"Answer..................=";C
                  150 GOTO 100
                  Note these same commands are used in the program with
                  the ,A switch

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

                  Comment


                  • #10
                    Originally posted by John Romano:
                    ...the entire 27000 lines....
                    You may want to read up on the $INCLUDE metastatement and break
                    your source code up into smaller, more manageable chunks. Just
                    a thought.

                    100 PRINT"This is an addition program"
                    110 INPUT"Type in first No........=";A
                    120 INPUT"Type in second No.......=";B
                    130 C=A+B
                    140 PRINT"Answer..................=";C
                    150 GOTO 100
                    You can do quite nicely without line numbers and GOTO's in PB.
                    Try this out and see what happens:

                    Code:
                    do
                     PRINT"This is an addition program"
                      INPUT"Type in first No........=";A
                       if a = -1 then exit loop
                      INPUT"Type in second No.......=";B
                       if b = -1 then exit loop
                         C=A+B
                     PRINT"Answer..................=";C
                    loop
                    As an added thought, your conversion process will be tedious to
                    the max. If you have that large a program, I would suggest putting
                    all your sub-routines into separate file(s) and then $INCLUDE
                    them in the main file and then editing them one at a time.

                    Also, PB can digest line labels vs. line numbers. For example,
                    instead of using GOSUB 10550 you can use GOSUB ConvertStringToUpperCase.
                    Line labels are a LOT more descriptive than numbers and makes it
                    easier to remember where you want to go_to and under what circumstances.

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




                    [This message has been edited by Mel Bishop (edited February 01, 2003).]
                    There are no atheists in a fox hole or the morning of a math test.
                    If my flag offends you, I'll help you pack.

                    Comment


                    • #11
                      Mel
                      Thanks for you reply. I went directly into PB's main screen and
                      typed in the sample program you provided in your message. I have
                      to be doing something wrong,when I tried running it (F9)nothing
                      happened.
                      Page 72 of PB's "User Manual" doesn't offer me much (and I
                      emphasize ME)to understand metastatements/$INCLUDE to be able
                      to put it into practice. Is there more detailed info or sample
                      programs available to use as a referance
                      Concerning the elimination of line numbers,I agree.
                      There is a conversion utility,RB58 that is used to convert .BAS
                      files into ASCII format would you know anything about or how it
                      works.

                      THANKS

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

                      Comment


                      • #12
                        Originally posted by John Romano:
                        ....when I tried running it (F9)nothing happened.....
                        I don't know why F9 isn't working for you. Always works for me.
                        Try F8'ing and single step through the program. Perhaps Lance
                        can answer this. What O/S are you working under? Maybe that has
                        something to do with it, maybe not.

                        ...understand metastatements/$INCLUDE...
                        The concept of $INCLUDE is very easy to understand. You have a
                        MAINFILE.BAS. When compiling and the compiler reads the $INCLUDE
                        statement, it will read that file in, compiles it and, when
                        finished, take up exactly where it left off from. Now somewhere
                        in your MAINFILE.BAS, you have a subroutine or function
                        containing a zillion lines of text. Instead of putting that in
                        MAINFILE.BAS, you would create it in a separate, smaller, more
                        manageable file and then use the $INCLUDE metastatement in
                        MAINFILE.BAS.
                        Example:

                        Create this using any file name you wish.
                        Code:
                        $lib all off
                         color 14,1
                          cls
                           print;"This line is printed from the MAINFILE.BAS"
                            $include "incfile.bas"
                             print;"We are now back in the MAINFILE.BAS"
                        end
                        Now your $include file will contain (in a separate file, named
                        INCFILE.BAS)

                        Code:
                        print;"This line is printed from the INCLUDE file."
                        By the way, when you post separate topics, you really should
                        create a new post on this BBS.




                        ------------------
                        There are no atheists in a fox hole or the morning of a math test.
                        If my flag offends you, I'll help you pack.

                        Comment


                        • #13
                          Mel
                          My appologies,I knew from the beginning this wasn't going to be
                          easy it is for this reason I have become anxious to be able to
                          understand how it works.

                          To answer your question,I'm using Wiindows XP Home Edition that
                          was already installes when I purchased the computer


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

                          Comment


                          • #14
                            i found a link that may be useful.
                            http://www.powerbasic.com/support/pb...read.php?t=688

                            ------------------
                            There are no atheists in a fox hole or the morning of a math test.
                            If my flag offends you, I'll help you pack.

                            Comment

                            Working...
                            X