home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / pascal / 7732 < prev    next >
Encoding:
Text File  |  1992-12-30  |  4.7 KB  |  141 lines

  1. Newsgroups: comp.lang.pascal
  2. 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
  3. From: samodena@csemail.cropsci.ncsu.edu (S. A. Modena)
  4. Subject: Re: BP7 and Turbovision Questions
  5. Message-ID: <1992Dec30.144242.19305@ncsu.edu>
  6. Summary: Event-driven programming is speak-easy
  7. Sender: news@ncsu.edu (USENET News System)
  8. Organization: Crop Science Dept., NCSU, Raleigh, NC 27695-7620
  9. References: <5212rn-@rpi.edu>
  10. Date: Wed, 30 Dec 1992 14:42:42 GMT
  11. Lines: 128
  12.  
  13. In article <5212rn-@rpi.edu> pribik@aix.rpi.edu (Kristen Anne Pribis) writes:
  14. >The last time I programmed in Pascal I used TP 4.0.  I recently 
  15. >received BP 7.0 and am absolutely amazed at its capabilities.  
  16. >I am slowly working my way through Turbo Vision, and have a 
  17. >question.  I would like a data entry window to be opened as 
  18. >soon as the program starts, asking for the user to swipe a 
  19. >credit card through a card reader (simulates keyboard input).  
  20. >If the card is swiped through (the string ends with '?'), I 
  21. >want to run a routine without the user having to hit enter or 
  22. >any key.  If the user presses F3, instead of swiping the card, 
  23. >I would like to run another routine for manual entry.
  24. >
  25. >1) Where should I place the first window procedure?  In the 
  26. >Application Init constructor?  Or can I simulate an event and
  27. >pass the simulated event (such as cmOpenInitWindow or 
  28. >something) to the HandleEvent procedure?
  29.  
  30. The last few lines of MyApp.Init should be something like:
  31.  
  32. CONSTRUCTOR MyApp.Init;
  33.     BEGIN
  34.         ....
  35.         INHERITED Init;
  36.     .......    
  37.     NextEvent.What := evCommand;
  38.     NextEvent.Command := cmRunCreditCardEntryRoutine;
  39.     NextEvent.InfoPtr := @SELF;
  40.     INHERITED PutEvent( NextEvent );
  41.     END;
  42.  
  43. This will be handled by:
  44.     PROCEDURE MyApp.HandleEvent();
  45.         BEGIN
  46.                 ..........
  47.         cmRunCreditCardEntryRoutine: 
  48.             BEGIN
  49.             SELF.RunCreditCardEntryRoutine;
  50.             INHERITED ClearEvent( Event );
  51.             END;
  52.                 cmRunTheManualEntryInputRoutineInstead:
  53.                 BEGIN
  54.             SELF.RunTheManualEntryInpurRoutineInstead;
  55.             INHERITED ClearEvent( Event );
  56.             END;
  57.                  .....
  58.                 INHERITED HandleEvent( event );
  59.         END;
  60.  
  61. PROCEDURE MyApp.RunCreditCardEntryRoutine;
  62.     BEGIN
  63.     ....gory setup details....
  64.     Result := DeskTop^.ExecView( MyCreditCardInputLineDialogP );
  65.     IF ( Result <> cmCancel )
  66.        THEN CASE Result OF
  67.              cmOk: BEGIN
  68.                ...gory details for credit card swipe....
  69.                END;
  70.                  cmRunTheManualInputRoutineInstead:
  71.             BEGIN
  72.                 NextEvent.What := evCommand;
  73.             NextEvent.Command := Result;
  74.             NextEvent.InfoPtr := @SELF;
  75.             INHERITED PutEvent( NextEvent );    
  76.             END;
  77.         END;
  78.     END;
  79.  
  80. >
  81. >2) How can I scan a data entry field for a '?' and then end data 
  82. >entry once it receives the '?'?
  83.  
  84. One way to do it:
  85.  
  86. PROCEDURE MyCeditCardInputLineDialog.HandleEvent()
  87.     BEGIN
  88.     ....
  89.     IF (( Event.What AND evKeyDown ) <> 0 )
  90.        BEGIN
  91.        CASE Event.KeyCode OF
  92.         kbQuestionMark: Event.KeyCode := kbTab;
  93.                 kbF3: BEGIN
  94.               INHERITED EndModal( cmRunTheManualInputRoutineInstead );
  95.               INHERITED ClearEvent( Event );
  96.               END;
  97.         END;
  98.        END;
  99.         INHERITED HandleEvent( Event );
  100.     END;
  101.  
  102. >
  103. >3) If I'm scanning for a '?', can I still capture an F3 to run a 
  104. >different routing?
  105.  
  106. See above for details intertwined...
  107.  
  108. >
  109. >The following is an example of a credit card swipe, but imagine 
  110. >it all on a single line:
  111. >
  112. >%B5123456789012345^SMITH/JOE^951110112102OP/0000000000000000?
  113. >
  114. >The ^9511 is the expiration date - 11/95.  The first string of 
  115. >numbers is the credit card number.
  116. >
  117. >Any sample code would be greatly appreciated.
  118. >Replies can be posted here, but preferably mailed to me at
  119. >pribik@rpi.edu.  Thanks in advance, and to all of those who
  120. >helped me with my async communications questions.
  121.  
  122. This is an outline just off the top of my head.....which in event
  123. driven programming comes out being structured quite close to the
  124. way you expressed the problem.  :^)
  125.  
  126. I'll leave the implementation details to you.  :^)
  127.  
  128. Steve
  129. ---
  130. +------------------------------------------------------------------+
  131. |     In person:  Steve Modena     AB4EL                           |
  132. |     On phone:   (919) 515-5328                                   |
  133. |     At e-mail:  nmodena@unity.ncsu.edu                           | 
  134. |                 samodena@csemail.cropsci.ncsu.edu                |
  135. |                 [ either email address is read each day ]        |
  136. |     By snail:   Crop Sci Dept, Box 7620, NCSU, Raleigh, NC 27695 |
  137. +------------------------------------------------------------------+
  138.          Lighten UP!  It's just a computer doing that to you.    (c)
  139. OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
  140.          
  141.