Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
_assign and return
Message
From
12/11/2003 05:13:02
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
11/11/2003 22:16:50
Arnold Lee
K&A International Co.,Ltd
Hong Kong, Hong Kong
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00848959
Message ID:
00849010
Views:
24
>Hi Everybody
>
>I want to exit from method of a class once a property has something inside by using _assign method.What is the practice from getting out of current method and return the error message ?
>
>Any help is highly appreciated. Thanks
>
>MM = CREATEOBJECT("CAR_PARK")
>? MM.TEST_DRIVE()
>Sorry.Full ! <---- Returned message
>
>DEFINE CLASS CAR_PARK AS SESSION OLEPUBLIC
> ERROR_MESSAGE = ""
>
> PROCEDURE ERROR_MESSAGE_ASSIGN
> LPARAMETERS vNewVal
> THIS.ERROR_MESSAGE = m.vNewVal
> IF .NOT.EMPTY(THIS.ERROR_MESSAGE)
> RETURN THIS.ERROR_MESSAGE TO MASTER <- ???????????? Pls enlighting me
> ENDIF
> ENDPROC
>
> PROCEDURE TEST_DRIVE
> THIS.ERROR_MESSAGE = "Sorry.Full !"
>
> Execution terminated
> Blah...Blah...Blah...
> ENDPROC
>ENDDEFINE

Arnold,
Caller should decide what to do when a result returns to it, not the class method itself. Otherwise you wouldn't be encapsulating and decrease the reusability of class.

ie:
MM = CREATEOBJECT("CAR_PARK")
lnResult = MM.TEST_DRIVE() 
if lnResult < 0 && Error occurred
  messagebox(mm.Error_Message)
*...

   * assuming success return value is a positive numeric
   PROCEDURE TEST_DRIVE 
      THIS.ERROR_MESSAGE = "Sorry.Full !"
      return -1 && Return a negative value indicating error
*...
   ENDPROC
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform