Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing a class method
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00755091
Message ID:
00755167
Views:
9
>>>------------------------------
>>>I created a class (obs_web_import_timer), which has one control on it, a timer.
>>>When the timer event fires the timer checks a table for undeleted content.
>>>If it find any undeleted records, in creates records in my Orders.dbf, OrderItems.dbf and Location.dbf.
>>>When before creating the location record it needs a number for a unique ID. My DBC is called OFAX and in it I have a routine in my RI code called NextID. NextID is what I would use but when I try to use it I can't find it. So I created a class method called GetNextID, which has the same code in it as the RI code for NextID. Even tho I now have this as a PUBLIC method, I still can't find it.
>>>
>>>I must be calling it wrong.
>>>What would be the proper syntax?
>>>Is there a way to call the RI codes NextID?
>>>
>>>My next step would be to create a PRG for GetNextID, but that seems like a wrong solution.
>>>
>>>please help
>>>
>>>Rick
>>>------------------------------
>>
>>So, how are you attempting to call this new method you've created? Are you using Private DataSessions? Where was your timer class created? Is it in a different data session thean where the data resides?
>>
>>Lots more details are required to pin this down.
>-------------------------
>Hi Fred, thanks for trying to help.
>Here's the info you requested.
>
>I open the dbc when I start my app...do I need to do it again in the form I placed the timer on?
>
>The form has a private datasession and all the required tables are opened before this line of code is called.
>
>The timer, obs_web_import_timer, is in a class called OFAX.
>
>I created the class via the VFP project by going to the classes tab, selecting the OFAX class and clicking NEW.
>
>I've placed the timer/class on a form called hidden_timer. This is a modless form and the form's visilble property is set to .F. and the form is called with the NOSHOW option (DO FORM Hidden_Timer NOSHOW). I did this to allow the timer to have a Private Datasession.
>
>For all intents and purposes, all my forms use Private DataSessions with optimistic table buffering.
>
>I've tried calling the code I need like the following:
>m.L_ID = obs_web_import_timer.GetNextID("LOCATION")

This should work, but I bet it doesn't because the form is a Private Datasession form, and your timer object was more than likely created before the form was started, and therefore it lives in the VFP default datasession, different than the form's.

>m.L_ID = This.GetNextID("LOCATION") && why didn't this work???

Because the GetNextID method doesn't belong to whatever object that your trying to call it from. "this" refernces the ccurrent object, not your timer object.

>m.L_ID = ThisForm.GetNextID("LOCATION") && there is no form method

Similar to above. If you put the code in your base class form (you do use a base class form, don't you?) or even as a method on this particular form, that would solve the datasession issue.

>m.L_ID = GetNextID("LOCATION") && this is a class method

For a class method, it needs to be like your first line of code.

>m.L_ID = NextID("LOCATION") && this is in the RI
>
>Before I placed the timer on the form, I used to just instanciate to object during my main program's startup, and I used the last line
>m.L_ID = NextID("LOCATION")
>That seemed to work...
>
>but after I put it on the form it seemed to stop working

Once you put the timer on the form, that should also solve the datasession issues as the timer will now participate in the same datasession as the form. But what would change is how you reference the timer. It would now be "thisform.YourTimerObject.GetNextID("LOCATION")" instead of the direct object reference.

If you actually have the NEXTID code as a stored procedure to your database container, as long as the database is the current one, you should be able to call it with just NextID("LOCATION"), just like a regular program. Think of stored procedures in a database as being very similar to using a regular procedure file, you just don't need the SET PROCEDURE TO in order to find it, it should automatically included. I'd also suggest you look more closely at the TAZTRADER sample app if you have it in VFP5,6 or 7, it's no longer part of VFP8.

>
>I hope that helps, I really need to resolve this and move on!
>Thanks!
>Rick
>-----------------------------

Hope this helps!
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform