Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Visual FreePro -- New structured flow
Message
De
21/10/2013 12:47:39
 
 
À
21/10/2013 12:14:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01585957
Message ID:
01585967
Vues:
124
I like Flower and petals, more lively

>Note: Also posted on Foxite.
>
>-----
>I am creating a new structured flow control mechanism for Visual FreePro. I had originally wanted to call it "flow controller" or FLOWER for short, but my wife said it was too "girly" and that nobody would take me seriously. :-) So, I've changed the name to ROPE..ENDROPE.
>
>It is designed to be more advanced than a TRY..CATCH..ENDTRY block (of which I've actually done away with in Visual FreePro in support of this new format).
>
>Other suggestions have been FLOW..ENDFLOW, with each PLATFORM being a SPIGOT. I am willing to entertain other suggestions.
>
>Consider the following as a logical progression of new abilities added. Please ask any questions:
>
>
**********
>* Traditional code block -- exiting all the way out from an inner loop
>*****
>    llBigExit = .F.
>    SELECT myTable
>    SCAN
>        FOR lnI = 1 TO 10
>            IF someTestOnThisData(lnI)
>                llBigExit = .T.
>                WAIT WINDOW "It was found!"
>                EXIT
>            ENDIF
>        NEXT
>        IF llBigExit
>            EXIT
>        ENDIF
>    ENDSCAN
>    IF NOT llBigExit
>        WAIT WINDOW "Sorry, Charlie!"
>    ENDIF
>
>
>**********
>* Visual FreePro's ROPE..ENDROPE structured flow for exiting all the way out
>* with the single SWING OUT command, which continues on after the ENDROPE.
>* Note also that no EXIT command is needed to exit a ROPE..ENDROPE block.
>*****
>    ROPE
>        SELECT myTable
>        SCAN
>            FOR lnI = 1 TO 10
>                IF someTestOnThisData(lnI)
>                    WAIT WINDOW "It was found!"
>                    SWING OUT
>                ENDIF
>            NEXT
>        ENDSCAN
>        WAIT WINDOW "Sorry, Charlie!"
>    ENDROPE
>    * Control continues here after SWING OUT command
>
>
>**********
>* An extended ability to SWING TO a specific destination, yet in a structured
>* manner.
>*
>* Note: One of the purposes of adding this ability was to document major code
>*       blocks in one specific area (near the end of the ROPE..ENDROPE block),
>*       thereby bringing important algorithms out of interspersed, nested code,
>*       and into more centralized, easily sought after areas.
>*****
>    ROPE
>        SELECT myTable
>        SCAN
>            FOR lnI = 1 TO 10
>                IF someTestOnThisData(lnI)
>                    SWING TO foundIt
>                ENDIF
>            NEXT
>        ENDSCAN
>        SWING TO notFound
>
>    PLATFORM foundIt
>        WAIT WINDOW "It was found!"
>
>    PLATFORM notFound
>        WAIT WINDOW "Sorry, Charlie!"
>
>    ENDROPE
>    * Control continues here after each platform code block is run
>
>
>**********
>* Adding FUNCTION definitions to a ROPE..ENDROPE block, as you
>* would any program.  These are in addition to ADHOC..ENDADHOC function
>* blocks, which can also be added anywhere.
>*
>* Note: The same note above is added for functions, as this helps with
>*       encapslation, such that related functions are included within the
>*       ROPE..ENDROPE block, also aiding with documentation, debugging, and
>*       code maintenance.
>*****
>    ROPE
>        SELECT myTable
>        SCAN
>            FOR lnI = 1 TO 10
>                IF someTestOnThisData(lnI)
>                    SWING TO foundIt
>                ENDIF
>            NEXT
>        ENDSCAN
>        SWING TO notFound
>
>    FUNCTION showMessage
>    LOBJECT po AS (pcMessage AS Character)
>        WAIT WINDOW pcMessage
>
>    PLATFORM foundIt
>        showMessage("It was found!")
>
>    PLATFORM notFound
>        showMessage("Sorry, Charlie!")
>
>    ENDROPE
>    * Control continues here after each platform code block is run
>
>
>**********
>* Adding ERROR handling to a ROPE..ENDROPE block
>* Note: The new ERROR block at the end is called instead of any
>*       ON ERROR or class Error() events.  A future support will
>*       allow for explicit number handling as in "ERROR nCode"
>*       so that multiple ERROR blocks can be added, one for each
>*       type of known error.
>*****
>    ROPE
>        SELECT myTable
>        SCAN
>            FOR lnI = 1 TO 10
>                IF someTestOnThisData(lnI)
>                    SWING TO foundIt
>                ENDIF
>            NEXT
>        ENDSCAN
>        SWING TO notFound
>
>    FUNCTION showMessage
>    LOBJECT po AS (pcMessage AS Character)
>        WAIT WINDOW pcMessage
>
>    PLATFORM foundIt
>        showMessage("It was found!")
>
>    PLATFORM notFound
>        showMessage("Sorry, Charlie!")
>
>    ERRROR thisCodeOfError
>        ERRORMESSAGEBOX(thisCodeOfError)   && Show Visual FreePro standard error message handler
>
>    ENDROPE
>    * Control continues here after each platform code block is run
>
>
>**********
>* Adding simple MESSAGE handling to a ROPE..ENDROPE block.  In this
>* example, the called function is used to spawn control flow in this
>* ROPE..ENDROPE block, and that's based upon its known return results.
>* This removes the requirement of us testing the result here, as our
>* program can simply act on it.  The new MEMA keyword indicates that
>* this source code line will respond to the RETURN MESSAGE command
>* flow control, and automatically SWING TO the MESSAGE code block.
>* The MESSAGE code block receives as a named parameter the thisCode
>* object of whatever triggered the MESSAGE. In this case, it would be
>* the thisCode object pointing to the source code line with MEMA on it.
>*****
>    ROPE
>        SELECT myTable
>        SCAN
>            FOR lnI = 1 TO 10
>                * The following function is shown below.
>                * It uses the new RETURN MESSAGE command.
>                someTestOnThisData(lnI) MEMA
>            NEXT
>        ENDSCAN
>        SWING TO notFound
>
>    FUNCTION someTestOnThisData
>    LOBJECT po AS (pnCount AS Integer)
>        IF SUBSTR(cName, pnCount, 4) == "rick"
>            RETURN MESSAGE "It was found!"
>        ENDIF
>
>    FUNCTION showMessage
>    LOBJECT po AS (pcMessage AS Character)
>        WAIT WINDOW pcMessage
>
>    PLATFORM notFound
>        showMessage("Sorry, Charlie!")
>
>    MESSAGE msg
>    * Note:  The thisCode object has an _m1 member which is the first
>    *        parameter of the returned message. _m2 continues on, _m3,
>    *        _m4, and so on.  Each of these is sticky and persist until
>    *        another RETURN MESSAGE command is encountered.
>        showMessage(msg._m1)
>
>    ENDROPE
>    * Control continues here after each platform code block is run
>
>
>**********
>* Adding a more advanced MESSAGE handler to a ROPE..ENDROPE block.  In
>* this example, the called function is able to spawn flow control based
>* upon its known return results. The MEMA SWING TO command is used to
>* swing to a specific platform destination by name.  In this case we
>* know the called function will return a message if the item is found.
>* As such, we trigger off of that condition automatic flow control.
>*****
>    ROPE
>        SELECT myTable
>        SCAN
>            FOR lnI = 1 TO 10
>                * The following function is shown below.
>                * It uses the new RETURN MESSAGE command.
>                someTestOnThisData(lnI) MEMA SWING TO foundIt WITH thisCode._m1
>            NEXT
>        ENDSCAN
>        SWING TO notFound
>
>    FUNCTION someTestOnThisData
>    LOBJECT po AS (pnCount AS Integer)
>        IF SUBSTR(cName, pnCount, 4) == "rick"
>            RETURN MESSAGE "It was found!"
>        ENDIF
>
>    FUNCTION showMessage
>    LOBJECT po AS (pcMessage AS Character)
>        WAIT WINDOW pcMessage
>
>    * Here we see that the destination PLATFORM can receive parameters like a function.
>    PLATFORM foundIt
>    LOBJECT po AS (pcMessage AS Character)
>        showMessage(pcMessage)
>
>    PLATFORM notFound
>        showMessage("Sorry, Charlie!")
>
>    ENDROPE
>    * Control continues here after each platform code block is run
>
>
>**********
>* Had I gone with the flow controller, or FLOWER definition, it would
>* have been like this instead of ROPE..ENDROPE (picture a bee flying
>* about a flower).
>*
>* What do you think?  Too girly? :-)  I actually like this because it
>* would be very hard to not be enjoying writing code when in your mind
>* you're flying around flowers. :-)
>*****
>    FLOWER
>        * Normal programming goes here
>        FLY TO cPetalName   && Instead of "swing to" the bee would "fly to"
>
>    PETAL cPetalName
>    LOBJECT po AS (pcParam1 AS Character, pnParam2 AS Integer)
>
>    FUNCTION cFunctionName
>    LOBJECT po AS (pcParam1 AS Character, pnParam2 AS Integer)
>    RETURNS llResult
>
>    MESSAGE
>
>    ERROR
>
>    ENDFLOWER
>
>
>Please provide any thoughts or comments.
Thierry Nivelet
FoxinCloud
Give your VFP application a second life, web-based, in YOUR cloud
http://foxincloud.com/
Never explain, never complain (Queen Elizabeth II)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform