of_AddCompute


pfcdwsrv.pbl   >   pfc_n_cst_dwsrv_report   >   of_AddCompute   

Full name pfc_n_cst_dwsrv_report.of_AddCompute
Access protected
Extend of string
Return value string
Prototype protected function string of_AddCompute(string,string,alignment,vtextalign,integer,integer,border,boolean,boolean,boolean,string,integer,fontcharset,

Name Datatype
No Data

Name Datatype
li_Cnt Integer
li_CurrentHeight Integer
li_DwWidth Integer
li_Height Integer
li_Line Integer
li_NewLines Integer
li_Shift Integer
li_Width Integer
lnv_String n_cst_string
ls_Line String[]
ls_Modify String
ls_Return String
ls_Text String
ls_Undo String

protected function string of_AddCompute (string as_expr, string as_band, alignment aal_halign, vtextalign avta_valign, integer ai_x, integer ai_y, border abo_border, boolean ab_bold, boolean ab_italic, boolean ab_underline, string as_fontface, integer ai_fontsize, fontcharset afc_charset, long al_color, long al_backcolor, boolean ab_execute);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_AddCompute
//
//	Access:  protected
//
//	Arguments:
//	as_Expr						The expression to be added as the computed column.
//	as_Band					The band to add it to.
//	aal_HAlign					The horizontal alignment of the object being placed.
//	avta_Valign				The vertical alignment of the object being placed.
//	abo_Border				The border to place around the object added (NoBorder!, 
//									ShadowBox!, Box!, ResizeBorder!, Underline!, Lowered!
//									Raised!).
//	ai_X							The X position of the object.
//	ai_Y							The Y position of the object.
//	ab_Bold						True - Bold, False - Normal.
//	ab_Italic					True - Yes, False - No.
//	ab_Underline				True - Yes, False - No.
//	as_FontFace				The font to use (i.e. "MS Sans Serif")
//	ai_FontSize				The point size of the font.
//	afc_CharSet				The character set to use (Ansi!, DefaultCharSet!, Symbol!, 
//									Shiftjis!, OEM!)
//	al_Color						The color of the object.
//	al_BackColor				The background color of the object.
//	ab_Execute				True - execute the Modify command,
//									False - build the command but do not execute it
//
//	Returns:		String
//					The output of the Modify command (the error text or "") if True
//					was passed for ab_Execute; the text of the Modify command
//					to add the object if False was passed.  Or one of the following errors:
//					"Error!  Invalid DW Unit"			-	DataWindow Unit is not PB Units or Pixels
//					"Error!  Invalid Expression"		-	The expression passed in was invalid
//					"Error!  Error calculating size"	-	Returned an error calculating the object size
//
//	Description:	Add a computed column to any band of a datawindow.  This protected
//						function does all the work.  Overloaded functions should be called.
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	5.0   Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
//	Copyright © 1996-1997 Sybase, Inc. and its subsidiaries.  All rights reserved.
//	Any distribution of the PowerBuilder Foundation Classes (PFC)
//	source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

String			ls_Return, ls_Modify, ls_Undo, ls_Line[], ls_Text
Integer			li_NewLines, li_Cnt, li_Line, li_Height, li_Width, &
					li_CurrentHeight, li_DwWidth, li_Shift
n_cst_string	lnv_String

// Verify that DataWindow units are either PowerBuild Units or Pixels
If idw_Requestor.Object.DataWindow.Units > "1" Then Return "Error!  Invalid DW Unit"

// Change all " to ~" because it will be imbedded in quotes
as_Expr = lnv_string.of_GlobalReplace (as_Expr, "~"", "~~~"")

// Evaluate the expression to be used in calculating the object width
ls_Text = idw_Requestor.Describe("Evaluate('" + as_Expr + "', 1)")
If ls_Text = "!" Then
	Return "Error!  Invalid Expression"
End if

// Calculate the height, width and position of the new object
li_NewLines = of_GetTextSizePos(as_Expr, as_Band, aal_HAlign, avta_VAlign, ab_Bold, &
												ab_Italic, ab_Underline, as_FontFace, ai_FontSize, li_Height, &
												li_Width, ai_X, ai_Y)
If li_NewLines = -1 Then Return "Error!  Error calculating size"

// Determine if existing objects should be shifted
If Not IsNull(aal_HAlign) Then
	If avta_VAlign <> VCenter! Then
		// Adding or inserting the object
		// Get original band height
		li_CurrentHeight = Integer(idw_Requestor.Describe("Datawindow." + as_Band + ".Height"))

		// Calculate the new height of the band
		li_Shift = (li_Height * (li_NewLines + 0.4))

		// If inserting at the top, then shift original objects down
		If avta_VAlign = Top! Then
			ls_Modify = ls_Modify + of_ShiftBand(as_Band, 0, li_Shift, False)
			ls_Undo = is_Undo[ii_UndoLevel]
			ii_UndoLevel --
		Else
			// Set new band height
			ls_Modify = "Datawindow." + as_Band + ".Height=" + String(li_CurrentHeight + li_Shift)
			ls_Undo = "Datawindow." + as_Band + ".Height=" + String(li_CurrentHeight)
		End if

	ElseIf aal_HAlign = Left! Then
		// Shift band objects right
		ls_Modify = ls_Modify + of_ShiftBand(as_Band, (li_Width + 10), 0, False)
		ls_Undo = is_Undo[ii_UndoLevel]
		ii_UndoLevel --
	End if
End If

// Build modify statement
ls_Modify = ls_Modify + of_BuildTextModify("compute", as_Expr, as_Band, ai_X, ai_Y, li_Height, li_Width, &
															abo_Border, ab_Bold, ab_Italic, ab_Underline, as_FontFace, &
															ai_FontSize, afc_CharSet, al_Color, al_BackColor)

ii_UndoLevel ++
is_Undo[ii_UndoLevel] = ls_Undo + " destroy add_obj_" + String(ii_ObjectNum)

ii_ObjectNum ++

If ab_Execute Then
	ls_Return = idw_Requestor.Modify(ls_Modify)
Else
	ls_Return = ls_Modify
End if

Return ls_Return

end function

     
Name Owner
pfc_n_cst_dwsrv_report.of_AddCompute pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_AddCompute pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_AddCompute pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_AddCompute pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_AddCompute pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_AddCompute pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_AddCompute pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_AddCompute pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_AddCompute pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_AddCompute pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_AddCompute pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_addcompute pfc_n_cst_dwsrv_report

     
Name Owner
datawindow.describe datawindow
datawindow.modify datawindow
systemfunctions.integer systemfunctions
systemfunctions.isnull systemfunctions
systemfunctions.string systemfunctions
pfc_n_cst_string.of_globalreplace pfc_n_cst_string
pfc_n_cst_dwsrv_report.of_gettextsizepos pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_ShiftBand pfc_n_cst_dwsrv_report
pfc_n_cst_dwsrv_report.of_BuildTextModify pfc_n_cst_dwsrv_report

     
Full name
No Data

     
Name Scope
No Data