Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Use Windows.pkg
- Use DFClient.pkg
- Deferred_View Activate_oNewObjects for ;
- Object oNewObjects is a dbView
- Set Border_Style to Border_Thick
- Set Size to 158 254
- Set Location to 2 4
- Set Label to "New Objects - Arrays"
- Procedure Process
- Send OnClick to oButton1
- Set Focus to oForm1
- End_Procedure
- Object oSaveArray is a SaveAsDialog
- Set Filter_String to 'All Files|*.*|Text File|*.txt|Comma Delimited|*.csv|'
- Set Initial_Folder to 'r:\'
- Set Dialog_Caption to 'Save my array'
- End_Object
- Object oOpenArray is a OpenDialog
- Set Filter_String to 'All Files|*.*|Text File|*.txt|Comma Delimited|*.csv|'
- Set Initial_Folder to 'r:\'
- Set Filter_Index to 2
- End_Object
- Object oMyNumbers is an Array
- Function FindResult Global Number nType Returns Number
- Integer iArrayCount
- Integer iLoop
- Number nLargest
- Number nVal
- Number nSmallest
- Number nTotal
- Number nAverage
- // nType = 1 = find largest
- // nType = 2 = find smallest
- // nType = 3 = find average
- Get Item_Count of oMyNumbers to iArrayCount
- Move 0 to nTotal
- For iLoop from 0 to (iArrayCount - 1)
- Get Value of oMyNumbers item iLoop to nVal
- If (iLoop eq 0) Begin
- Move nVal to nLargest
- Move nVal to nSmallest
- End
- Else Begin
- If (nVal gt nLargest) Move nVal to nlargest
- If (nVal lt nSmallest) Move nVal to nSmallest
- End
- Move (nTotal +nVal) to nTotal
- Loop
- Move (nTotal/iArrayCount) to nAverage
- If (nType eq 1) Function_Return nLargest
- Else If (nType eq 2) Function_Return nSmallest
- Else If (nType eq 3) Function_Return nAverage
- End_Function
- End_Object
- Object oButton1 is a Button
- Set Size to 14 75
- Set Location to 41 39
- Set Label to "Add number to array"
- // fires when the button is clicked
- Procedure OnClick
- Number nVal
- Integer iArrayCount
- Get Value of oForm1 to nVal
- Get Item_Count of oMyNumbers to iArrayCount
- Set Value of oMyNumbers item iArrayCount to nVal
- Set Value of oForm1 to ""
- End_Procedure
- End_Object
- Object oForm1 is a Form
- Set Size to 13 56
- Set Location to 15 49
- Set Form_Mask to "###.##"
- Set Form_Datatype to Mask_Numeric_Window
- //OnChange is called on every changed character
- Procedure OnChange
- On_Key Key_Enter Send Process
- End_Procedure
- End_Object
- Object oButton2 is a Button
- Set Location to 86 51
- Set Label to "Display array"
- // fires when the button is clicked
- Procedure OnClick
- Integer iArrayCount
- Number nVal
- Integer iLoop
- Number nTotal
- String sResult
- Move "" to sResult
- Get Item_Count of oMyNumbers to iArrayCount
- For iLoop from 0 to (iArrayCount - 1)
- Get Value of oMyNumbers item iLoop to nVal
- If (nVal ne 998) Begin
- Append sResult nVal sLineFeed
- Move (nTotal +nVal) to nTotal
- End
- Loop
- Append sResult sLineFeed sLineFeed nTotal
- Send Info_Box sResult "Answer"
- End_Procedure
- End_Object
- Object oButton3 is a Button
- Set Location to 64 51
- Set Label to "Reset array"
- // fires when the button is clicked
- Procedure OnClick
- Integer iLoop
- Integer iArrayCount
- Get Item_Count of oMyNumbers to iArrayCount
- For iLoop from 0 to (iArrayCount - 1)
- Set Value of oMyNumbers item iLoop to 998
- Loop
- End_Procedure
- End_Object
- Object oButton5 is a Button
- Set Location to 81 148
- Set Label to "Go"
- // fires when the button is clicked
- Procedure OnClick
- String sResult
- Integer iCurrentRadio
- Get Current_Radio of oRadioGroup1 to iCurrentRadio
- If (iCurrentRadio eq 0) Append sResult "largest = "(FindResult(1))
- If (iCurrentRadio eq 1) Append sResult "Smallest = "(FindResult(2))
- If (iCurrentRadio eq 2) Append sResult "Average = "(FindResult(3))
- Send Info_Box sResult "Result"
- End_Procedure
- End_Object
- Object oRadioGroup1 is a RadioGroup
- Set Location to 22 137
- Set Size to 54 77
- Set Label to "Arrays"
- Object oRadio1 is a Radio
- Set Label to "Largest"
- Set Size to 10 61
- Set Location to 10 5
- End_Object
- Object oRadio2 is a Radio
- Set Label to "Smallest"
- Set Size to 10 61
- Set Location to 25 5
- End_Object
- Object oRadio3 is a Radio
- Set Label to "Average"
- Set Size to 10 61
- Set Location to 40 5
- End_Object
- Procedure Notify_Select_State Integer iToItem Integer iFromItem
- Forward Send Notify_Select_State iToItem iFromItem
- //for augmentation
- End_Procedure
- //If you set Current_Radio, you must set it AFTER the
- //radio objects have been created AND AFTER Notify_Select_State has been
- //created. i.e. Set in bottom-code of object at the end!!
- //Set Current_Radio To 0
- End_Object
- Object oButton4 is a Button
- Set Location to 119 50
- Set Label to "Save to file"
- // fires when the button is clicked
- Procedure OnClick
- Boolean bSave
- String sFileTitle sFileName
- Integer iLoop
- Integer iArrayCount
- Number nVal
- Get Show_Dialog of (oSaveArray(Self)) to bSave
- If (bSave) Begin
- Get File_Title of (oSaveArray(Self)) to sFileTitle
- Get File_Name of (oSaveArray(Self)) to sFileName
- Send Info_Box ("File Name = " +sFileTitle +"\nFile Path = " +sFileName)
- Direct_Output sFileName
- Get Item_Count of oMyNumbers to iArrayCount
- For iLoop from 0 to (iArrayCount -1)
- Get Value of oMyNumbers item iLoop to nVal
- Writeln nVal
- Loop
- Close_Output
- End
- Else Begin
- Send Info_Box "File has not been saved"
- End
- End_Procedure
- End_Object
- Object oButton6 is a Button
- Set Location to 135 50
- Set Label to "Open file"
- // fires when the button is clicked
- Procedure OnClick
- Boolean bOpen bReadOnly
- String sFileTitle
- String sFileName
- Integer sVal
- String sResult
- Get Show_Dialog of oOpenArray to bOpen
- If bOpen Begin
- Get TickReadOnly_State of oOpenArray to bReadOnly
- Get File_Title of oOpenArray to sFileTitle
- Get File_Name of oOpenArray to sFileName
- If (bReadOnly) Append sFileName ' (Read-Only)'
- Direct_Input sFileName
- If not SeqEof Begin
- While not (SeqEof)
- Readln sVal
- Append sResult sVal sLineFeed
- Loop
- End
- Send Info_Box sResult "Data from file"
- End
- Else Send Info_Box "You did not choose to open a file"
- End_Procedure
- End_Object
- Cd_End_Object
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement