Skip to content

Commit

Permalink
code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
delahaye-4D committed Oct 28, 2024
1 parent 54c8d29 commit 2c7203b
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 89 deletions.
108 changes: 55 additions & 53 deletions Project/Sources/Forms/NQR/ObjectMethods/toolbar.opened.fields.4dm
Original file line number Diff line number Diff line change
@@ -1,91 +1,93 @@
// ----------------------------------------------------
// Object method : NQR.toolbar.opened.fields - (4D Report)
// ID[69EECC1C0B65428A924882EA8987C101]
// Created #7-12-2015 by Vincent de Lachaux
// ----------------------------------------------------
// Declarations
C_LONGINT:C283($i;$l;$Lon_area;$Lon_bottom;$Lon_formEvent;$Lon_height)
C_LONGINT:C283($Lon_left;$Lon_offset;$Lon_right;$Lon_top)
C_REAL:C285($Num_wanted)
C_TEXT:C284($t;$Txt_formula;$Txt_title;$Txt_variableName)
C_OBJECT:C1216($o)
// ----------------------------------------------------
// Object method : NQR.toolbar.opened.fields - (4D Report)
// ID[69EECC1C0B65428A924882EA8987C101]
// Created #7-12-2015 by Vincent de Lachaux
// ----------------------------------------------------
// Declarations

// ----------------------------------------------------
// Initialisations
$Lon_formEvent:=Form event code:C388

// ----------------------------------------------------
var $i; $l; $Lon_area; $Lon_bottom; $Lon_height : Integer
var $Lon_left; $Lon_offset; $Lon_right; $Lon_top : Integer
var $Num_wanted : Real
var $t; $Txt_formula; $Txt_title; $Txt_variableName : Text
var $e; $o : Object

// ----------------------------------------------------
// Initialisations
$e:=FORM Event:C1606

// ----------------------------------------------------
Case of

//______________________________________________________
: ($Lon_formEvent=On Clicked:K2:4)
//______________________________________________________
: ($e.code=On Clicked:K2:4)

OBJECT GET COORDINATES:C663(*;"settings.mask";$l;$l;$l;$Lon_height)
OBJECT GET COORDINATES:C663(*; "settings.mask"; $l; $l; $l; $Lon_height)

$Num_wanted:=$Lon_height*0.9
$Lon_offset:=Round:C94(($Lon_height-$Num_wanted)/2;0)
$Lon_offset:=Round:C94(($Lon_height-$Num_wanted)/2; 0)
$Lon_top:=$Lon_offset
$Lon_bottom:=$Lon_height-$Lon_offset

OBJECT GET COORDINATES:C663(*;"settings.dial";$Lon_left;$l;$Lon_right;$l)
OBJECT SET COORDINATES:C1248(*;"settings.dial";$Lon_left;$Lon_top;$Lon_right;$Lon_bottom)
OBJECT GET COORDINATES:C663(*; "settings.dial"; $Lon_left; $l; $Lon_right; $l)
OBJECT SET COORDINATES:C1248(*; "settings.dial"; $Lon_left; $Lon_top; $Lon_right; $Lon_bottom)

// Adjust position
Obj_CENTER ("settings.dial";"settings.mask";Horizontally centered:K39:1)
// Adjust position
Obj_CENTER("settings.dial"; "settings.mask"; Horizontally centered:K39:1)

// Mask plus button
OBJECT SET VISIBLE:C603(*;"plus@";False:C215)
// Mask plus button
OBJECT SET VISIBLE:C603(*; "plus@"; False:C215)

// Show widget & mask
OBJECT SET VISIBLE:C603(*;"settings.@";True:C214)
// Show widget & mask
OBJECT SET VISIBLE:C603(*; "settings.@"; True:C214)

//#ACI0098813 [
//$Lon_area:=OB Get(ob_area;"area";Is longint)
//If ($Lon_area#0)
//$Lon_columns:=QR Count columns($Lon_area)
//ARRAY OBJECT($tObj_columns;$Lon_columns)
//For ($Lon_i;1;$Lon_columns;1)
//QR GET INFO COLUMN($Lon_area;$Lon_i;$Txt_title;$Txt_formula;$Lon_;$Lon_;$Lon_;$Txt_;$Txt_variableName)
//OB SET($tObj_columns{$Lon_i};\
//#ACI0098813 [
//$Lon_area:=OB Get(ob_area;"area";Is longint)
//If ($Lon_area#0)
//$Lon_columns:=QR Count columns($Lon_area)
//ARRAY OBJECT($tObj_columns;$Lon_columns)
//For ($Lon_i;1;$Lon_columns;1)
//QR GET INFO COLUMN($Lon_area;$Lon_i;$Txt_title;$Txt_formula;$Lon_;$Lon_;$Lon_;$Txt_;$Txt_variableName)
//OB SET($tObj_columns{$Lon_i};\
"column";$Lon_i;\
"title";$Txt_title;\
"formula";$Txt_formula;\
"variable";$Txt_variableName)
//End for
// //touch the subform
//OB SET ARRAY((OBJECT Get pointer(Object named;"settings.dial"))->;"columns";$tObj_columns)
//End if
//End for
// //touch the subform
//OB SET ARRAY((OBJECT Get pointer(Object named;"settings.dial"))->;"columns";$tObj_columns)
//End if

$Lon_area:=Num:C11(ob_area.area)

If ($Lon_area#0)

//#ACI0098813
//#ACI0098813
$o:=New object:C1471(\
"columns";New collection:C1472)
"columns"; New collection:C1472)

For ($i;1;QR Count columns:C764($Lon_area);1)
For ($i; 1; QR Count columns:C764($Lon_area); 1)

QR GET INFO COLUMN:C766($Lon_area;$i;$Txt_title;$Txt_formula;$l;$l;$l;$t;$Txt_variableName)
QR GET INFO COLUMN:C766($Lon_area; $i; $Txt_title; $Txt_formula; $l; $l; $l; $t; $Txt_variableName)

$o.columns.push(New object:C1471(\
"column";$i;\
"title";$Txt_title;\
"formula";$Txt_formula;\
"variable";$Txt_variableName))
"column"; $i; \
"title"; $Txt_title; \
"formula"; $Txt_formula; \
"variable"; $Txt_variableName))

End for

// Touch the subform
(OBJECT Get pointer:C1124(Object named:K67:5;"settings.dial"))->:=$o
// Touch the subform
(OBJECT Get pointer:C1124(Object named:K67:5; "settings.dial"))->:=$o

End if
//]
//]

//______________________________________________________
//______________________________________________________
Else

ASSERT:C1129(False:C215;"Form event activated unnecessarily ("+String:C10($Lon_formEvent)+")")
ASSERT:C1129(False:C215; "Form event activated unnecessarily ("+String:C10($e.code)+")")

//______________________________________________________
//______________________________________________________
End case
2 changes: 1 addition & 1 deletion Project/Sources/Methods/COMPILER_report.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var Form_C_UseVirtualStructure : Integer
var ob_dialog; ob_area : Object


ob_area:=ob_area || New object:C1471
ob_area:=ob_area || {}

ARRAY LONGINT:C221(tLon_rowHeights; 0)

Expand Down
54 changes: 28 additions & 26 deletions Project/Sources/Methods/db_virtualFieldName.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,41 @@
//
// ----------------------------------------------------
// Declarations
C_TEXT:C284($0)
C_TEXT:C284($1)
#DECLARE($structure_name : Text) : Text

C_LONGINT:C283($Lon_fieldID; $Lon_parameters; $Lon_tableID; $Lon_x; $Lon_y)
C_TEXT:C284($kTxt_pattern; $Txt_structure_name; $Txt_virtual_name)
//_O_C_TEXT($0)
//_O_C_TEXT($1)

If (False:C215)
C_TEXT:C284(db_virtualFieldName; $0)
C_TEXT:C284(db_virtualFieldName; $1)
End if
var $field_ID; $count_parameters; $table_ID; $x; $y : Integer
var $pattern; $virtual_name : Text

//If (False)
//_O_C_TEXT(db_virtualFieldName; $0)
//_O_C_TEXT(db_virtualFieldName; $1)
//End if

ARRAY TEXT:C222($tTxt_results; 0x0000; 0x0000)
ARRAY TEXT:C222($_results; 0x0000; 0x0000)

// ----------------------------------------------------
// Initialisations
$Lon_parameters:=Count parameters:C259
$count_parameters:=Count parameters:C259

If (Asserted:C1132($Lon_parameters>=1; "Missing parameter"))
If (Asserted:C1132($count_parameters>=1; "Missing parameter"))

//Required parameters
$Txt_structure_name:=$1
//$structure_name:=$1

//Optional parameters
If ($Lon_parameters>=2)
If ($count_parameters>=2)

// <NONE>

End if

$Txt_virtual_name:=$Txt_structure_name
$virtual_name:=$structure_name

//extract the table name and the field name
$kTxt_pattern:="(?mi-s)^\\[+([^\\]]*)\\]+([^-+*/(&?>]*)$"
$pattern:="(?mi-s)^\\[+([^\\]]*)\\]+([^-+*/(&?>]*)$"

Else

Expand All @@ -52,31 +54,31 @@ End if
// ----------------------------------------------------
If (boo_useVirtualStructure)

If (Rgx_ExtractText($kTxt_pattern; $Txt_structure_name; "1 2"; ->$tTxt_results; 0)=0)
If (Rgx_ExtractText($pattern; $structure_name; "1 2"; ->$_results; 0)=0)

//mapped to the virtual structure

//#ACI0093166
//$Lon_tableID:=Find in array(tTxt_tableNames;$tTxt_results{1}{1})
$Lon_tableID:=Find in array:C230(report_structureDefinition{0}; $tTxt_results{1}{1})
$table_ID:=Find in array:C230(report_structureDefinition{0}; $_results{1}{1})

If ($Lon_tableID>0)
If ($table_ID>0)

//#ACI0093166
//$Lon_fieldID:=Find in array(tTxt_fieldNames{$Lon_tableID};$tTxt_results{1}{2})
$Lon_fieldID:=Find in array:C230(report_structureDefinition{$Lon_tableID}; $tTxt_results{1}{2})
$field_ID:=Find in array:C230(report_structureDefinition{$table_ID}; $_results{1}{2})

If ($Lon_fieldID>0)
If ($field_ID>0)

$Lon_x:=Find in array:C230(tLon_tableIDs; $Lon_tableID)
$x:=Find in array:C230(tLon_tableIDs; $table_ID)

If ($Lon_x>0)
If ($x>0)

$Lon_y:=Find in array:C230(tLon_fieldIDs{$Lon_x}; $Lon_fieldID)
$y:=Find in array:C230(tLon_fieldIDs{$x}; $field_ID)

If ($Lon_y>0)
If ($y>0)

$Txt_virtual_name:="["+tTxt_tableNames{$Lon_x}+"]"+tTxt_fieldNames{$Lon_x}{$Lon_y}
$virtual_name:="["+tTxt_tableNames{$x}+"]"+tTxt_fieldNames{$x}{$y}

End if
End if
Expand All @@ -87,7 +89,7 @@ End if

// ----------------------------------------------------
// Return
$0:=$Txt_virtual_name
return $virtual_name

// ----------------------------------------------------
// End
18 changes: 9 additions & 9 deletions Project/Sources/Methods/report_INIT.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $template:="<span style=\"font-family:'"
$template+=Choose:C955(Is Windows:C1573; "Segoe UI"; "Lucida Grande")
$template+="';font-size:{size};font-weight:{weight};font-style:normal;text-decoration:none;color:{color}\">{value} </span>"

Form:C1466.dataStyled:=New collection:C1472
Form:C1466.dataStyled:=[]

//------------------------- SUM -------------------------
$text:=Replace string:C233($template; "{size}"; Choose:C955(Is Windows:C1573; "16"; "18"))
Expand Down Expand Up @@ -98,7 +98,7 @@ $text:=Replace string:C233($text; "{value}"; Char:C90(0x03C3))
Form:C1466.dataStyled.push($text)

// Mark:Tags for automatic calculations
Form:C1466.dataTags:=New collection:C1472
Form:C1466.dataTags:=[]

Form:C1466.dataTags.push("##S")
Form:C1466.dataTags.push("##A")
Expand All @@ -109,14 +109,14 @@ Form:C1466.dataTags.push("##D")


// Mark:Labels for automatic calculations
Form:C1466.dataLabels:=New collection:C1472
Form:C1466.dataLabels:=[]

$template:="<span style='font-weight: normal;text-decoration:none'> </span>"

Form:C1466.dataLabels.push($template+Get localized string:C991("nqr_sum")+"\r")
Form:C1466.dataLabels.push($template+Get localized string:C991("nqr_average")+"\r")
Form:C1466.dataLabels.push($template+Get localized string:C991("nqr_min")+"\r")
Form:C1466.dataLabels.push($template+Get localized string:C991("nqr_max")+"\r")
Form:C1466.dataLabels.push($template+Get localized string:C991("nqr_count")+"\r")
Form:C1466.dataLabels.push($template+Get localized string:C991("nqr_standard_deviation")+"\r")
Form:C1466.dataLabels.push($template+Localized string:C991("nqr_sum")+"\r")
Form:C1466.dataLabels.push($template+Localized string:C991("nqr_average")+"\r")
Form:C1466.dataLabels.push($template+Localized string:C991("nqr_min")+"\r")
Form:C1466.dataLabels.push($template+Localized string:C991("nqr_max")+"\r")
Form:C1466.dataLabels.push($template+Localized string:C991("nqr_count")+"\r")
Form:C1466.dataLabels.push($template+Localized string:C991("nqr_standard_deviation")+"\r")

0 comments on commit 2c7203b

Please sign in to comment.