Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
COM Object (ADSI) Error Trapping?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00489229
Message ID:
00489462
Vues:
8
Steve,
You don't really want to ignore the error completely. You just want to trap it. Your ON ERROR could be ON ERROR lError = .T.. Check that flag before you run the FOR...ENDFOR loop. You could also check the datatype of oGroup to make sure it's an object before processing it. From the looks of things, your ON ERROR made VFP ignore at least three errors (OLE and oGroup is not an object twice).

As for writing classes with Error events, you can do this fairly easily using the Class Designer and selecting something like Custom. All the pre-fabricated PEMs are there and Error happens to be one of them. Whenever an error occurs within the code executing in the class, the Error event will fire.

If you create classes in PRG code using DEFINE CLASS, just add the following in the class definition:
PROCEDURE ERROR
LPARAMETERS nError, cMethod, nLine

ENDPROC
Add whatever code you want in it. The parameter statement must be there becuase this is the information VFP passes along when an error occurs.

HTH.

>Well, right after the "Scan" line in my code, I had
On Error *
in order to get VFP to ignore the OLE error. But what happened then was the scan kept going, so instead of the proper result of
>
>Steve = lvl3
>
>I got
>
>Steve = lvl3
>Steve = lvl4
>
>I'm interested in putting this into a class with an error event, but I've never done that before. :) Could you pass me some quick info on how to do that?
>
>Thanks.
>
>
>
>
>>What doesn't work about ON ERROR? An alternative is to program this functionality into a class and have an Error event. You have to trap for OLE errors (usually 1426 - 1428).
>>
>>HTH.
>>
>>>I am having a little trouble with error trapping/handling with ADSI in my .prg.
>>>
>>>0. I created some dummy local user accounts.
>>>1. I created 3 local groups on my NT4 box called lvl1, lvl2, lvl3 and put a user in each.
>>>2. I created a .dbf called AccessMap which has a list of local groups that should be queried for membership.
>>>
>>>I am now scanning through AccessMap, looking for a match between my user name and the local group I belong to. I have 4 rows in the table, but only 3 local groups, so when I get to "lvl4" in my table, VFP says:
>>> OLE error code 0x800708ac: Unknown COM status code.
>>>What's the best way to trap this kind of OLE error? I originally did "On Error *" but that's just sloppy and doesn't work right anyway. Help?
>>>
>>>
>>>cAccount = "Steve"
>>>Select AccessMap
>>>Scan
>>>oGroup = GetObject("WinNT://" + "SCraft" + "/" +AllTrim(cGroupName) )
>>>For Each oAcct in oGroup.Members
>>>If Upper(oAcct.Name) = Upper(cAccount)
>>>? oAcct.Name + " = " + cGroupName
>>>EndIf
>>>Next
>>>EndScan
>>>
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform