Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

ShowVars

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

  • ShowVars


    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
Working...
X