Character Mode Cookbook: Difference between revisions

From DataFlex Wiki
Jump to navigationJump to search
Jka (talk | contribs)
m Added to Character Mode category
 
Line 252: Line 252:
[[Category:Basics]]
[[Category:Basics]]
[[Category:Cookbook]]
[[Category:Cookbook]]
[[Category:DataFlex (Character Mode)]]

Latest revision as of 12:39, 8 April 2020

Keys and commands

 on_key KCLEAR                      : F5
 on_key KCANCEL      Send Cancel    : Esc
 on_key KENTER                      : Enter
 on_key KSAVE_RECORD Send Do_Report : F2
Promt commands
df32
dfcomp ex.src -pfv1    p=precompile
dfcomp ex.src -fv1     fv1 creates prn-file (check errors)
dfrun ex
dfruncon ex            with mouse support

Declaration

Properties and variables

 property integer piCount public 0
 set piCount To (piCount(current_object)+1)

Move

local integer liNumber
 move 0 To liNumber

 Move (key+1) to key    key = key++ //Dont forget to use paratheses (a+(b*c))<>a+b*c

Set/Get

 Set value of (oPop(current_object)) item 0 to sVar      // item[0] = sVar
 Get Value item 0 to sVar                                // sVar    = item[0]

Be aware of the difference

 Set A of object to B  A=B
 Get A of object to B  B=A
 Move A to B
You can only use Get and Set on properties

Functions and Procedures

 get myFunc of (oObj(current_object)) "tmp" to sAnswer // sAnswer = oObj->myFunc("tmp")
--------------
SET
   value of OBJ ITEM to VAL
   location X Y [ABSOLUTE/RELATIVE]
   focus_mode to POINTER_ONLY
--------------
Procedure MyProcedure
End_Procedure
Send MyProcedure
------------------
Procedure DisplayResult String lsValue1 String lsValue2 String lsValue3
   set value of (oOutput(self)) item 0 to lsValue1
   set value of (oOutput(self)) item 1 to lsValue2
   set value of (oOutput(self)) item 2 to lsValue3
end_procedure
send DisplayResult lsValue1 "" ""
--------------
Procedure_Section // used in reports to handle paging in a smarter way
--------------
Function MyFunction integer i returns Integer

End_Function

get MyFunction(self) as iRet
--------------
function myFunc string test returns string
 local string lsRval
 move test to lsRval
 function_return lsRval
end_function
get myFunc of (oObj(current_object)) "tmp string" to sAnswer

Start "windows/console"

 start_ui       // starts a new console
 ui_accept      // has a return value
 activate_scope // opens a new "window"

Content layout

 --------------
 /Answer.hdr
 +--------------------+
 /Answer.dat
 ¦ Answer:_________   ¦
 +--------------------+
 /*
 register_object oAnswer
 Object oAnswer is a Client Answer.hdr
   Set location 7 30 ABSOLUTE
   On_Key kcancel Send cancel 

  Object oAnswData is a Form Answer.dat
    Set location 1 0 RELATIVE
    Set focus_mode to POINTER_ONLY
    item_list
      On_Item "" Send none
    end_item_list
  End_Object

  Procedure OpenAnswerForm string sValue
    local Integer iRval
    Set value of (oAnswData(current_object)) item 0 to sValue
    ui_accept current_object to iRval
  End_Procedure

 End_Object

 Send OpenAnswerForm to (oAnswer(current_object)) "test string"
 --------------

Reports

 /oReportView1.SectionName
    __________________________________________________________________________
 /oReportView1.body
   ____________________  ______________________
 /*


 //Activate_View Activate_Report1 for oReportView
 Object oReportView1 is a Report_View NO_IMAGE

    Object oMainReport is a seq.Report NO_IMAGE

        Set Main_File to customer.file_number
        //set Ordering to 2 // Order by name
        Set Report_Title to "Report 1 - Show position of sections"

        set Page_End to 18 // Page length set to screen length

        Procedure _PrintSectionName String lsValue
            Print lsValue to oReportView1.SectionName.1
            Output_Pagecheck oReportView1.SectionName
        End_Procedure

        // Procedures Page_Top thru Page_Bottom ONLY get used by the outermost report
        // object... All other objects delegate messages to this ultimate parent.
        // creating these procedures in child reports will have NO effect.

        // Procedure_Section Page_Top as oReportView1.SectionName
        // Procedure_Section Report_Header as oReportView1.SectionName
        // Procedure_Section Page_Header as oReportView1.SectionName
        // Procedure_Section Page_Title as oReportView1.SectionName
        // Procedure_Section Page_Total as oReportView1.SectionName
        // Procedure_Section Page_Footer as oReportView1.SectionName
        // Procedure_Section Report_Footer as oReportView1.SectionName
        Procedure_Section Page_Bottom as oReportView1.SectionName
            Send _PrintSectionName "Page_Bottom             (last thing printed on every page)"
        End_Procedure

        Procedure_Section Body as oReportView1.body      // or Procedure_Section Body
            Print customer.name to oReportView1.body.1   // Sets the data fields
            Print customer.city to oReportView1.body.2
            Output_Pagecheck oReportView1.body           // Prints the data to screen
        End_Procedure

        //Procedure_Section Total as oReportView1.SectionName

    End_Object

    Procedure run_report
        send run_report to (oMainReport(self))
    End_Procedure
 End_Object

 procedure Activate_Report_View_1
  send run_report to (oReportView1(self))
 end_procedure

---------------------------------------------------------------

Objects

 Object oOrder is a Entry_View_Client oOrder.hdr
    Set location 5 8 ABSOLUTE 

    Object Orderhea_DD is a Data_Set NO_IMAGE
        Set main_file to Orderhea.file_number
    End_Object       

    Object Orderdtl_DD is a Data_Set NO_IMAGE
        Set main_file to Orderdtl.file_number     
        Send attach_server (Orderhea_DD(current_object))
        //Set constrain_file to orderhea.file_number
        begin_constraints                    
             Constrain orderdtl relates to orderhea
        end_constraints
    End_Object   
    
    Object oForm is a Entry_Form oOrder.frm
        Set location 1 0 RELATIVE
        Set Server to (Orderhea_DD(current_object)) 

        item_list
          Entry_Item ORDERHEA.ORDER_NUMBER         { AutoClear AutoFind }
          Entry_Item ORDERHEA.ORDER_DATE           { AutoClear NoEnter }
          Entry_Item ORDERHEA.SHIP_VIA             { AutoClear NoEnter }
          Entry_Item ORDERHEA.ORDERED_BY           { AutoClear NoEnter }
          Entry_Item ORDERHEA.ORDER_TOTAL          { AutoClear NoEnter }          
        end_item_list
        
    End_Object

    Object oList is a Selection_List oOrder.lst
        Set location 13 0 RELATIVE
        Set Server to (Orderdtl_DD(current_object))
        
        Begin_Row    
          Entry_Item ORDERDTL.DETAIL_NUMBER      { AutoClear AutoFind NoPut}
          Entry_Item ORDERDTL.ITEM_ID            { AutoClear }
          Entry_Item ORDERDTL.QTY_ORDERED        { AutoClear }
          Entry_Item ORDERDTL.PRICE              { AutoClear }
          Entry_Item ORDERDTL.EXTENDED_PRICE     { AutoClear }
        End_Row

    End_Object
                                                                 
 End_Object
An object can be of different types
Containers
 - Entry_View_Client  : 
 - View_Client        : 
 - ModalClient        : Needs UI and brakes the flow
Controles
 - Entry_Form         : Data Aware
 - Form               : Non Data Aware
 - List               : Non Data Aware
 - Table              : Data Aware