Qbasicnews.com

Full Version: PEEK and POKE
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Here is a problem some of you guys might be able to come up with an answer. I do not expect you to be knowledgeable with the likes of Liberty Basic or BBC BASIC for Windows, and it is not the function of this forum to delve too deeply in other Basics. But I would like to be able to create PEEK and POKE routines in QB that would allow data to be swapped between the three different languages.

QB has POKE and PEEK of course, likewise BBC BASIC similar commands, and some clever guys have produced the equivalent code using API calls for Liberty Basic. All way beyond me as I am almost strictly a BASIC man and at 72 too old to learn the complexities of hundreds of API calls!!

I understand the main problem is Windows has the delightful habit of shuffling memory locations around with different software, and as with all computers one must also take care about poking memory addresses. So is there anyway one can determine the same address used by two languages at once, since they all have a SHELL option to run a programs created and compiled by another language. This would allow routines in one language, not available in another language, to generate data for another language.

Gordon
Gordon,

What you want to do is not very clear.

I think you want to share data between programs written in different languages.

If these programs don't need to be running simultaneously, a simple approach would be for them to share data via a common text-type file. Wouldn't that work for you?
*****
ah there no easy way to do what you want.

well there is a few big problem with what you want. namely that both liberty and BBC basic are win32 and windows does not allow for one program to access another programs address space.

next problem is QB can only access 640k of real mode memory which windows emulates kind of.

this makes interprogram communication from QB to another win32 program limited. the only easy ways to do it is via a file I/O and have the two program communicate that way via reading and writing to the same file.

the only other trick i know of is what victor did with Dsock. he wrote a system driver which runs at ring0 on windows meaning it has complete unrestricted access to the system memory which act as a type of communication bridge
Thanks Guys.

I think Moneo has the answer, if I can get each language to read an ASCII file created by another.

The reason for this is each language lacks certain commands found in another. LB does not have the equvalent of POINT(x,y) or PAINT(x,y) etc so you have to resort to API. Likwise BBC4W does not have an UPPER$ and Lower$ case change, so you need to create a routine. Thanks to the speed of modern hard drives it could be easier to Shell to another language.

Likewise since it fairly simple to create Windows Buttons, Boxes, Menus with LB, it might be usefull to create say a multi input Textbox using LB, then pass the inputs to an ASCII file to be read by QB, Far better than the terrible method of asking someone to use umpteen INPUTs.
You can also try VB. It has all the features you mention, plus the syntax is just QB's, and you are used to it.

Get VB3 pro from my signature, it should fit you. It comes with a very, very detailed help file (used in the same way as QB's, i.e. highlight command and press F1) and lots of examples.
Thanks,

I am probably now showing my ignorance, but having tried a demo version of VB some years ago, I came to conclusion it was more like 'C' than BASIC, needing far mor coding than BASIC.

Also I never like the DRAG and DROP method used to code, preferring the old fashioned way of typing in code.

Gordon
I beg to differ. VB is not like C. It's only like C in the same way that FB is like C. Anyway, I'd suggest using it too. It may take a little while to get used to it, but it would help IMO.
The syntax is exactly the same, I mean, I don't see how it looks like C.

This is a normal VB module:

Code:
Sub PrintText(sText As String)
    Dim i As Integer, j As Integer, sCurrWord As String

    Screen.MousePointer = vbHourglass

    'Initialize first page
    DoNewPage False

    'Print text, word-wrapping as we go
    i = 1

    Do Until i > Len(sText)

        'Get next word
        sCurrWord = ""

        Do Until i > Len(sText) Or Mid$(sText, i, 1) <= " "
            sCurrWord = sCurrWord & Mid$(sText, i, 1)
            i = i + 1
        Loop

        'Check if word will fit on this line

        If (Printer.CurrentX + Printer.TextWidth(sCurrWord)) > (Printer.ScaleWidth - m_MarginRight) Then
            'Send carriage-return line-feed to printer
            Printer.Print
            'Check if we need to start a new page

            If Printer.CurrentY > (Printer.ScaleHeight - m_MarginBottom) Then
                DoNewPage
            Else
                Printer.CurrentX = m_MarginLeft
            End If

        End If

        'Print this word
        Printer.Print sCurrWord;

        'Process whitespace and any control characters
        Do Until i > Len(sText) Or Mid$(sText, i, 1) > " "

            Select Case Mid$(sText, i, 1)
                Case " "        'Space
                    Printer.Print " ";

                Case Chr$(10)   'Line-feed
                    'Send carriage-return line-feed to printer
                    Printer.Print
                    'Check if we need to start a new page

                    If Printer.CurrentY > (Printer.ScaleHeight - m_MarginBottom) Then
                        DoNewPage
                    Else
                        Printer.CurrentX = m_MarginLeft
                    End If

                Case Chr$(9)    'Tab
                    j = (Printer.CurrentX - MARGIN_LEFT) / Printer.TextWidth("0")
                    j = j + (10 - (j Mod 10))
                    Printer.CurrentX = MARGIN_LEFT + (j * Printer.TextWidth("0"))

                Case Else       'Ignore other characters

            End Select
            i = i + 1
        Loop
    Loop

    Printer.EndDoc

    Screen.MousePointer = vbDefault

End Sub
Thanks Nathan,

But to an 'old codger' like me it looks a lot more complex that simple BASIC. When you get o my age you tend to shire away from a lot of new ideas.

Which expalins why I am scared stiff to use a Crredit Card online, or even use eBAy, eapecially with all the Spoof emails I get supposed to be coming form eBay and Paypal.

Gordon
Quote:Thanks Nathan,

But to an 'old codger' like me it looks a lot more complex that simple BASIC. When you get o my age you tend to shire away from a lot of new ideas.

Which expalins why I am scared stiff to use a Crredit Card online, or even use eBAy, eapecially with all the Spoof emails I get supposed to be coming form eBay and Paypal.

Gordon
You're not alone, Gordon. Being an oldtimer also, I have the same feelings.

Example: In 1975 I was responsible for all the software for Citibank's ATM cash dispenser network. I saw so many potential problems for the user that I did not use an ATM for the next 20 years.
*****