Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.50 KB | None | 0 0
  1. Use Windows.pkg
  2. Use DFClient.pkg
  3.  
  4. Deferred_View Activate_oNewObjects for ;
  5. Object oNewObjects is a dbView
  6.  
  7. Set Border_Style to Border_Thick
  8. Set Size to 158 254
  9. Set Location to 2 4
  10. Set Label to "New Objects - Arrays"
  11.  
  12. Procedure Process
  13. Send OnClick to oButton1
  14. Set Focus to oForm1
  15. End_Procedure
  16.  
  17. Object oSaveArray is a SaveAsDialog
  18. Set Filter_String to 'All Files|*.*|Text File|*.txt|Comma Delimited|*.csv|'
  19. Set Initial_Folder to 'r:\'
  20. Set Dialog_Caption to 'Save my array'
  21. End_Object
  22.  
  23. Object oOpenArray is a OpenDialog
  24. Set Filter_String to 'All Files|*.*|Text File|*.txt|Comma Delimited|*.csv|'
  25. Set Initial_Folder to 'r:\'
  26. Set Filter_Index to 2
  27. End_Object
  28.  
  29. Object oMyNumbers is an Array
  30. Function FindResult Global Number nType Returns Number
  31. Integer iArrayCount
  32. Integer iLoop
  33. Number nLargest
  34. Number nVal
  35. Number nSmallest
  36. Number nTotal
  37. Number nAverage
  38. // nType = 1 = find largest
  39. // nType = 2 = find smallest
  40. // nType = 3 = find average
  41.  
  42. Get Item_Count of oMyNumbers to iArrayCount
  43. Move 0 to nTotal
  44.  
  45. For iLoop from 0 to (iArrayCount - 1)
  46. Get Value of oMyNumbers item iLoop to nVal
  47.  
  48. If (iLoop eq 0) Begin
  49. Move nVal to nLargest
  50. Move nVal to nSmallest
  51. End
  52. Else Begin
  53. If (nVal gt nLargest) Move nVal to nlargest
  54. If (nVal lt nSmallest) Move nVal to nSmallest
  55. End
  56.  
  57.  
  58. Move (nTotal +nVal) to nTotal
  59. Loop
  60.  
  61. Move (nTotal/iArrayCount) to nAverage
  62.  
  63. If (nType eq 1) Function_Return nLargest
  64. Else If (nType eq 2) Function_Return nSmallest
  65. Else If (nType eq 3) Function_Return nAverage
  66.  
  67. End_Function
  68. End_Object
  69.  
  70.  
  71.  
  72.  
  73. Object oButton1 is a Button
  74. Set Size to 14 75
  75. Set Location to 41 39
  76. Set Label to "Add number to array"
  77.  
  78. // fires when the button is clicked
  79. Procedure OnClick
  80. Number nVal
  81. Integer iArrayCount
  82.  
  83. Get Value of oForm1 to nVal
  84. Get Item_Count of oMyNumbers to iArrayCount
  85. Set Value of oMyNumbers item iArrayCount to nVal
  86. Set Value of oForm1 to ""
  87. End_Procedure
  88.  
  89. End_Object
  90.  
  91. Object oForm1 is a Form
  92. Set Size to 13 56
  93. Set Location to 15 49
  94. Set Form_Mask to "###.##"
  95. Set Form_Datatype to Mask_Numeric_Window
  96. //OnChange is called on every changed character
  97.  
  98. Procedure OnChange
  99. On_Key Key_Enter Send Process
  100. End_Procedure
  101.  
  102. End_Object
  103.  
  104. Object oButton2 is a Button
  105. Set Location to 86 51
  106. Set Label to "Display array"
  107.  
  108. // fires when the button is clicked
  109. Procedure OnClick
  110. Integer iArrayCount
  111. Number nVal
  112. Integer iLoop
  113. Number nTotal
  114.  
  115. String sResult
  116. Move "" to sResult
  117.  
  118. Get Item_Count of oMyNumbers to iArrayCount
  119. For iLoop from 0 to (iArrayCount - 1)
  120. Get Value of oMyNumbers item iLoop to nVal
  121. If (nVal ne 998) Begin
  122. Append sResult nVal sLineFeed
  123. Move (nTotal +nVal) to nTotal
  124. End
  125. Loop
  126.  
  127. Append sResult sLineFeed sLineFeed nTotal
  128.  
  129. Send Info_Box sResult "Answer"
  130.  
  131. End_Procedure
  132.  
  133. End_Object
  134.  
  135. Object oButton3 is a Button
  136. Set Location to 64 51
  137. Set Label to "Reset array"
  138.  
  139. // fires when the button is clicked
  140. Procedure OnClick
  141. Integer iLoop
  142. Integer iArrayCount
  143.  
  144. Get Item_Count of oMyNumbers to iArrayCount
  145.  
  146. For iLoop from 0 to (iArrayCount - 1)
  147. Set Value of oMyNumbers item iLoop to 998
  148. Loop
  149. End_Procedure
  150.  
  151. End_Object
  152.  
  153. Object oButton5 is a Button
  154. Set Location to 81 148
  155. Set Label to "Go"
  156.  
  157. // fires when the button is clicked
  158. Procedure OnClick
  159. String sResult
  160. Integer iCurrentRadio
  161.  
  162. Get Current_Radio of oRadioGroup1 to iCurrentRadio
  163.  
  164. If (iCurrentRadio eq 0) Append sResult "largest = "(FindResult(1))
  165. If (iCurrentRadio eq 1) Append sResult "Smallest = "(FindResult(2))
  166. If (iCurrentRadio eq 2) Append sResult "Average = "(FindResult(3))
  167.  
  168. Send Info_Box sResult "Result"
  169.  
  170.  
  171. End_Procedure
  172.  
  173. End_Object
  174.  
  175. Object oRadioGroup1 is a RadioGroup
  176. Set Location to 22 137
  177. Set Size to 54 77
  178. Set Label to "Arrays"
  179.  
  180. Object oRadio1 is a Radio
  181. Set Label to "Largest"
  182. Set Size to 10 61
  183. Set Location to 10 5
  184. End_Object
  185.  
  186. Object oRadio2 is a Radio
  187. Set Label to "Smallest"
  188. Set Size to 10 61
  189. Set Location to 25 5
  190. End_Object
  191.  
  192. Object oRadio3 is a Radio
  193. Set Label to "Average"
  194. Set Size to 10 61
  195. Set Location to 40 5
  196. End_Object
  197.  
  198. Procedure Notify_Select_State Integer iToItem Integer iFromItem
  199. Forward Send Notify_Select_State iToItem iFromItem
  200. //for augmentation
  201. End_Procedure
  202.  
  203. //If you set Current_Radio, you must set it AFTER the
  204. //radio objects have been created AND AFTER Notify_Select_State has been
  205. //created. i.e. Set in bottom-code of object at the end!!
  206.  
  207. //Set Current_Radio To 0
  208.  
  209. End_Object
  210.  
  211. Object oButton4 is a Button
  212. Set Location to 119 50
  213. Set Label to "Save to file"
  214.  
  215. // fires when the button is clicked
  216. Procedure OnClick
  217. Boolean bSave
  218. String sFileTitle sFileName
  219. Integer iLoop
  220. Integer iArrayCount
  221. Number nVal
  222.  
  223. Get Show_Dialog of (oSaveArray(Self)) to bSave
  224.  
  225. If (bSave) Begin
  226. Get File_Title of (oSaveArray(Self)) to sFileTitle
  227. Get File_Name of (oSaveArray(Self)) to sFileName
  228. Send Info_Box ("File Name = " +sFileTitle +"\nFile Path = " +sFileName)
  229.  
  230. Direct_Output sFileName
  231. Get Item_Count of oMyNumbers to iArrayCount
  232. For iLoop from 0 to (iArrayCount -1)
  233. Get Value of oMyNumbers item iLoop to nVal
  234. Writeln nVal
  235. Loop
  236.  
  237. Close_Output
  238. End
  239. Else Begin
  240. Send Info_Box "File has not been saved"
  241. End
  242. End_Procedure
  243.  
  244. End_Object
  245.  
  246. Object oButton6 is a Button
  247. Set Location to 135 50
  248. Set Label to "Open file"
  249.  
  250. // fires when the button is clicked
  251. Procedure OnClick
  252. Boolean bOpen bReadOnly
  253. String sFileTitle
  254. String sFileName
  255. Integer sVal
  256. String sResult
  257.  
  258. Get Show_Dialog of oOpenArray to bOpen
  259.  
  260. If bOpen Begin
  261. Get TickReadOnly_State of oOpenArray to bReadOnly
  262. Get File_Title of oOpenArray to sFileTitle
  263. Get File_Name of oOpenArray to sFileName
  264.  
  265. If (bReadOnly) Append sFileName ' (Read-Only)'
  266.  
  267. Direct_Input sFileName
  268.  
  269. If not SeqEof Begin
  270. While not (SeqEof)
  271. Readln sVal
  272. Append sResult sVal sLineFeed
  273. Loop
  274. End
  275.  
  276. Send Info_Box sResult "Data from file"
  277. End
  278. Else Send Info_Box "You did not choose to open a file"
  279.  
  280. End_Procedure
  281.  
  282. End_Object
  283.  
  284. Cd_End_Object
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement