home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a084 / 2.ddi / CKSAMPLE / MEMTOGEN.SPR < prev    next >
Encoding:
Text File  |  1993-05-25  |  5.8 KB  |  212 lines

  1. *       *********************************************************
  2. *       *                                                         
  3. *       * 05/18/93            MEMTOGEN.SPR               13:45:10 
  4. *       *                                                         
  5. *       *********************************************************
  6. *       *                                                         
  7. *       * Steven Hsu, Wayne Lampel                                
  8. *       *                                                         
  9. *       * Copyright (c) 1993 Microsoft                            
  10. *       * One Microsoft Way                                       
  11. *       * Redmond, WA  98052                                      
  12. *       *                                                         
  13. *       * Description:                                            
  14. *       * This program was automatically generated by GENSCRN.    
  15. *       *                                                         
  16. *       *********************************************************
  17.  
  18.  
  19. #REGION 0
  20. REGIONAL m.currarea, m.talkstat, m.compstat
  21.  
  22. IF SET("TALK") = "ON"
  23.     SET TALK OFF
  24.     m.talkstat = "ON"
  25. ELSE
  26.     m.talkstat = "OFF"
  27. ENDIF
  28. m.compstat = SET("COMPATIBLE")
  29. SET COMPATIBLE FOXPLUS
  30.  
  31. m.rborder = SET("READBORDER")
  32. SET READBORDER ON
  33.  
  34. *       *********************************************************
  35. *       *                                                         
  36. *       *               Windows Window definitions                
  37. *       *                                                         
  38. *       *********************************************************
  39. *
  40.  
  41. IF NOT WEXIST("mem2gen") ;
  42.     OR UPPER(WTITLE("MEM2GEN")) == "MEM2GEN.PJX" ;
  43.     OR UPPER(WTITLE("MEM2GEN")) == "MEM2GEN.SCX" ;
  44.     OR UPPER(WTITLE("MEM2GEN")) == "MEM2GEN.MNX" ;
  45.     OR UPPER(WTITLE("MEM2GEN")) == "MEM2GEN.PRG" ;
  46.     OR UPPER(WTITLE("MEM2GEN")) == "MEM2GEN.FRX" ;
  47.     OR UPPER(WTITLE("MEM2GEN")) == "MEM2GEN.QPR"
  48.     DEFINE WINDOW mem2gen ;
  49.         AT  0.000, 0.000  ;
  50.         SIZE 20.385,44.400 ;
  51.         TITLE "Convert Memo" ;
  52.         FONT "MS Sans Serif", 8 ;
  53.         FLOAT ;
  54.         NOCLOSE ;
  55.         MINIMIZE ;
  56.         SYSTEM
  57.     MOVE WINDOW mem2gen CENTER
  58. ENDIF
  59.  
  60.  
  61. *       *********************************************************
  62. *       *                                                         
  63. *       *         MEMTOGEN/Windows Setup Code - SECTION 2         
  64. *       *                                                         
  65. *       *********************************************************
  66. *
  67.  
  68. #REGION 1
  69. if used()
  70.     if not file(dbf())
  71.         wait window "Not a Table (a cursor perhaps)" nowait
  72.         return
  73.     endif
  74.     thetable = dbf()
  75.     thealias = alias()
  76.     wasopen = .t.
  77. else
  78.     thetable = getfile("DBF","Select a Table")
  79.     if empty(thetable)
  80.         return
  81.     endif
  82.     select 0
  83.     use (thetable) alias "mytable"
  84.     thealias = "mytable"
  85.     wasopen = .f.
  86. endif
  87.  
  88. tempfil = sys(3)+'.dbf'
  89.  
  90. copy to (tempfil) stru exte
  91. sele 0
  92. use (tempfil) alias thestru
  93. copy to array tempm fields field_name for field_type = "M"
  94. if type("tempm") = "U"
  95.     wait window "No memo fields to convert!" nowait
  96.     return
  97. endif
  98.  
  99. use
  100. delete file (tempfil)
  101. select (thealias)
  102. use
  103.  
  104. gen_cnt = 0
  105. for z = 1 to alen(tempm)
  106.     tempm(z) = alltrim(tempm(z))
  107.     if isole(thetable,tempm(z)) = 1
  108.         gen_cnt = gen_cnt + 1
  109.         dime thememos(gen_cnt)
  110.         thememos(gen_cnt) = tempm(z)
  111.     endif
  112. endfor
  113. if gen_cnt = 0
  114.     wait window "There are no OLE objects in this table!" nowait
  115.     return
  116. endif
  117.  
  118. mselect = ""
  119. m.browseit = .t.
  120.  
  121. *       *********************************************************
  122. *       *                                                         
  123. *       *             MEMTOGEN/Windows Screen Layout              
  124. *       *                                                         
  125. *       *********************************************************
  126. *
  127.  
  128. #REGION 1
  129. IF WVISIBLE("mem2gen")
  130.     ACTIVATE WINDOW mem2gen SAME
  131. ELSE
  132.     ACTIVATE WINDOW mem2gen NOSHOW
  133. ENDIF
  134. @ 0.308,3.200 SAY "Please select a memo to convert:"  ;
  135.     FONT "MS Sans Serif", 8 ;
  136.     STYLE "BT"
  137. @ 1.923,3.400 GET mselect ;
  138.      PICTURE "@&T" ;
  139.     FROM thememos ;
  140.     SIZE 12.692,37.400 ;
  141.     DEFAULT 1 ;
  142.     FONT "MS Sans Serif", 8
  143. @ 15.538,3.200 GET m.browseit ;
  144.     PICTURE "@*C \<Browse after conversion" ;
  145.     SIZE 1.308,28.500 ;
  146.     DEFAULT 0 ;
  147.     FONT "MS Sans Serif", 8 ;
  148.     STYLE "BT"
  149. @ 17.538,11.000 GET m.action ;
  150.     PICTURE "@*HT \!\<Convert;Cancel" ;
  151.     SIZE 2.000,8.500,1.667 ;
  152.     DEFAULT 1 ;
  153.     FONT "MS Sans Serif", 8 ;
  154.     STYLE "B"
  155.  
  156. IF NOT WVISIBLE("mem2gen")
  157.     ACTIVATE WINDOW mem2gen
  158. ENDIF
  159.  
  160. READ CYCLE
  161.  
  162. RELEASE WINDOW mem2gen
  163.  
  164. #REGION 0
  165.  
  166. SET READBORDER &rborder
  167.  
  168. IF m.talkstat = "ON"
  169.     SET TALK ON
  170. ENDIF
  171. IF m.compstat = "ON"
  172.     SET COMPATIBLE ON
  173. ENDIF
  174.  
  175.  
  176. *       *********************************************************
  177. *       *                                                         
  178. *       *              MEMTOGEN/Windows Cleanup Code              
  179. *       *                                                         
  180. *       *********************************************************
  181. *
  182.  
  183. #REGION 1
  184. ret_val = 0
  185. if m.action = 1
  186.     ret_val = mem2gen(thetable,alltrim(mselect))
  187.     do case
  188.         case ret_val = -6
  189.             wait window "Could not write to: "+thetable+chr(7)
  190.         case ret_val = -5
  191.             wait window "Field could not be found: "+alltrim(mselect)+chr(7)
  192.         case ret_val = -4
  193.             wait window "Not a valid table!"+chr(7)
  194.         case ret_val = -2
  195.             wait window "Not a memo field: "+mselect+chr(7)
  196.         case ret_val = -1
  197.             wait window "Could not open: "+thetable+chr(7)
  198.         case ret_val = 1
  199.             wait window "Conversion complete!" nowait
  200.         otherwise
  201.             wait window "Unknown mem2gen error: "+alltrim(str(ret_val))+chr(7)
  202.     endcase
  203. endif
  204. if (wasopen or browseit) and ret_val >= 0
  205.     select 0
  206.     use (thetable) alias (thealias)
  207.     if browseit
  208.         browse
  209.     endif
  210. endif
  211.  
  212.