Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ON ERROR calls in FORMS
Message
De
05/08/1997 08:56:29
 
 
À
04/08/1997 22:39:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00043158
Message ID:
00043202
Vues:
42
>I'm trying to adapt a FoxPro 2.6a program to a VFP5a form and I can't get a handle
>on the ON ERROR command. I'm using Graphics Server, a 3rd-party graphing library,
>to create polygons of every state in the U.S. In FPW 2.6, I have an ON ERROR DO NOTHING
>error routine that goes to the procedure, NOTHING, and returns without doing anything.
>
>I have to do this in case there is a call to a nonexistant state polygon procedure. The
>program would bomb out otherwise. I can't seem to get this to work in a VFP5 form.
>
>How do I go about doing this? The state polygon procedures I mentioned above are now
>methods in the form. Listed below is the CLICK method - everything works except the ON
>ERROR call.
>
>*:===============================================
>*: Object: cmdMap
>*: E/M: CLICK
>*: Purpose: Draws state polygons when user
>*: clicks the Redraw Map command
>*: button.
>*:===============================================
>r=GSUseView(THISFORM.oleMap.NWin,0) && Make sure we are using the correct GS View.
>THISFORM.oleMap.Background = 7 && Assign gray to background color.
>THISFORM.oleMap.GraphType = 0 && Do not display the default graph.
>THISFORM.oleMap.DRAWMODE = 1 && Clear the view.
>THISFORM.SplitSet() && Call method assigning default coordiates.
>
>ON ERROR DO THISFORM.Nothing && Call dummy error handler method so we won't
>*: bomb out when calling nonexistent methods.
>
>SELECT states && Go to the STATES table workarea.
>
>SCAN && Scan the entire STATES table.
> IF BETWEEN(terr,"5","6") AND SUBSTR(stcode,3,1)="0" && For testing, limit call to state borders in the
>*: WEST and SOUTH territories.
> cMapPoly = "THISFORM.ST"+states.stcode+"()" && Create a string for the method call.
> &cMapPoly && Call the method containing the state polygon array.
> DIMENSION aNewState[ALEN(THISFORM.aMap,1),2] && Redimension the array used by Graphics Server.
> =ACOPY(THISFORM.aMap,aNewState) && Copy the state polygon array data to the GS array.
> =GSFixPos(THISFORM.aFixPos[1,1],THISFORM.aFixPos[2,1]) && Fix the XY positions in the GS view.
> =GSDataDim(ALEN(aNewState,1),2) && Establish the data dimensions for GS.
> =GSDataAmp(ALEN(aNewState,1),2,@aNewState[1,1]) && Send the data to GS.
> =GSPolyFill(0,0,0,0,0,6) && Draw a polygon with the array's dimensions.
> =GSPolyVec(0,0,0,0,0,0) && Draw a line around the polygon.
> DO CASE
> CASE stcode = "580" && If the state is US Virgin Islands,
> FOR lnSupp = 1 TO 2 && draw supplemental polygons (numerous islands).
> cSupp = ALLTRIM(STR(lnSupp,1,0))
> cMapPolyPlus = SUBSTR(cMapPoly,1,LEN(cMapPoly)-2)+cSupp+"()"
> &cMapPolyPlus
> DIMENSION aNewState[ALEN(THISFORM.aMap,1),2]
> =ACOPY(THISFORM.aMap,aNewState)
> =GSFixPos(THISFORM.aFixPos[1,1],THISFORM.aFixPos[2,1])
> =GSDataDim(ALEN(aNewState,1),2)
> =GSDataAmp(ALEN(aNewState,1),2,@aNewState[1,1])
> =GSPolyFill(0,0,0,0,0,6)
> =GSPolyVec(0,0,0,0,0,0)
> ENDFOR
> CASE stcode = "110" && If the state is Hawaii,
> FOR lnSupp = 1 TO 7 && draw supplemental polygons (numerous islands).
> cSupp = ALLTRIM(STR(lnSupp,1,0))
> cMapPolyPlus = SUBSTR(cMapPoly,1,LEN(cMapPoly)-2)+cSupp+"()"
> &cMapPolyPlus
> DIMENSION aNewState[ALEN(THISFORM.aMap,1),2]
> =ACOPY(THISFORM.aMap,aNewState)
> =GSFixPos(THISFORM.aFixPos[1,1],THISFORM.aFixPos[2,1])
> =GSDataDim(ALEN(aNewState,1),2)
> =GSDataAmp(ALEN(aNewState,1),2,@aNewState[1,1])
> =GSPolyFill(0,0,0,0,0,6)
> =GSPolyVec(0,0,0,0,0,0)
> ENDFOR
> ENDCASE
> ENDIF
>ENDSCAN
>THISFORM.BorderAbbv() && Call the method placing state abbreviations on polygons.
>ON ERROR && Close the ON ERROR routine.

VFP doesn't like to have Thisform as part of ON ... commands. You can either put procedure NOTHING into system procedure file and issue ON ERROR DO Nothing, or use direct reference to form: ON ERROR frmPolygon.DoNothing
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform