1. RE: Tsunami Record Manager

My attention was brought to this thread by an interested party who 
"suggested" that the author of the Tsunami Record Manager (that would be 
me) should contribute a little time to help produce a Euphoria 
interface. I agreed.

I downloaded a copy of Euphoria (very nice language, btw) and took the 
first step by writing the following code to get things started. Not 
being familiar with the Euphorian way of doing things, I'm reluctant to 
push forward until some of you more experienced EUgurus bless or curse 
this first step. Am I headed in the right direction, or are there better 
ways to this?

If anyone is interested in testing this, please get the latest TRM.DLL 
from the download page at www.trm-ug.com (ver 2.3). This code snippet 
looks for the trmdemo.dat file, which is a Tsunami data file created by 
running the Tsunami PowerBASIC demo on our site. I'd also recommend 
downloading the TRM.PDF file from the PowerBASIC section of our download 
page.

Timm Motl
Tsunami Users Group
Advantage Systems


-- Tsunami test -----------------------------------------------------

-- requires TRM.DLL and trmdemo.dat

include msgbox.e

procedure WinMain()

    atom trm,
         trm_Op,
         trm_File,
         trm_DataPtr,
         trm_DataLen,
         trm_KeyPtr,
         trm_KeyLen,
         trm_KeyNo

    sequence fileName

    atom fileNameAddress,
         result,
         total

    trm = define_c_func(open_dll("TRM.DLL"), "trm", {C_INT, C_INT, 
C_INT, C_INT, C_INT, C_INT, C_INT}, C_INT)

    if trm = -1 then

        result = message_box("Couldn't find TRM.DLL", "Error", MB_OK)

    else

        -- designate the Tsunami file name (and optional path)

        fileName = "Trmdemo.dat"

        fileNameAddress = allocate_string(fileName)

        -- initialize the call parameters to 4 bytes each

        trm_Op      = allocate(4)
        trm_File    = allocate(4)
        trm_DataPtr = allocate(4)
        trm_DataLen = allocate(4)
        trm_KeyPtr  = allocate(4)
        trm_KeyLen  = allocate(4)
        trm_KeyNo   = allocate(4)

        -- set the necessary parameters for a call to trm_Open

        poke4(trm_Op, 0) -- trm_Open = 0
        poke4(trm_KeyPtr, fileNameAddress)
        poke4(trm_KeyLen, length(fileName))

        result = c_func(trm, {trm_Op,
                              trm_File,
                              trm_DataPtr,
                              trm_DataLen,
                              trm_KeyPtr,
                              trm_KeyLen,
                              trm_KeyNo})
        if result then

            result = message_box("trm_Open ... Result code = " & 
sprint(result), "Error", MB_OK)

        else

            -- trm_File now holds the Tsunami file handle
            -- set the operation parameter for a call to trm_Count

            poke4(trm_Op, 17) -- trm_Count = 17

            result = c_func(trm, {trm_Op,
                                  trm_File,
                                  trm_DataPtr,
                                  trm_DataLen,
                                  trm_KeyPtr,
                                  trm_KeyLen,
                                  trm_KeyNo})
            if result then

                result = message_box("trm_Coumt ... Result code = " & 
sprint(result), "Error", MB_OK)

            else

                -- display the record count (returned in trm_KeyNo)

                total = peek4s(trm_KeyNo)

                result = message_box(fileName & " contains " & 
sprint(total) & " records", "Tsunami Test", MB_OK)

            end if

        end if

    end if

    -- no need to call trm_Close...
    -- Tsunami closes all open files upon exit

end procedure WinMain()

new topic     » topic index » view message » categorize

2. RE: Tsunami Record Manager

euman at bellsouth.net wrote:

> I welcome you to Euphoria!

Thanks for the welcome and for offering to work up Euphoria wrappers for 
Tsunami. You know, the more I look at Euphoria, the more I like it. It 
has a unique elegance that's very appealing.

I look forward to seeing the wrappers! If I can be of any help, please 
don't hesitate to ask.

Timm Motl
Tsunami Users Group
Advantage Systems

new topic     » goto parent     » topic index » view message » categorize

3. RE: Tsunami Record Manager

Elliott Sales de Andrade wrote:
> 
> 
> Ok, so I almost wrapped this library. But i have one problem. What is a 
> QUAD? I know what all the other types are and what to put them in as but 
> 
> Euphoria doesn't seem to have a tye for a QUAD. If anyone knows how it 
> should work, could you tell me?
> 
> 
A quad is a value 8 bytes long ( or 64 bits in size ).
That value is returned by some functions as the record number
in the database. So you have to wrap it so euphoria can grab
a returned value that is 8 bytes long. The only way you might
get away using it is a double float value; but if you read the
databse docs you will see that errors are returned as negative
numbers and record numbers are returned as positive numbers
which may cause a problem using these 64 bit numbers.
Good luck:
Bernie

new topic     » goto parent     » topic index » view message » categorize

4. RE: Tsunami Record Manager

On 25 Jan 2002, at 23:16, Bernie Ryan wrote:

> 
> 
> Elliott Sales de Andrade wrote:
> > 
> > 
> > Ok, so I almost wrapped this library. But i have one problem. What is a 
> > QUAD? I know what all the other types are and what to put them in as but 
> > 
> > Euphoria doesn't seem to have a tye for a QUAD. If anyone knows how it 
> > should work, could you tell me?
> > 
> > 
> A quad is a value 8 bytes long ( or 64 bits in size ).
> That value is returned by some functions as the record number
> in the database. So you have to wrap it so euphoria can grab
> a returned value that is 8 bytes long. The only way you might
> get away using it is a double float value; but if you read the
> databse docs you will see that errors are returned as negative
> numbers and record numbers are returned as positive numbers
> which may cause a problem using these 64 bit numbers.

Could it be accepted by Eu as an object, and then read as a sequence, and 
turned into a number with string math?

Kat

new topic     » goto parent     » topic index » view message » categorize

5. RE: Tsunami Record Manager

I used the VB DLL, but I am still having that problem also.
 It's almost always the same error:

     The instuction at 00a2c0e2 referenced memory at 00000001
     The memory could not be read from.
Sometimes its 00000000 instead of 00000001.

[Offtopic]
If anyone is still wondering, I didn't get this message and another 
reply from Markus Vedder-Kemnitzer. And Bernie's came really late, too.


rossboyd at ihug.com.au wrote:
> > Ok, so I almost wrapped this library. But i have one problem. What is
> a
> > QUAD? I know what all the other types are and what to put them in as
> but
> > Euphoria doesn't seem to have a tye for a QUAD. If anyone knows how it
> > should work, could you tell me?
> 
> 
> To get around the problem of the QUAD, download the trm_vb.dll from
> their site.
> Its a wrapper for all the functions which require returning or passing a
> QUAD.
> 
> I've been trying to get it to work myself but am having trouble with
> calling trm_Open() in trm.dll.
> 
> Perhaps someone here can help????????
> 
> This is the VB declaration.
> ~~~~~~~~~~~~~~~~~~
> Declare Function trm_Open Lib "TRM.DLL"  (PathFileName As String,
> MultiUser As Long) As Long
> 
> Here's my code.... what am I doing wrong?
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include machine.e
> include dll.e
> 
> atom trm,trm_vb ,trm_Loaded, trm_Open ,lpcstr ,hFile, mode
> 
> trm = open_dll("trm.dll")
> trm_vb = open_dll("trm_vb.dll")
> if trm = 0 or trm_vb = 0 then
>     puts(1, "Couldn't open the dlls!\n")
>     abort(1)
> end if
> 
> trm_Loaded = define_c_func(trm_vb, "trm_Loaded" ,{}, C_LONG)
> trm_Open  = define_c_func(trm, "trm_Open" ,{C_POINTER, C_LONG}, C_LONG)
> 
> if c_func(trm_Loaded,{}) = 0 then
>     puts(1, "Not Loaded!\n")
>     abort(1)
> end if
> 
> lpcstr = allocate_string("trmdemo.dat")
> mode = 0
> 
> -- it produces an application error on this call...
> hFile = c_func(trm_Open,{lpcstr, mode})
> puts(1,"If you can read this, it worked...\n")
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu