home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!munnari.oz.au!spool.mu.edu!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!usc!howland.reston.ans.net!paladin.american.edu!gatech!concert!rock!taco!csemail.cropsci.ncsu.edu!samodena
- From: samodena@csemail.cropsci.ncsu.edu (S. A. Modena)
- Subject: Re: BP7 and Turbovision Questions
- Message-ID: <1992Dec30.144242.19305@ncsu.edu>
- Summary: Event-driven programming is speak-easy
- Sender: news@ncsu.edu (USENET News System)
- Organization: Crop Science Dept., NCSU, Raleigh, NC 27695-7620
- References: <5212rn-@rpi.edu>
- Date: Wed, 30 Dec 1992 14:42:42 GMT
- Lines: 128
-
- In article <5212rn-@rpi.edu> pribik@aix.rpi.edu (Kristen Anne Pribis) writes:
- >The last time I programmed in Pascal I used TP 4.0. I recently
- >received BP 7.0 and am absolutely amazed at its capabilities.
- >I am slowly working my way through Turbo Vision, and have a
- >question. I would like a data entry window to be opened as
- >soon as the program starts, asking for the user to swipe a
- >credit card through a card reader (simulates keyboard input).
- >If the card is swiped through (the string ends with '?'), I
- >want to run a routine without the user having to hit enter or
- >any key. If the user presses F3, instead of swiping the card,
- >I would like to run another routine for manual entry.
- >
- >1) Where should I place the first window procedure? In the
- >Application Init constructor? Or can I simulate an event and
- >pass the simulated event (such as cmOpenInitWindow or
- >something) to the HandleEvent procedure?
-
- The last few lines of MyApp.Init should be something like:
-
- CONSTRUCTOR MyApp.Init;
- BEGIN
- ....
- INHERITED Init;
- .......
- NextEvent.What := evCommand;
- NextEvent.Command := cmRunCreditCardEntryRoutine;
- NextEvent.InfoPtr := @SELF;
- INHERITED PutEvent( NextEvent );
- END;
-
- This will be handled by:
- PROCEDURE MyApp.HandleEvent();
- BEGIN
- ..........
- cmRunCreditCardEntryRoutine:
- BEGIN
- SELF.RunCreditCardEntryRoutine;
- INHERITED ClearEvent( Event );
- END;
- cmRunTheManualEntryInputRoutineInstead:
- BEGIN
- SELF.RunTheManualEntryInpurRoutineInstead;
- INHERITED ClearEvent( Event );
- END;
- .....
- INHERITED HandleEvent( event );
- END;
-
- PROCEDURE MyApp.RunCreditCardEntryRoutine;
- BEGIN
- ....gory setup details....
- Result := DeskTop^.ExecView( MyCreditCardInputLineDialogP );
- IF ( Result <> cmCancel )
- THEN CASE Result OF
- cmOk: BEGIN
- ...gory details for credit card swipe....
- END;
- cmRunTheManualInputRoutineInstead:
- BEGIN
- NextEvent.What := evCommand;
- NextEvent.Command := Result;
- NextEvent.InfoPtr := @SELF;
- INHERITED PutEvent( NextEvent );
- END;
- END;
- END;
-
- >
- >2) How can I scan a data entry field for a '?' and then end data
- >entry once it receives the '?'?
-
- One way to do it:
-
- PROCEDURE MyCeditCardInputLineDialog.HandleEvent()
- BEGIN
- ....
- IF (( Event.What AND evKeyDown ) <> 0 )
- BEGIN
- CASE Event.KeyCode OF
- kbQuestionMark: Event.KeyCode := kbTab;
- kbF3: BEGIN
- INHERITED EndModal( cmRunTheManualInputRoutineInstead );
- INHERITED ClearEvent( Event );
- END;
- END;
- END;
- INHERITED HandleEvent( Event );
- END;
-
- >
- >3) If I'm scanning for a '?', can I still capture an F3 to run a
- >different routing?
-
- See above for details intertwined...
-
- >
- >The following is an example of a credit card swipe, but imagine
- >it all on a single line:
- >
- >%B5123456789012345^SMITH/JOE^951110112102OP/0000000000000000?
- >
- >The ^9511 is the expiration date - 11/95. The first string of
- >numbers is the credit card number.
- >
- >Any sample code would be greatly appreciated.
- >Replies can be posted here, but preferably mailed to me at
- >pribik@rpi.edu. Thanks in advance, and to all of those who
- >helped me with my async communications questions.
-
- This is an outline just off the top of my head.....which in event
- driven programming comes out being structured quite close to the
- way you expressed the problem. :^)
-
- I'll leave the implementation details to you. :^)
-
- Steve
- ---
- +------------------------------------------------------------------+
- | In person: Steve Modena AB4EL |
- | On phone: (919) 515-5328 |
- | At e-mail: nmodena@unity.ncsu.edu |
- | samodena@csemail.cropsci.ncsu.edu |
- | [ either email address is read each day ] |
- | By snail: Crop Sci Dept, Box 7620, NCSU, Raleigh, NC 27695 |
- +------------------------------------------------------------------+
- Lighten UP! It's just a computer doing that to you. (c)
- OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
-
-