• Welcome, Guest. Please login.
 
April 20, 2019, 05:53:38 am

News:

Welcome to the SQLitening support forums!


Hello World...

Started by Jim Robinson, July 22, 2016, 06:13:41 pm

Previous topic - Next topic

Jim Robinson

Hi all.

I started programming way back in the last century using BAL (Basic Assembly Language) on an old IBM mainframe.

When the PC's finally got fast enough (using the 386 processors) we migrated over to the PC world.  We started by using PC/370, a BAL emulator for the PC.  This freeware product was purchased by Micro Focus, and we continued using their version for a while.

Meanwhile, I started rewriting our apps in Qbasic.  I even did some VB DOS.  What fun.   I read somewhere on the internet that this product called PowerBASIC allowed you to program in assembler.  Wow!  So I bought PBCC and started looking into it.  I found out that PC assembler and mainframe assembler were about as similar as German and English... there were some things that I understood, but I didn't have time to completely learn a new language.

So I continued on with Qbasic and then VB6.  After a year or so, we were able to abandon the BAL emulators, and things were moving along pretty smoothly.  Except that the programs ran pretty slow.  And we had problems with VB crashing a lot.  I wanted to find a way to make things faster.  I read somewhere on the internet that PowerBASIC had a product that would allow me to make DLLs that ran really fast.  So, I bought PBDLL and started looking into it. 

I wrote a few DLLs and called them from VB, and it worked!  Then, PowerBASIC announced that the were upgrading the product to PBWIN.  I bought it and also bought PB Forms.  I'd learned more how PCs work, and I started converting a bunch of apps from Qbasic and VB using both PBCC and PBWIN. The PB apps ran faster, and only crashed when I made a programming error.  :) Quite an improvement.

Now, several decades later, I need to get a bit more into SQL.  I wrote a simple app using SQLite, and it's been very stable for the last few years.  I see some changes coming, and I really need to understand SQL better so I can expand the simple app into something a bit more complicated.

Wow, I think that's enough for now... CUL

jim
... .... .  .. ...  .... .. ...  .... ..  .... ..

cj

I read "The Definitive Guide to SQLite" and "The SQL Guide to SQLite" and wrote a textbox function executor to test
the code.  It was a great learning experience.  All the crashes I had with VB6 were solved years ago and I also use
it in multithreaded programs.






ken_anthony

Hi Jim,

I did BAL on a Univac in the early 80s. When it was time to find a new job personnel people would say they want IBM people... JCL and BAL were absolutely identical on both! I just couldn't claim IBM experience (as I should have.) Instead I connected a 9 track tape machine to a PC and wrote my code in BasCom... which was faster than any of the later flavors of Basic that Microsoft put out.

Working without SQL is like working while a dog chews on your leg. There's all kinds of theoretic ways to do joins but all I've ever done are left joins with perhaps a few exceptions once every decade or so. That SQLite puts type with the data really simplifies things (and could bite ya if not careful.)

I just created over 10,000 planets this morning and still don't have an inkey$ function! I can't get registered on the PB forums either (though once got a message that was fixed when it wasn't.) I don't mind, but it makes the curve a bit difficult.

I did notice I was getting keyboard info in my callback function on simple forms but something is gobbling them up once I add controls??? I'll figure it out?

cj

July 24, 2016, 12:55:27 am #3 Last Edit: July 24, 2016, 01:02:22 am by cj
The message pump of modeless dialogs can be examined as each character is typed and characters
can also be changed or not allowed before being processed by the controls.

If something is being gobbling up it is probably not allowed by or not being processed by the control it is sent to. :o
Test for the character before it hits the control in the message pump or in the correct %WM message.
Subclassing can also be used to test/change input.

INKEY$ can be simulated in a callback or in the message pump if using PBWIN  (see reply #8)
http://www.sqlitening.com/support/index.php?topic=9603.msg25266;topicseen#msg25266

Post a small program that gobbles up a character and I or somebody else may be able to help.

ken_anthony

I think I've trimmed it as much as I can to show the problem I'm having...

#Compile Exe
#Dim All

Global hF1, hF2, hF3, hGfx As Dword
%Style = %WS_Caption Or %WS_SysMenu

Function PBMain () As Long
    show_F1()
    show_F2()
    show_F3()
End Function

Sub show_F1()
    Dialog New %HWND_Desktop, "Form #1 - [esc] to close", 5, 5, 200, 100, %Style To hF1
    Dialog Show Modal hF1, Call cb_F1
End Sub

Sub show_F2()
    'so we don't pass keystroke to form 3.
    Dialog New %HWND_Desktop, "Just close me", 50, 5, 200, 100, %Style To hF2
    Dialog Show Modal hF2
End Sub

CallBack Function cb_F1()
    If (CbCtl = 27) Then Dialog End hF1   '*** works here ***
End Function

%SD_gfx         = 1210
%SD_cbSize      = 1220

Global nCellSize As Long

Sub show_F3()
    Local nDex, nStyle As Dword
    Dim s_array(5 To 50) As String

    nStyle = %WS_Caption Or %WS_SysMenu
    Dialog New Pixels, %HWND_Desktop, "Try [esc]", 5, 5, 400, 401, nStyle To hF3
    Dialog  Set Color hF3, %Yellow, %rgb_DarkSlateGray

    Control Add Graphic, hF3, %SD_gfx, "", 1, 1, 200, 400
    Graphic Attach hF3, %SD_gfx, ReDraw
    Graphic Color %rgb_DimGray, %rgb_Black
    Graphic Scale Pixels
    draw_design_grid(5)

    For nDex = 5 To 50
        s_array(nDex) = Str$(nDex)
    Next nDex
    Control Add ComboBox, hF3, %SD_cbSize, s_array(), 225, 25, 60, 300, %CBS_DropDownList Or %WS_VScroll
    ComboBox Select hF3, %SD_cbSize, 1

    Dialog Show Modal hF3, Call cb_F3
End Sub

CallBack Function cb_F3()
    Local pt As Point
    Local s1 As String

    If (CbCtl = 27) Then Dialog End hF3   ' *** doesn't work here ***

    Select Case As Long CbMsg
        Case %WM_Command
            Select Case As Long CbCtl
                Case %SD_cbSize
                    ComboBox Get Text hF3, %SD_cbSize To s1
                    If (CbCtlMsg = 1) Then draw_design_grid(Val(s1))
            End Select
    End Select
End Function

Sub draw_design_grid(nSize As Long)
    Local n1 As Long

    Graphic Clear
    If nSize < 26 Then
        For n1 = 1 To nSize
            nCellSize = n1 * (200/nSize)
            Graphic Line (1, nCellSize) - (200, nCellSize)
            Graphic Line (1, 200 + nCellSize) - (200, 200 + nCellSize)
            Graphic Line (nCellSize, 1) - (nCellSize, 400)
        Next n1
    End If
    Graphic ReDraw
    nCellSize=200/nSize
End Sub

cj

July 24, 2016, 11:30:32 am #5 Last Edit: July 24, 2016, 11:33:04 am by cj
'https://forum.powerbasic.com/forum/announcements-articles-and-support-faqs/pbwin-online-help-and-commentary/57497-graphic-inkey-statement

Since a graphic window is being used it has its own commands.
Somebody else will have to step in until I study using graphic windows especially with a callback
This code may work only under some situtations, but it is definitely wrong because the keystroke should immediately be handled.

I also added standard code for callbacks in case you add controls to the forms. 
The fact that 27 works for the control id and the escape key is interesting, but probably not the correct way to handle
a form with no controls.


#INCLUDE "win32api.inc"
%Style = %WS_CAPTION OR %WS_SYSMENU

FUNCTION PBMAIN () AS LONG
    show_F1()
    show_F2()
    show_F3()

END FUNCTION

SUB show_F1()
    LOCAL hF1 AS DWORD
    DIALOG NEW %HWND_DESKTOP, "Form #1 - [esc] to close", 5, 5, 200, 100, %Style TO hF1
    DIALOG SHOW MODAL hF1, CALL cb_F1
END SUB

SUB show_F2()
    'so we don't pass keystroke to form 3.
    LOCAL hF2 AS DWORD
    DIALOG NEW %HWND_DESKTOP, "Just close me", 50, 5, 200, 100, %Style TO hF2
    DIALOG SHOW MODAL hF2
END SUB

CALLBACK FUNCTION cb_F1()

    'If (CbCtl = 27) Then ? str$(cb.ctl): end 'Dialog End hF1   '*** works here ***
    '
    SELECT CASE AS LONG CB.MSG
      CASE %WM_COMMAND
        SELECT CASE AS LONG CB.CTL
          CASE 2: DIALOG END CB.HNDL
        END SELECT
      CASE %WM_SYSCOMMAND
        IF (CB.WPARAM AND &HFFF0) = %SC_CLOSE THEN
        END IF
      CASE %WM_CLOSE
      END SELECT
END FUNCTION

%SD_gfx         = 1210
%SD_cbSize      = 1220

GLOBAL nCellSize AS LONG

SUB show_F3()
    LOCAL hF3 AS DWORD
    LOCAL nDex, nStyle AS DWORD
    DIM s_array(5 TO 50) AS STRING

    nStyle = %WS_CAPTION OR %WS_SYSMENU
    DIALOG NEW PIXELS, %HWND_DESKTOP, "Try [esc]", 5, 5, 400, 401, nStyle TO hF3
    DIALOG  SET COLOR hF3, %YELLOW, %RGB_DARKSLATEGRAY

    CONTROL ADD GRAPHIC, hF3, %SD_gfx, "", 1, 1, 200, 400
    GRAPHIC ATTACH hF3, %SD_gfx, REDRAW
    GRAPHIC COLOR %RGB_DIMGRAY, %RGB_BLACK
    GRAPHIC SCALE PIXELS
    draw_design_grid(5)

    FOR nDex = 5 TO 50
        s_array(nDex) = STR$(nDex)
    NEXT nDex
    CONTROL ADD COMBOBOX, hF3, %SD_cbSize, s_array(), 225, 25, 60, 300, %CBS_DROPDOWNLIST OR %WS_VSCROLL
    COMBOBOX SELECT hF3, %SD_cbSize, 1

    DIALOG SHOW MODAL hF3, CALL cb_F3
END SUB

CALLBACK FUNCTION cb_F3()
   IF GRAPHIC$(INKEY$) = CHR$(27) THEN DIALOG END CB.HNDL
   SELECT CASE AS LONG CB.MSG
      CASE %WM_COMMAND
        SELECT CASE AS LONG CB.CTL
          CASE  %SD_cbSize
            SELECT CASE CB.CTLMSG
               CASE %CBN_SETFOCUS
               CASE %CBN_KILLFOCUS
               CASE %CBN_CLOSEUP:BEEP
            END SELECT
        END SELECT
      CASE %WM_SYSCOMMAND
        IF (CB.WPARAM AND &HFFF0) = %SC_CLOSE THEN
        END IF
      CASE %WM_CLOSE
        ? "Bye"
   END SELECT
END FUNCTION

SUB draw_design_grid(nSize AS LONG)
    LOCAL n1 AS LONG

    GRAPHIC CLEAR
    IF nSize < 26 THEN
        FOR n1 = 1 TO nSize
            nCellSize = n1 * (200/nSize)
            GRAPHIC LINE (1, nCellSize) - (200, nCellSize)
            GRAPHIC LINE (1, 200 + nCellSize) - (200, 200 + nCellSize)
            GRAPHIC LINE (nCellSize, 1) - (nCellSize, 400)
        NEXT n1
    END IF
    GRAPHIC REDRAW
    nCellSize=200/nSize
END SUB

ken_anthony

Thanks CJ, I appreciate the feedback. It'll be a while before I've got my PB sea legs. I'll learn. --ken

PS - I expect I will have a SQLitening test DB online in about six months. I've already purchased two domains for it. Currently I'm just simulating the online DB locally. Anyway, I'll announce when I do and hopefully will get some help stress testing it. (** Just had a thought... any host you would recommend? **)

I plan to write some business software eventually, but I couldn't afford the support costs today. Sooo... my plan is to give away a free game that if I do it right will allow 1000s of players per game (10,000 is my goal, but I will be successful if I can only manage less.) The strategy is to have mostly static data on the server (not entirely) with most processing being done on the clients. I've got other techniques in mind to keep interactivity high. I'm not much for artwork (coming soon in version 2. Act now and we'll throw in a bottle cap!) but I hope gameplay will make up for that. At least I won't be doing ascii graphics!

By the time I get it ready to publish, I should have worked out my tools and practices so I can get my code productivity to a level I won't feel like apologizing for.