Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Library problem - please help!!!

Status
Not open for further replies.

teamakesmefart

Technical User
Dec 3, 2003
10
GB
Hi All

I am using Paradox 9 and am having trouble calling a custom procedure from a library.

The library is called sisUtils and has a custom procedure called sqlDate in its Proc method like so:

Proc sqlDate(var inDate Date) String
blah
blah
return String(outDate)
endProc


This compiles OK.

From my calling form, I have placed the following in the Var method:

var
lib Library
endVar

In the calling form, I have placed the following in the Uses method:

Uses ObjectPAL
sqlDate (var inDate Date) String
endUses


The calling form has the following in its Open method:

method open(var eventInfo Event)
if eventInfo.isPreFilter() then
;// This code executes for each object on the form
else
;// This code executes only for the form
msgInfo("Opening", "Opening sisUtils library")
if lib.open("sisUtils") then
message("sisUtils library was opened successfully")
else
message("Unable to open the sisUtils library")
endif
endIf
endMethod


I then try to call the custom method in the pushButton event of a button on the calling form

method pushButton(var eventInfo Event)
var
inDate Date
outDate String
endVar

inDate = Date()
outDate = lib.sqlDate(inDate)
msgInfo("Return from sqlDate is ...", outDate)
endMethod

When I run the form, I get the msgInfo box saying that its trying to open the Library, and the status bar changes to say that the library was successfully opened (as per the form's Open method).

When I click on the button to instigate the call to the custom procedure, I get an error dialogue which says: "The method, 'SQLDate(var Date) String' is not visible from the object, '#Library1'.

Why?? Please, please help!!

Thanks in advance
Pete Wright
 
Pete,

I think the "var" is giving you the trouble, try removing it and I think you will be ok.

;Proc sqlDate(var inDate Date) String
Proc sqlDate(inDate Date) String
blah
blah
return String(outDate)
endProc

Uses ObjectPAL
; sqlDate (var inDate Date) String
sqlDate (inDate Date) String
endUses

Perrin
 
Kliot

Many thanks for your reply.

I have tried as you suggest, but unfortunately I still have the error (slightly re-worded now: "The method, 'SQLDate(Date) String' is not visible from the object, '#Library1'".

The var in the declaration ensures that an instance of the Date class is created if not passed with the call. This enables the procedure to work even if the required paramater is not passed (because the first thing I do is evaluate the incoming paramater and set it to a default value if it isn;t received).

I don't suppose you have any further ideas?


Many thanks
Pete
 
Hi Pete -

If I remember right, you can't call a library's proc from outside the library, that's why the error box's saying it can't see it. Only a library method can be called from outside a library. Only a library method can "see" a library proc.

You could "copy and paste" the code into a new method, or you could make a new one who's only function is to accept the incoming data and feed the results back: this libary method could access the library proc. Your form would then call this new method.

Hope this works,
Bill
 
Pete,

Bill and Perrin are correct; one of the differences between procedures and methods in ObjectPAL is that methods can be called from outside the containership chain while procedures are local to the document they're declared in.

In general, you'll want to use methods more than procedures for this very reason, however, procs do have an advantage over methods. They don't clear the error stack and I'm in the process of writing an article for my site that shows one way to use this behavior effectively.

In any event, convert your procedure to a method and I believe you'll see your problems disappear.

Also, don't forget to save your library after each change; otherwise, your calling forms won't be able to see your changes.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top