Announcement

Collapse
No announcement yet.

A pre-processor compiler statement for PB

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

  • George Bleck
    replied
    OMG BOB did you see that? Mike said "Woo".

    You can take that to be the equivelent of the cheers of a thousand programmers in unison!

    This is the proof that the PB team has truly created a masterpiece this time. :ven:

    Leave a comment:


  • Michael Mattias
    replied
    Woo.

    I just surfed the site here and found all the what's new.

    It was too big to just read on-line so I did some select/copy/paste.

    Just off the top my head that is the single longest list of "new stuff" since at least 1991.

    Leave a comment:


  • Richard Angell
    replied
    I have to find the complete "what's new" document. If the help file is now on line it must be here somewhere.
    All 13+ pages ... (laser printer, 60 lines/page ...included separation lines when printing form Firefox browser)

    http://www.powerbasic.com/support/help/pbwin/index.htm

    Look at the "What's New" section in the left hand treeview index column

    Forward Referencing is now SOP, no need for a metastatement.

    You might also note that Global Memory location is now part of the language, see the GLOBALMEM commands for more. I know you have posted aa lot of code using memory allocations ... now it is wrapped in the language not just available by direct API.

    As far as the other items you mentioned, well instead, you can now finitely control DEBUG code generation at a subroutine level or even line by line level.

    Leave a comment:


  • John Petty
    replied
    Michael
    To sort of quote you RTFP (P for Bob's posts) The full manual has been on line for some time and yes forward referencing is now standard.:applaus:
    John

    Leave a comment:


  • Michael Mattias
    replied
    I have to find the complete "what's new" document. If the help file is now on line it must be here somewhere.

    It's starting to sound like all my NFSs for the past six years have been adopted.

    (I sure hope I find #FORWARD REFERENCE ON and #UNDEF and #ERROR OVERFLOW ON and..... )

    MCM

    Leave a comment:


  • Eric Pearson
    replied
    Oops, my bad! I have been a PB beta tester since the early days of PB/DOS, and whenever possible I use the beta compilers in my daily work (for everything except modules that are distributed to others). I have been using #UTILITY for what seems like a long time now, and I thought that it had been added in the last version.

    Next you're going to tell me that ARRAY SORT USING is brand new! I don't know how I ever got along without it!

    -- Eric

    Leave a comment:


  • Laurence Jackson
    replied
    Originally posted by Eric Pearson View Post
    I prefer to use the #UTILITY metastatement. It was added to PB a couple of versions ago for exactly that purpose.
    ? I've just been reading about that as new for version 9!

    Leave a comment:


  • Eric Pearson
    replied
    Laurence --

    > the special comment '#PRECOM.

    I too use UltraEdit and a home-grown preprocessor. For what it's worth, instead of comments (which IMO should never affect compilation) I prefer to use the #UTILITY metastatement. It was added to PB a couple of versions ago for exactly that purpose.

    -- Eric

    Leave a comment:


  • Aslan Babakhanov
    replied
    Working on ...

    Hi Wayne,

    BTW, I'm working on my own SQL preprocessor based on SQL Tools from PerfectSync called mSQL (Macro SQL)

    Syntax is similar as Michael suggested above.

    Here is the mSQL syntax, but it's in alpha stage like project itself.
    Code:
    LOCAL errTxt AS STRING, rsCount AS LONG, hListViewCtl AS LONG
    LOCAL res() AS STRING
    
    CONTROL HANDLE CBHNDL, %LVC_RESULT TO hListViewCtl 
    
     ~MSQL CONNECT "DSN=mybase"
     ~MSQL PREPARE RESULT TO ARRAY res COUNT rsCount
     ~MSQL PREPARE ERROR  TO errTxt
     ~MSQL EXEC SELECT Customer FROM SalesPerson WHERE PostIndex = "AZ012"
    
     ~MSQL FEED RESULT TO LISTVIEW hListViewCtl
    or

    Code:
    LOCAL errTxt AS STRING, rsCount AS LONG, hListViewCtl AS LONG
    LOCAL res() AS STRING
    
    CONTROL HANDLE CBHNDL, %LVC_RESULT TO hListViewCtl 
    
     ~MSQL-BEGIN
           CONNECT "DSN=mybase"
           PREPARE RESULT TO ARRAY res COUNT rsCount
           PREPARE ERROR  TO errTxt
           EXEC SELECT Customer FROM SalesPerson WHERE PostIndex = "AZ012"
           FEED RESULT TO LISTVIEW hListViewCtl
     ~MSQL-END

    Leave a comment:


  • Theo Gottwald
    replied
    I think the most easy way would be, you download the complete SED-Source from Jose, and include it there.

    if it works fine, sent it back to Jose to make it official.

    I have alread built a Past-Processor into SED some time ago, don't know if its still in there. A Preprocessor is actually not yet supported.

    Anyway I'd support such a possibility, and i have always asked for something like that.

    Leave a comment:


  • Brad D Byrne
    replied
    hmmm, I think what Wayne is really after here, is a 2 pass compiler.

    given the following example, currently I have to pre-define the type of data that I am after, (hence the displaying multiple dialogs), if we had a 2 pass compiler that allowed us to program our 1st pass structuring so2speak, I could have simply used a "ShowVar" for any type. (IIRC, in the old days we called this first pass routines "Macros")




    Code:
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'SHOWVARS.INC
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'here is a handy little include file which will allow you to easily view
    'a string, Single precision Float, or a Long Integer value during runtime,
    'can be very helpful while debugging or designing.
    'syntax:
    'ShowVar "label", var
    'ShowStr "label", string var
    'ShowFlt "label", var
    '(see following test.bas file for use)
    'also should mention that the "label" label portion can be anything, and the
    'routine checks for and updates on simalar labels so if you wish to check 
    'the same variable before and after something you can just: as example; 
    'ShowVar "before xxx", varA 
    'do something
    'ShowVar "after xxx", varA 
    'do what-ever you wish with the code... Public Domain, by Brad Byrne 2004
    '
    GLOBAL hVDsp&,hSDsp&,hFDsp&
    
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    FUNCTION ShowStr(Var_label$, Var_string$ )AS STRING
       STATIC ControlCount&
       LOCAL i&,CntrlText$,NewLbl$,MatchLbl&,yy&
       MatchLbl&=0: yy&=ControlCount&*10+22
       IF  ControlCount& = 0 THEN
    
        DIALOG NEW 0, "SHOW STRINGS DISPLAY",0,0,0,0,%ws_border , TO hSDsp&
        CONTROL ADD FRAME ,hSDsp&,1000,"Strings",2,1,130,yy&, %ss_sunken,
        SetWindowPos  hSDsp&, %HWND_TOPMOST,400,50, 137, yy&+4,0
        DIALOG SHOW MODELESS hSDsp&,
       END IF
    
           NewLbl$=Var_label$+"   :"
            FOR i&= 1 TO ControlCount&+1
              CONTROL GET TEXT hSDsp&,(1100+i&) TO CntrlText$
                 IF CntrlText$= NewLbl$ THEN
    
                     CONTROL SET TEXT hSDsp&,(1200+i&),Var_string$
                     MatchLbl&=1
                     EXIT FOR
                 END IF
            NEXT i&
            IF MatchLbl&=0   THEN
    
                     DIALOG SET SIZE hSDsp&,137,yy&+18
                     CONTROL SET SIZE hSDsp&,1000,130,yy&
                     CONTROL ADD LABEL ,hSDsp&,(1100+i&),NewLbl$,4,i&*10-10,60,10,%SS_RIGHT,
                     CONTROL ADD LABEL ,hSDsp&,(1200+i&),Var_string$,70,i&*10-10,60,10,,
                     INCR ControlCount&
            END IF
    
          SendMessage hSDsp&,%wm_paint,0,0
    END FUNCTION
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    FUNCTION ShowVar(Var_label$, Var_value& ) AS LONG
       STATIC ControlCount&
       LOCAL i&,CntrlText$,NewLbl$,MatchLbl&,yy&
       MatchLbl&=0: yy&=ControlCount&*10+22
       IF  ControlCount& = 0 THEN
    
        DIALOG NEW 0, "SHOW VARIABLES DISPLAY",0,0,0,0,%ws_border , TO hVDsp&
        CONTROL ADD FRAME ,hVDsp&,1000,"Variables",2,1,130,yy&, %ss_sunken,
        SetWindowPos  hVDsp&, %HWND_TOPMOST,450,100, 137, yy&+4,0
        DIALOG SHOW MODELESS hVDsp&,
       END IF
    
           NewLbl$=Var_label$+"   :"
            FOR i&= 1 TO ControlCount&+1
              CONTROL GET TEXT hVDsp&,(1100+i&) TO CntrlText$
                 IF CntrlText$= NewLbl$ THEN
    
                     CONTROL SET TEXT hVDsp&,(1200+i&),STR$(Var_value&)
                     MatchLbl&=1
                     EXIT FOR
                 END IF
            NEXT i&
            IF MatchLbl&=0   THEN
    
                     DIALOG SET SIZE hVDsp&,137,yy&+18
                     CONTROL SET SIZE hVDsp&,1000,130,yy&
                     CONTROL ADD LABEL ,hVDsp&,(1100+i&),NewLbl$,4,i&*10-10,60,10,%SS_RIGHT,
                     CONTROL ADD LABEL ,hVDsp&,(1200+i&),STR$(Var_value&),70,i&*10-10,60,10,,
                     INCR ControlCount&
            END IF
    
          SendMessage hVDsp&,%wm_paint,0,0
    END FUNCTION
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    FUNCTION ShowFlt(Var_label$, Var_value! ) AS LONG
       STATIC ControlCount&
       LOCAL i&,CntrlText$,NewLbl$,MatchLbl&,yy&
       MatchLbl&=0: yy&=ControlCount&*10+22
       IF  ControlCount& = 0 THEN
    
        DIALOG NEW 0, "SHOW FLOATS DISPLAY",0,0,0,0,%ws_border , TO hFDsp&
        CONTROL ADD FRAME ,hFDsp&,1000,"Single Floats",2,1,130,yy&, %ss_sunken,
        SetWindowPos  hFDsp&, %HWND_TOPMOST,500,150, 137, yy&+4,0
        DIALOG SHOW MODELESS hFDsp&, 'CALL Var_Dspl()
    
       END IF
           NewLbl$=Var_label$+"   :"
            FOR i&= 1 TO ControlCount&+1
              CONTROL GET TEXT hFDsp&,(1100+i&) TO CntrlText$
                 IF CntrlText$= NewLbl$ THEN
    
                     CONTROL SET TEXT hFDsp&,(1200+i&),STR$(Var_value!)
                     MatchLbl&=1
                     EXIT FOR
                 END IF
    
            NEXT i&
            IF MatchLbl&=0   THEN
                     DIALOG SET SIZE hFDsp&,137,yy&+18
                     CONTROL SET SIZE hFDsp&,1000,130,yy&
                     CONTROL ADD LABEL ,hFDsp&,(1100+i&),NewLbl$,4,i&*10-10,60,10,%SS_RIGHT,
                     CONTROL ADD LABEL ,hFDsp&,(1200+i&),STR$(Var_value!),70,i&*10-10,60,10,,
    
                     INCR ControlCount&
            END IF
          SendMessage hFDsp&,%wm_paint,0,0
    END FUNCTION
    
    
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'test.bas
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'a little test program to show how to use "SHOWVARS.INC"
    
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
    #INCLUDE "SHOWVARS.INC"
    
    GLOBAL hDlg&, Var1 AS SINGLE , txt$
    
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    CALLBACK FUNCTION CallBackFunc()
    SELECT CASE CBMSG
        CASE %WM_COMMAND
          SELECT CASE CBCTL
             CASE 100
                CONTROL GET TEXT hDlg, 100 TO txt
                ShowStr "my text",txt
             CASE 200
     	    ShowFlt "Var1", Var1
                IF CBCTLMSG = %BN_CLICKED THEN
    
                Var1 = Var1 * 2.2
                ShowFlt "Var2", Var1
                END IF
            END SELECT
            CASE %WM_DESTROY
                PostQuitMessage 0
            FUNCTION = %TRUE
    
        END SELECT
    END FUNCTION
    
    
    FUNCTION PBMAIN
        LOCAL Msg AS tagmsg
        Var1 = 1.234567
        DIALOG NEW 0, "ShowVarTest",50,50,130,120, %ws_overlappedwindow, TO hDlg
        CONTROL ADD BUTTON ,hDlg,200,"Incr Float",30,20,70,30,%BS_FLAT
        CONTROL ADD TEXTBOX ,hDlg,100,"Change this",30,55,70,40, , %WS_EX_STATICEDGE
        DIALOG SHOW MODELESS hDlg, CALL CallBackFunc()
      WHILE GetMessage(Msg,%NULL, 0, 0)
           ShowVar "Msg.hwnd",Msg.hwnd
           ShowVar "Msg.message",Msg.message
           ShowVar "Msg.wparam",Msg.wparam
           ShowVar "Msg.lparam",Msg.lparam
           ShowVar "Msg.time",Msg.time
           ShowVar "Msg.pt",Msg.pt.x
        TranslateMessage Msg
        DispatchMessage Msg
      WEND
    
    END FUNCTION

    Leave a comment:


  • Michael Mattias
    replied
    >As others have said, you don't really need compiler support for this, just some creative renaming

    True, but I think it would be a lot easier to use (and far less prone to making "the big mistake") if there were some kind of thing in the IDE options for ...
    Code:
      Run on compile of BASIC source code [ myprogram.exe]   << default = PBWIN.EXE
      Run on compile of resource files        [  myotherprogram] << default = RC.EXE + PBRES.EXE
    Something like that anyway.


    MCM

    Leave a comment:


  • Laurence Jackson
    replied
    My PB-UltraEdit "bridging" program (http://www.laurencejackson.com/pbshell2/) has pre and post processing capabilities, implemented like this, for example:

    %BUILD_NUMBER = 1000 '#PRECOM INCBUILD PROGNAME.BAS

    The preprocessor (within PBShell) scans the source code for the special comment '#PRECOM. It then interprets the word that follows as the name of the program to be invoked (in this example "INCBUILD") and anything following as command line parameters (in this example, "PROGNAME.BAS").

    The program INCBUILD simply scans the specified source file for a BUILD-NUMBER equate assignment and, if found, increments the value.

    If I were doing this one function from scratch, for use from the PB IDE, I guess I would rename PBWIN.EXE to something else, and name a modified INCBUILD.EXE as PBWIN.EXE. The necessary modifications would be to pick up the source file spec from the command line passed by the IDE then, after source processing, SHELL to the renamed PBWIN.EXE with the original parameters. Of course, then you wouldn't need all the '#PRECOM ... stuff. The same program could do post processing if required as PBWIN would return to it after execution.

    As others have said, you don't really need compiler support for this, just some creative renaming.

    Leave a comment:


  • Chris Holbrook
    replied
    Last one I did looked like this, it's very simple but enabled me to produce a lot of PB Forms code for SQLite table maintenance programs very quickly. Generate ran the pre-processor, which in this case dug out all the columns from a DB table and made a List View control for the whole table, plus a static control for each column item. Having generated the PB Forms application, the app called PBFORMS for the user to tidy up the results. Next step would be Compile, with compiler output shown in the listbox, and you could Run it from here, too, and also call up the PB IDE in a new window. The results were stored in a project directory tree.
    Attached Files

    Leave a comment:


  • Wayne Diamond
    replied
    Yes ... I could also use Notepad to modify the source beforehand, but thats not quite what I had in mind in regards to a pre-processor...

    Leave a comment:


  • Michael Mattias
    replied
    Ok, so please show me an easy path to wrap up PB if it's as easy as you describe
    Code:
    REM CompileMe.cmd
    Start /W myPrecompilerProgram.exe %1 ~sourcefile
    Start pbwin  ~sourcefile /Options
    REM en of file
    ....
    
    C:\DOS> Compileme mysourcecode.bas

    Leave a comment:


  • Wayne Diamond
    replied
    Elaborate please?
    I hope I didn't mean any offense :-/
    Last edited by Wayne Diamond; 11 Aug 2008, 11:03 AM.

    Leave a comment:


  • Chris Holbrook
    replied
    Originally posted by Wayne Diamond View Post
    ...even if it'd work it wouldn't be very pretty...Basically I'm not interested in hack options...
    clearly not a job for myself...

    Leave a comment:


  • Wayne Diamond
    replied
    Originally posted by Chris Holbrook View Post
    Its not hard to write a shell which wraps a collection of tools including an editor, pre-compiler and compiler.
    Ok, so please show me an easy path to wrap up PB if it's as easy as you describe ...

    I have no desire to create a program to hook into the PB IDE or compiler. Renaming the PB compiler executables to something else and replacing them with executables of my own that "pass onto them" is possibly an option, but even if it'd work it wouldn't be very pretty.

    Basically I'm not interested in hack options, because this is a legitimate feature that could easily be incorporated into PB.

    A pre-processor option built into the compiler itself would provide a neat, elegant and powerful way to modify source code before compilation.

    That would add a WHOLE NEW DIMENSION to PowerBasic source code, and I think it would be very easy to incorporate into PB.

    At this very moment there are no real options for that besides messing around with the PB compiler, which I wouldnt ever want to do unless it was my last option, but seeing as there are no pre-compiler options I have had to make my own "manual adjustments" in the past

    Leave a comment:


  • Chris Holbrook
    replied
    Its not hard to write a shell which wraps a collection of tools including an editor, pre-compiler and compiler.

    Leave a comment:

Working...
X