LB Booster
« Problem with a Cheetah function »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:34am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Problem with a Cheetah function  (Read 252 times)
Jack Kelly
Full Member
ImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 106
xx Problem with a Cheetah function
« Thread started on: Sep 9th, 2016, 08:26am »

Richard,

First I want to say that everything you said about "wrappers" is true. They're probably not necessary, and are rarely supported. However, I don't have sufficient documentation or expertise to access Cheetah2.dll directly. Walt Decker's LB dll wrapper has been working sufficiently well for me up to this point. I am hoping you can give this problem some thought before I go looking for Walt, or post on the LB forum.

I cannot get any output from ""DBADDDATE". It doesn't generate an error, but always returns an empty string. Two other date functions have been working correctly. I know this is outside your large area of responsibility, but any suggestions will be much appreciated. Let me know if you don't have the two Cheetah dll files handy.

Thanks,
Jack

Code:
open "LBcheetah2.dll" for dll as #DBF
print "DBaddDate$(=|"; DBaddDate$("20151231", 5); "|"
print DBdaysApart("20151231", "20160105")
[ProgramEnd]
print "Program ended."
end

function DBaddDate$(StartDate$, Days)
    StartDate$ = trim$(StartDate$) + chr$(0)
    CallDll #DBF, "DBADDDATE", StartDate$ AS PTR, AddDate$ AS PTR, _
            Days AS LONG, Result AS VOID
' "DBADDDATE", StartDate$ AS PTR, AddDate$ AS PTR,Days AS LONG, Result AS VOID
' (from LBCheat.INC.BAS)
    if DBerror("DBADDDATE") then goto [ProgramEnd]
    DBaddDate$=stripped$(AddDate$)
end function

function DBdaysApart(DateFrom$, DateTo$)
    DateFrom$ = trim$(DateFrom$) + chr$(0)
    DateTo$ = trim$(DateTo$) + chr$(0)
    CallDll #DBF,  "DBDAYSAPART", DateFrom$ AS PTR, DateTo$ AS PTR, _
            DBdaysApart AS LONG
    if DBerror("DBDAYSAPART") then goto [ProgramEnd]
end function

function DBerror(ErrorNote$)
    CallDll #DBF, "DBERROR", ErrorCode as Long
    select case ErrorCode
        case 0
            DBerror=0
            exit function
        case else
            notice "DB Error "+str$(ErrorCode)+chr$(13)+ErrorNote$
            DBerror=ErrorCode
    end select
    CallDll #DBF,"DBRESETERROR", result as Void
end function

function stripped$(a$)
    a$=trim$(a$)
        if right$(a$,1)=chr$(0) then a$=left$(a$,len(a$)-1)
    stripped$=trim$(a$)
end function
 
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Problem with a Cheetah function
« Reply #1 on: Sep 9th, 2016, 08:55am »

on Sep 9th, 2016, 08:26am, Jack Kelly wrote:
I cannot get any output from ""DBADDDATE". It doesn't generate an error, but always returns an empty string.

That appears to be because you don't allocate any memory to hold the returned string! Look at this code:

Code:
    StartDate$ = trim$(StartDate$) + chr$(0)
    CallDll #DBF, "DBADDDATE", StartDate$ AS PTR, AddDate$ AS PTR, _
            Days AS LONG, Result AS VOID 

StartDate$ is (I presume) an input to the function and AddDate$ is the output from the function. That means you must initialize AddDate$ to a dummy string (it doesn't matter what it contains) which is at least as long as the longest string that can ever be returned from the function. Something like this:

Code:
    StartDate$ = trim$(StartDate$) + chr$(0)
    AddDate$ = space$(MAX.DATE.LENGTH) + chr$(0)
    CallDll #DBF, "DBADDDATE", StartDate$ AS PTR, AddDate$ AS PTR, _
            Days AS LONG, Result AS VOID 

That should hopefully fix the problem. Here I'm assuming that MAX.DATE.LENGTH is a global constant.

Richard.
User IP Logged

Jack Kelly
Full Member
ImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 106
xx Re: Problem with a Cheetah function
« Reply #2 on: Sep 9th, 2016, 12:29pm »

Thanks Richard, that did the trick! Thank you again, for the umpteenth time!
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls