Character Mode Cookbook: Difference between revisions

From DataFlex Wiki
Jump to navigationJump to search
Jka (talk | contribs)
Jka (talk | contribs)
m using source tag
Line 1: Line 1:
=Keys and commands=
=Keys and commands=


<source lang="vdf">
  on_key KCLEAR                      : F5
  on_key KCLEAR                      : F5
  on_key KCANCEL      Send Cancel    : Esc
  on_key KCANCEL      Send Cancel    : Esc
  on_key KENTER                      : Enter
  on_key KENTER                      : Enter
  on_key KSAVE_RECORD Send Do_Report : F2
  on_key KSAVE_RECORD Send Do_Report : F2
</source>


  Promt commands
  Promt commands
Line 15: Line 17:
=Declaration=
=Declaration=
==Properties and variables==
==Properties and variables==
<source lang="vdf">
  property integer piCount public 0
  property integer piCount public 0
  set piCount To (piCount(current_object)+1)
  set piCount To (piCount(current_object)+1)
</source>


==Move==
==Move==
  local integer liNumber
  local integer liNumber
<source lang="vdf">
  move 0 To liNumber
  move 0 To liNumber


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


==Set/Get==
==Set/Get==
<source lang="vdf">
  Set value of (oPop(current_object)) item 0 to sVar      // item[0] = sVar
  Set value of (oPop(current_object)) item 0 to sVar      // item[0] = sVar
  Get Value item 0 to sVar                                // sVar    = item[0]
  Get Value item 0 to sVar                                // sVar    = item[0]
</source>


==Be aware of the difference==
==Be aware of the difference==
<source lang="vdf"
  Set A of object to B  A=B
  Set A of object to B  A=B
  Get A of object to B  B=A
  Get A of object to B  B=A
  Move A to B
  Move A to B
</source>
 
  You can only use Get and Set on properties
  You can only use Get and Set on properties


=Functions and Procedures=
=Functions and Procedures=
<source lang="vdf">>
  get myFunc of (oObj(current_object)) "tmp" to sAnswer // sAnswer = oObj->myFunc("tmp")
  get myFunc of (oObj(current_object)) "tmp" to sAnswer // sAnswer = oObj->myFunc("tmp")
</source>
  --------------
  --------------
  SET
  SET
Line 74: Line 86:


=Start "windows/console"=
=Start "windows/console"=
<source lnag="vdf">
  start_ui      // starts a new console
  start_ui      // starts a new console
  ui_accept      // has a return value
  ui_accept      // has a return value
  activate_scope // opens a new "window"
  activate_scope // opens a new "window"
</source>


=Content layout=
=Content layout=
<source lang="vdf">
  --------------
  --------------
  /Answer.hdr
  /Answer.hdr
Line 109: Line 124:
  Send OpenAnswerForm to (oAnswer(current_object)) "test string"
  Send OpenAnswerForm to (oAnswer(current_object)) "test string"
  --------------
  --------------
</source>


=Reports=
=Reports=
<source lang="vdf">
  /oReportView1.SectionName
  /oReportView1.SectionName
     __________________________________________________________________________
     __________________________________________________________________________
Line 168: Line 185:
  end_procedure
  end_procedure


</source>
  ---------------------------------------------------------------
  ---------------------------------------------------------------


=Objects=
=Objects=
<source lang="vdf">
  Object oOrder is a Entry_View_Client oOrder.hdr
  Object oOrder is a Entry_View_Client oOrder.hdr
     Set location 5 8 ABSOLUTE  
     Set location 5 8 ABSOLUTE  
Line 216: Line 235:
                                                                  
                                                                  
  End_Object
  End_Object
<7source>


  An object can be of different types
  An object can be of different types

Revision as of 20:52, 9 June 2008

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

 

 You can only use Get and Set on properties

=Functions and Procedures=
<source lang="vdf">>
 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

<source lang="vdf">

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

<7source>

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