File: eaf_n_cst_datastoreservice.sru
Size: 52774
Date: Tue, 22 Jan 2008 23:39:40 +0100
HA$PBExportHeader$eaf_n_cst_datastoreservice.sru
forward
global type eaf_n_cst_datastoreservice from n_cst_baseservice
end type
end forward

global type eaf_n_cst_datastoreservice from n_cst_baseservice
string is_logservice = "n_cst_loggingservice"
end type
global eaf_n_cst_datastoreservice eaf_n_cst_datastoreservice

type variables
Protected:

constant          long           BUTTONHEIGHT=120
constant          long           BUTTONWIDTH = 370

string                           is_headersuffix = "_t"
string                           is_buttonprefix = "b_"

datastore                        ids_requestor

end variables

forward prototypes
public function long setrequestor (datastore ads_requestor)
public function long duplicate (datastore ads_source, ref datastore ads_target)
public function boolean validdataobject (string as_dataobject)
public function long getobjects (ref string as_objects[], string as_objecttype, string as_band, boolean ab_visibleonly)
public function string getcolumnheadername (string as_column, string as_suffix)
public function boolean validdataobject (datastore ads_working)
public function long createbutton (string as_action, real ar_position)
public function long createbutton (string as_action, real ar_position, long al_languageid)
public function long getextremepoints (string as_objects[], ref long al_minx, ref long al_miny, ref long al_maxx, ref long al_maxy)
public function long getobjectposition (string as_object, ref long al_x, ref long al_y, ref long al_width, ref long al_height)
public function long move (string as_objects[], long al_x, long al_y)
public function long createbutton (string as_buttonname, string as_buttontext, long al_buttonactioncode, real ar_position)
public function long calculatecolumnheight (string as_text, string as_face, long al_size, boolean ab_bold, boolean ab_italic, boolean ab_underline, long al_width, string as_additional)
protected function string buttontext (long al_action, long al_languageid)
public function long getarguments (ref string as_names[], ref string as_datatypes[])
public function long getarguments (string as_syntax, ref string as_names[], ref string as_datatypes[])
public function string getcolumnheadername (string as_column, string as_suffix, boolean ab_capitalize)
end prototypes

public function long setrequestor (datastore ads_requestor);////////////////////////////////////////////////////////////////
// Description:
//    Sets the requestor object instance
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_requestor - The requestor object instance
// Returns: 
//     1 - Success
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setRequestor ( datastore )"

inv_log.traceLog (METHOD_NAME, "")

// Validate arguments
If IsNull(ads_requestor) or Not IsValid(ads_requestor) Then
   Return -1
End If

ids_requestor = ads_requestor
Return 1

end function

public function long duplicate (datastore ads_source, ref datastore ads_target);////////////////////////////////////////////////////////////////
// Description:
//    Duplicates the "source" object into the "target" object
//
//    If the "target" object is not valid then it will be created
//    via "ads_target = create datastore"
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_source - The "source" object
//    ads_target - The "target" object
// Returns: 
//     1 - Success
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "duplicate "

If ib_trace Then
   inv_log.traceLog (METHOD_NAME, "(ads_source, ads_target)")
End If   

// Declare local variables
blob     lblb_data

// Validate arguments
If isNull(ads_source) Or Not isValid(ads_source) Then
   addError (METHOD_NAME, "Invalid ads_source argument")
   Return -1
End If
If isNull(ads_target) Or Not isValid(ads_target) Then
   ads_target = create datastore
End If
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError (METHOD_NAME, "Invalid ads_target argument")
   Return -1
End If

// Populate the working datastore with the current data (keeping all internal flags)
If ads_source.getFullState(lblb_data) < 0 Then
   addError(METHOD_NAME, "The getFullState operation failed")  
   Return -1
End If   
If ads_target.setFullState(lblb_data) < 0 Then
   addError(METHOD_NAME, "The setFullState operation failed")  
   Return -1
End If

Return 1
end function

public function boolean validdataobject (string as_dataobject);////////////////////////////////////////////////////////////////
// Description:
//    Determines if the passed in DataWindow Dataobject is valid
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_dataobject - The name of the dataobject
// Returns: 
//    true - Yes, it is valid
//    false - No, it is not valid
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "validDataobject ( string )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
boolean     lb_method_rc
string      ls_describeresult
datastore   lds_working

// Perform cleanup
as_dataobject = Trim(as_dataobject)

// Validate arguments
If isNull(as_dataobject) Or Len(as_dataobject) = 0 Then 
   addError(METHOD_NAME, "Invalid as_dataobject argument")  
   Return false
End If

// Confirm that this is a valid dataobject
lds_working = create datastore
lds_working.dataobject = as_dataobject
lb_method_rc = validDataobject(lds_working)
destroy lds_working

Return lb_method_rc
end function

public function long getobjects (ref string as_objects[], string as_objecttype, string as_band, boolean ab_visibleonly);////////////////////////////////////////////////////////////////
// Description:
//    Returns the Object Names that match the Search Criteria
//    passed in
//
//    Very similar functions on the helpereservice
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_objects[]   - Place holder for the objects
//    as_objecttype  - The object type to search for (* for all)
//    as_band        - The band to search in (* for all)
//    ab_visibleonly - Set to true if only visible objects are desired
//                      otherwise set to False
// Returns: 
//     1 - Success
//     0 - No objects
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "getObjects "

If ib_trace Then
   inv_log.traceLog (METHOD_NAME, "(ref as_objects[], as_objecttype, " + &
      "as_band, ab_visibleonly)~r~n" + &
      "as_objecttype="+as_objecttype + "~r~n" + &
      "as_band="+as_band + "~r~n" + &
      "ab_visibleonly="+string(ab_visibleonly))
End If   

// Declare local variables
constant string   TAB = "~t"
string   ls_objectsyntax
string   ls_objectname
boolean  lb_validtype
boolean  lb_validband
boolean  lb_validvisibility
string   ls_empty[]
boolean  lb_done = false
long     ll_pos_namestart
long     ll_counter=0
long     ll_pos_nexttab

// Perform cleanup
as_objects = ls_empty
as_objecttype = trim(as_objecttype)
as_band = trim(as_band)

// Validate arguments
If isNull(as_objecttype) Or Len(as_objecttype) = 0 Then 
   addError(METHOD_NAME, "Invalid as_objecttype argument")  
   Return -1
End If
If isNull(as_band) Or Len(as_band) = 0 Then 
   addError(METHOD_NAME, "Invalid as_band argument")  
   Return -1
End If
If isNull(ab_visibleonly)  Then
   addError(METHOD_NAME, "Invalid ab_visibleonly argument") 
   Return -1
End If

// Validate required references
If isNull(ids_requestor) Or Not isValid(ids_requestor) Then 
   addError(METHOD_NAME, "Invalid ids_requestor reference") 
   Return -1
End If

// Get the Object Syntax
ls_objectsyntax = ids_requestor.describe("datawindow.objects")
If isNull(ls_objectsyntax) Or ls_objectsyntax = "!" Then 
   addError(METHOD_NAME, "Invalid call for 'datawindow.Objects'") 
   Return -1
End If
If len(ls_objectsyntax) = 0 Then
   // No objects found
   Return 0
End If

// Loop around all the objects which are separated by TABs (with last one exception)
ll_pos_namestart = 1
ll_pos_nexttab =  pos(ls_objectsyntax, TAB, ll_pos_namestart)
Do While (Not lb_done)
   // Account for the last entry
   If ll_pos_nexttab = 0 Then
      ll_pos_nexttab = len(ls_objectsyntax) + 1
   End If
   
   // Get the next object name
   ls_objectname = mid(ls_objectsyntax, ll_pos_namestart, &
      (ll_pos_nexttab - ll_pos_namestart))

   // As long as there is a name, there is an entry to check
   If len(ls_objectname) > 0 Then
      // Determine if object name was requested
      lb_validtype = (as_objecttype = "*" Or &
                      ids_requestor.describe(ls_objectname + ".type") = as_objecttype)
      If lb_validtype Then
         lb_validband = (as_band = "*" Or &
                         ids_requestor.describe(ls_objectname + ".band") = as_band)
         If lb_validband Then
            lb_validvisibility = (Not ab_visibleonly Or &
                                  (ab_visibleonly And &
                                   ids_requestor.describe(ls_objectname + ".visible") = "1"))
         End If
      End If
      If lb_validtype And lb_validband And lb_validvisibility Then
         ll_counter ++
         as_objects[ll_counter] = ls_objectname
      End if
   
      // Locate the next start of a name and it next tab position
      ll_pos_namestart = ll_pos_nexttab + 1
      ll_pos_nexttab =  pos(ls_objectsyntax, TAB, ll_pos_namestart)
   Else
      lb_done = True
   End If
Loop 

// Determine the appropriate return code
If ll_counter = 0 Then
   Return 0
End If
Return 1
end function

public function string getcolumnheadername (string as_column, string as_suffix);////////////////////////////////////////////////////////////////
// Description:
//    Attempts to get the proper Header Name for the passed in 
//    Column using the passed in Suffix
//
//    Very similar function found in helperservice
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_column - The column for which to get the header name
//    as_suffix - The suffix to use to get the header name
// Returns: 
//    The column header name or the Origina passed in column name value
//    if none was found
//    "!" - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "getColumnHeaderName "

If ib_trace Then
   inv_log.traceLog (METHOD_NAME, "(as_column, as_suffix)   " + &
      "as_column="+as_column+" as_suffix="+as_suffix)
End If   

return getColumnHeaderName( as_column, as_suffix, false )

end function

public function boolean validdataobject (datastore ads_working);////////////////////////////////////////////////////////////////
// Description:
//    Determines if the passed in DataStore has a valid Dataobject
//    currently assigned
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_working - The datastore to test
// Returns: 
//    true - Yes, it is valid
//    false - No, it is not valid
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "validDataobject ( datastore )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
string      ls_describeresult

// Validate arguments
If isNull(ads_working) Or Not isValid(ads_working) Then 
   addError(METHOD_NAME, "Invalid ads_working argument") 
   Return false
End If

// Validate that the dataobject
ls_describeresult = ads_working.describe("DataWindow.Processing")
If Not IsNumber(ls_describeresult) Then
   Return false            
End If

Return true
end function

public function long createbutton (string as_action, real ar_position);////////////////////////////////////////////////////////////////
// Description:
//    Creates a Button
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_action      - The action describing the desired button
//    ar_position    - The location of the button
// Returns: 
//     1 - Success 
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "createButton "

If ib_trace And ib_detailed Then
   inv_log.traceLog (METHOD_NAME, "(as_action)   " + &
      "as_action="+string(as_action) + " ar_position=" + string(ar_position))
End If   

Return createButton(as_action, ar_position, il_languageid)
end function

public function long createbutton (string as_action, real ar_position, long al_languageid);////////////////////////////////////////////////////////////////
// Description:
//    Creates a Button
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_action      - The action describing the desired button
//    ar_position    - The location of the button
//    al_languageid  - The desired language
// Returns: 
//     1 - Success 
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "createButton "

If ib_trace Then
   inv_log.traceLog (METHOD_NAME, "(as_action)   " + &
      "as_action="+string(as_action) + " ar_position=" + string(ar_position) + " " + &
      "al_languageid="+string(al_languageid))
End If   

// Declare local variables
long     ll_buttonactioncode
long     ll_rc
string   ls_buttonname
string   ls_buttontext

// Perform cleanup
as_action = trim(as_action)

// Validate arguments
If isNull(as_action) Or len(as_action) = 0 Then 
   addError(METHOD_NAME, "Invalid as_action argument")   
   Return -1
End If
If isNull(ar_position) Or ar_position < 0 Then 
   addError(METHOD_NAME, "Invalid al_position argument") 
   Return -1
End If

// Create the "to be" button name
ls_buttonname = is_buttonprefix + as_action

// Confirm that the button does not already exists
If ids_requestor.describe(ls_buttonname+".text")  <> "!" Then
// addError(METHOD_NAME, "Button already exists ("+ls_buttonname+")")      
   Return 1
End If   

// Determine the action code and validate the as_action
Choose Case lower(as_action)
   Case "user"
      ll_buttonactioncode = 0
   Case "retrieveyield"
      ll_buttonactioncode = 1
   Case "retrieve"
      ll_buttonactioncode = 2
   Case "cancel"
      ll_buttonactioncode = 3
   Case "next"
      ll_buttonactioncode = 4
   Case "prior"
      ll_buttonactioncode = 5
   Case "first"
      ll_buttonactioncode = 6
   Case "last"
      ll_buttonactioncode = 7
   Case "sort"
      ll_buttonactioncode = 8
   Case "filter"
      ll_buttonactioncode = 9
   Case "delete"
      ll_buttonactioncode = 10
   Case "append"
      ll_buttonactioncode = 11
   Case "insert"
      ll_buttonactioncode = 12
   Case "update"
      ll_buttonactioncode = 13
   Case "saveas"
      ll_buttonactioncode = 14
   Case "print"
      ll_buttonactioncode = 15
   Case "preview"
      ll_buttonactioncode = 16
   Case "previewrulers"
      ll_buttonactioncode = 17
   Case "querymode"
      ll_buttonactioncode = 18
   Case "querysort"
      ll_buttonactioncode = 19
   Case "queryclear"
      ll_buttonactioncode = 20
   Case Else
      addError (METHOD_NAME, "Invalid as_action argument")
      Return -1 
End Choose

// Determine the button Text
ls_buttontext = buttonText (ll_buttonactioncode, al_languageid)

ll_rc = createButton(ls_buttonname, ls_buttontext, ll_buttonactioncode, ar_position)
Return ll_rc
end function

public function long getextremepoints (string as_objects[], ref long al_minx, ref long al_miny, ref long al_maxx, ref long al_maxy);////////////////////////////////////////////////////////////////
// Description:
//    Returns the Extreme Points of the passed in objects
// Revisions
//    2.0   - Initial version
// Arguments:  
//    as_objects[]   - The objects to be checked 
//    al_minx        - Place holder for the minimum X
//    al_miny        - Place holder for the minimum Y
//    al_maxx        - Place holder for the maximum X
//    al_maxy        - Place holder for the maximum Y
// Returns: 
//     1 - Success
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "getExtremePoints "

If ib_trace Then
   inv_log.traceLog (METHOD_NAME, "(as_objects[], al_minx, " + &
      "al_miny, al_maxx, al_maxy")
End If   

// Declare local variables
long     ll_rc
long     ll_x
long     ll_y
long     ll_width
long     ll_height
long     ll_upper
long     ll_idx

// Perform cleanup
al_minx=30000
al_miny=30000
al_maxx=-30000
al_maxy=-30000

// Validate arguments
If IsNull(as_objects) Or UpperBound(as_objects)=0 Then
   addError(METHOD_NAME, "Invalid as_objects argument")
   Return -1
End If

// Loop to determine each extreme point
ll_upper = UpperBound (as_objects)
For ll_idx = 1 to ll_upper
   ll_rc = this.getObjectPosition(as_objects[ll_idx], ll_x, ll_y, ll_width, ll_height)
   If ll_rc <= 0 Then
      addError(METHOD_NAME, "Operation getObjectPosition() failed")
      Return -1
   End if
   
   //Determine the Min and Max points
   If ll_x < al_minx Then al_minx = ll_x
   If ll_y < al_miny Then al_miny = ll_y
   If ll_x + ll_width > al_maxx Then al_maxx = ll_x + ll_width
   If ll_y + ll_height > al_maxy Then al_maxy = ll_y + ll_height
Next

If ib_debug And ib_detailed Then
   inv_log.debugLog (METHOD_NAME,  inv_constants.MESSAGE_TYPE_EAF_DEBUG, "Returning minX="+string(al_minx)+ &
      " minY="+string(al_miny)+" maxX="+string(al_maxx)+" maxY="+string(al_maxy))
End If

Return 1
end function

public function long getobjectposition (string as_object, ref long al_x, ref long al_y, ref long al_width, ref long al_height);////////////////////////////////////////////////////////////////
// Description:
//    Returns the Object Position Attributes for the passed in object
// Revisions
//    2.0   - Initial version
// Arguments:  
//    as_object   - The object to be checked 
//    al_x        - Place holder for the X 
//    al_y        - Place holder for the Y 
//    al_width    - Place holder for the Width or X2
//    al_height   - Place holder for the Height or Y2
// Returns: 
//     1 - Success
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "getObjectPosition "

If ib_trace Then
   inv_log.traceLog (METHOD_NAME, "(as_objects, al_x, al_y, al_width, al_height")
End If   

// Declare local variables
string   ls_type
string   ls_result
long     ll_x 
long     ll_y 
long     ll_height
long     ll_width

// Perform cleanup
as_object = trim(as_object)
al_x = 0
al_y = 0
al_width = 0
al_height = 0

// Validate arguments
If isNull(as_object) Or Len(as_object) = 0 Then
   addError (METHOD_NAME, "Invalid as_object argument")
End IF

// Validate required reference
If isNull(ids_requestor) or Not IsValid(ids_requestor) Then
   addError (METHOD_NAME, "Invalid ids_requestor reference")
   Return -1
End If

// Continue validating arguments
ls_type = ids_requestor.describe(as_object+'.Type')
If isNull(ls_type) or ls_type='!' or ls_type='?' Then
   addError (METHOD_NAME, "Invalid as_object argument (object not found)")
   Return -1
End If

// Determine where to get the position from
If pos(ls_type, "line") > 0 Then
   // This is a Line object
   ls_result = ids_requestor.describe(as_object+'.X1')
   If isNull(ls_result) or Not isNumber(ls_result) Then
      Return -1
   End If
   ll_x = long(ls_result)

   ls_result = ids_requestor.describe(as_object+'.Y1')
   If isNull(ls_result) or Not isNumber(ls_result) Then
      Return -1
   End If
   ll_y = long(ls_result)

   ls_result = ids_requestor.describe(as_object+'.X2')
   If isNull(ls_result) or Not isNumber(ls_result) Then
      Return -1
   End If
   ll_width = long(ls_result)

   ls_result = ids_requestor.describe(as_object+'.Y2')
   If isNull(ls_result) or Not isNumber(ls_result) Then
      Return -1
   End If
   ll_height = long(ls_result)   
Else
   // This is any other than a Line object
   ls_result = ids_requestor.describe(as_object+'.X')
   If isNull(ls_result) or Not isNumber(ls_result) Then
      Return -1
   End If
   ll_x = long(ls_result)

   ls_result = ids_requestor.describe(as_object+'.Y')
   If isNull(ls_result) or Not isNumber(ls_result) Then
      Return -1
   End If
   ll_y = long(ls_result)

   ls_result = ids_requestor.describe(as_object+'.Width')
   If isNull(ls_result) or Not isNumber(ls_result) Then
      Return -1
   End If
   ll_width = long(ls_result)

   ls_result = ids_requestor.describe(as_object+'.Height')
   If isNull(ls_result) or Not isNumber(ls_result) Then
      Return -1
   End If
   ll_height = long(ls_result)
End If

// Success - OK to populate the reference variables
al_x = ll_x
al_y = ll_y
al_width = ll_width
al_height = ll_height
Return 1
end function

public function long move (string as_objects[], long al_x, long al_y);////////////////////////////////////////////////////////////////
// Description:
//    Moves the passed in objects by the passed in values
//    regarding the X and Y Axis
// Revisions
//    2.0   - Initial version
// Arguments:  
//    as_objects  - The object to be moved
//    al_x        - The amount to move the object along the X axis
//    al_y        - The amount to move the object along the Y axis
// Returns: 
//     1 - Success
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "move "

If ib_trace Then
   inv_log.traceLog (METHOD_NAME, "(as_objects[], al_x, al_y    " + &
      "where al_x="+string(al_x)+" al_y="+string(al_y))
End If   

// Declare local variables
string   ls_type
string   ls_modifyexp
string   ls_result
long     ll_upper
long     ll_idx

// Validate arguments
ll_upper = upperBound(as_objects)
If isNull(as_objects) Or  ll_upper = 0 Then
   addError (METHOD_NAME, "Invalid as_objects argument")
End IF

// Validate required reference
If isNull(ids_requestor) or Not IsValid(ids_requestor) Then
   addError (METHOD_NAME, "Invalid ids_requestor reference")
   Return -1
End If

For ll_idx = 1 to ll_upper
   // Continue validating arguments
   ls_type = ids_requestor.describe(as_objects[ll_idx]+'.Type')
   If isNull(ls_type) or ls_type='!' or ls_type='?' Then
      addError (METHOD_NAME, "Invalid as_objects argument (object not found) ll_idx="+string(ll_idx))
      Return -1
   End If
   
   // Determine which attributes to use
   If pos(ls_type, "line") > 0 Then
      // This is a Line object
      If al_x <> 0 Then
         ls_result = ids_requestor.describe(as_objects[ll_idx]+'.X1')
         If isNull(ls_result) or Not isNumber(ls_result) Then
            addError(METHOD_NAME, "describe (X1) operation failed for " + as_objects[ll_idx])
            Return -1
         End If
         ls_modifyexp += as_objects[ll_idx]+'.X1=' + string(long(ls_result) + al_x) + " "
      End If         
   
      If al_y <> 0 Then    
         ls_result = ids_requestor.describe(as_objects[ll_idx]+'.Y1')
         If isNull(ls_result) or Not isNumber(ls_result) Then
            addError(METHOD_NAME, "describe (Y1) operation failed for " + as_objects[ll_idx])
            Return -1
         End If
         ls_modifyexp += as_objects[ll_idx]+'.X1=' + string(long(ls_result) + al_x) + " "
      End If         
   
      ls_result = ids_requestor.describe(as_objects[ll_idx]+'.X2')
      If isNull(ls_result) or Not isNumber(ls_result) Then
         Return -1
      End If
         
      ls_result = ids_requestor.describe(as_objects[ll_idx]+'.Y2')
      If isNull(ls_result) or Not isNumber(ls_result) Then
         Return -1
      End If
      
   Else
      // This is any other than a Line object
      If al_x <> 0 Then
         ls_result = ids_requestor.describe(as_objects[ll_idx]+'.X')
         If isNull(ls_result) or Not isNumber(ls_result) Then
            addError(METHOD_NAME, "describe (X) operation failed for " + as_objects[ll_idx])
            Return -1
         End If
         ls_modifyexp += as_objects[ll_idx]+'.X=' + string(long(ls_result) + al_x) + " "
      End If
   
      If al_y <> 0 Then 
         ls_result = ids_requestor.describe(as_objects[ll_idx]+'.Y')
         If isNull(ls_result) or Not isNumber(ls_result) Then
            addError(METHOD_NAME, "describe (Y) operation failed for " + as_objects[ll_idx])
            Return -1
         End If
         ls_modifyexp += as_objects[ll_idx]+'.Y=' + string(long(ls_result) + al_y) + " "
      End If
   
   End If
Next  

// Now execute all the moves in one operation
ls_result = ids_requestor.modify(ls_modifyexp)
If len(ls_result) > 0 Then
   addError(METHOD_NAME, "Modify operation failed - ls_modifyexp=" + ls_modifyexp + &
      " ("+ls_result+")")
   Return -1
End If

Return 1
end function

public function long createbutton (string as_buttonname, string as_buttontext, long al_buttonactioncode, real ar_position);////////////////////////////////////////////////////////////////
// Description:
//    Creates a Button
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_buttonname        - The button name
//    as_buttontext        - The button text
//    al_buttonactioncode  - The button action code
//    ar_position          - The button position
// Returns: 
//     1 - Success 
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "createButton "

If ib_trace Then 
   inv_log.traceLog (METHOD_NAME, "(as_buttonname, as_buttontext, " + &
      "al_buttonactioncode, ar_position)~r~n" + &
      "   as_buttonname="+as_buttonname + "~r~n" + &
      "   as_buttontext="+as_buttontext + "~r~n" + &
      "   al_buttonactioncode="+string(al_buttonactioncode) + "~r~n" + &      
      "   ar_position=" + string(ar_position))
End If   

// Declare local variables
constant string   BAND = 'footer'
long     ll_x
long     ll_y = 40
long     ll_height = this.BUTTONHEIGHT
long     ll_width = this.BUTTONWIDTH
long     ll_footerheight
long     ll_border = 10
long     ll_current_footerheight
string   result
string   ls_modifyexp

// Perform cleanup
as_buttonname = trim(as_buttonname)

// Validate arguments
If isNull(as_buttonname) Or Len(as_buttonname) = 0 Then 
   addError(METHOD_NAME, "Invalid as_buttonname argument")  
   Return -1
End If
If isNull(as_buttontext) Then 
   // Ok to have an empty button text
   addError(METHOD_NAME, "Invalid as_buttontext argument")  
   Return -1
End If
If isNull(al_buttonactioncode) Or al_buttonactioncode < 0 Or &
 al_buttonactioncode > 20 Then 
   addError(METHOD_NAME, "Invalid al_buttonactioncode argument")  
   Return -1
End If
If isNull(ar_position) Or ar_position < 0  Then 
   addError(METHOD_NAME, "Invalid al_position argument") 
   Return -1
End If

// Validate required references
If isNull(ids_requestor) Or Not isValid(ids_requestor) Then 
   addError(METHOD_NAME, "Invalid ids_requestor reference") 
   Return -1
End If

// Confirm that the button does not already exists
If ids_requestor.describe(as_buttonname+".text")  <> "!" Then
// addError(METHOD_NAME, "Button already exists ("+as_buttonname+")")      
   Return 1
End If   

// Calculate the X pos
ll_x = (ll_border * ar_position) + (ll_width * (ar_position - 1 ))

// Get the current and desired footer height
ll_footerheight = (2 * ll_y) + ll_height
ll_current_footerheight = long(ids_requestor.object.DataWindow.Footer.Height)

// If needed, modify the footer height
If ll_footerheight > ll_current_footerheight Then
   ls_modifyexp = " DataWindow.Footer.Height='"+string(ll_footerheight) + "'"
End If

// 
ls_modifyexp += "  create button(band="+BAND+  &
" color='0'"  +  & 
" x='"+string(ll_x)+"' " +  & 
" y='"+string(ll_y)+"' " +  & 
" height='"+string(ll_height)+"' " +  & 
" width='"+string(ll_width)+"' " +  & 
" name="+as_buttonname +  & 
" Action='"+string(al_buttonactioncode) + "'"+  & 
" text='"+as_buttontext+"' " +  & 
" HTextAlign='0' " +  & 
" VTextAlign='0' " +  & 
" font.face='Tahoma'" +  & 
" font.height='-8' " +  & 
" font.weight='400' " +  & 
" font.family='2' " +  & 
" font.pitch='2' " +  & 
" font.charset='0' " +  & 
" font.italic='0' " +  & 
" font.strikethrough='0' " +  & 
" font.underline='0' " +  & 
" background.mode='0' " +  & 
" background.color='67108864')"

// Attempt to create the button
result = ids_requestor.modify(ls_modifyexp)
If len(result) > 0 Then 
   addError(METHOD_NAME, "Failed to create button ("+as_buttonname+") " + &
      "with ls_modifyexp ="+ ls_modifyexp )  
   Return -1
End If

Return 1
end function

public function long calculatecolumnheight (string as_text, string as_face, long al_size, boolean ab_bold, boolean ab_italic, boolean ab_underline, long al_width, string as_additional);////////////////////////////////////////////////////////////////
// Description:
//    Calculates the Column Height needed for the in Text and properties.
//
//    The caller can pass an additional modify string to properly 
//    set up the environment to determine the height.
// Revisions
//    2.0   - Initial version
// Arguments:  
//    as_text     - 
//    as_face -
//    al_size -
//    ab_bold     -
//    ab_italic   -
//    ab_underline-
//    al_width    -
//    as_additional  - Additional modify statement 
// Returns: 
//    >= 0 - The calculated height
//    -1  - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "calculateColumnHeight "

// In progress ---CJQ
If ib_trace And ib_detailed Then
   inv_log.traceLog (METHOD_NAME, "(as_text, as_face, al_size, ab_bold, " + &
      "ab_italic, ab_underline, al_width, as_additional ) ~r~n" + &
      "~r~nas_text="+as_text + &
      "~r~nas_face="+as_face + &
      "~r~nal_size="+string(al_size) + &
      "~r~nab_bold ="+string(ab_bold) + &
      "~r~nab_italic="+string(ab_italic) + &
      "~r~nab_underline="+string(ab_underline) + &
      "~r~nal_width="+string(al_width) + &
      "~r~nas_additional="+as_additional)
End If   

// Declare Local variables
constant string COLUMN_NAME = "column1"
datastore   lds_working
string      ls_modifyexp
string      ls_result
long        ll_rc
long        ll_height

// Validate arguments
If isNull(as_text) Then
   addError(METHOD_NAME, "Invalid as_text argument")
   Return -1
End If
If isNull(as_face) Then
   addError(METHOD_NAME, "Invalid as_face argument")
   Return -1
End If
If isNull(al_size) Then
   addError(METHOD_NAME, "Invalid al_size argument")
   Return -1
End If
If isNull(ab_bold) Then
   addError(METHOD_NAME, "Invalid ab_bold argument")
   Return -1
End If
If isNull(ab_italic) Then
   addError(METHOD_NAME, "Invalid ab_italic argument")
   Return -1
End If
If isNull(ab_underline) Then
   addError(METHOD_NAME, "Invalid ab_underline argument")
   Return -1
End If
If isNull(al_width) Or al_width < 0 Then
   addError(METHOD_NAME, "Invalid al_width argument")
   Return -1   
End If

// Prepare the environment
lds_working = Create datastore
lds_working.dataobject = "d_sizecalculation"
If lds_working.rowCount() <> 1 Then
   ll_rc = lds_working.reset()
   ll_rc = lds_working.insertRow(0)
   If ll_rc <> 1 Then
      addError(METHOD_NAME, "Invalid attempt to insert row while on datastore using d_sizecalculation")
      destroy lds_working
      Return -1
   End If
End If

// Put the information into the COLUMN_NAME
ll_rc = lds_working.setItem(1, COLUMN_NAME, as_text)
If ll_rc <= 0 Then
   addError(METHOD_NAME, "Invalid setItem() operation")
   destroy lds_working
   Return -1
End If

// Build a string with the appropriate Modify Expression based on the
// arguments passed in
If len(trim(as_face)) > 0 Then
   // (i.e., SYSTEM, COURIER)
   ls_modifyexp += " " + COLUMN_NAME + ".Font.Face='" + as_face + "'"
End If
ls_modifyexp += " " + COLUMN_NAME + ".Font.Height='" + string(al_size) + "'" 
If ab_bold Then
   ls_modifyexp += " " + COLUMN_NAME + ".Font.Weight='700'"
Else
   ls_modifyexp += " " + COLUMN_NAME + ".Font.Weight='400'"
End If
If ab_italic Then
   ls_modifyexp += " " + COLUMN_NAME + ".Font.Italic='1'"
Else
   ls_modifyexp += " " + COLUMN_NAME + ".Font.Italic='0'"
End If
If ab_underline Then
   ls_modifyexp += " " + COLUMN_NAME+".Font.Underline='1'"
Else
   ls_modifyexp += " " + COLUMN_NAME+".Font.Underline='0'"
End If
ls_modifyexp += " " + COLUMN_NAME+".Width='" + string(al_width)+"'"

// Perform the Modify
If len(trim(ls_modifyexp)) > 0 Then 
   ls_result = lds_working.modify(ls_modifyexp)
   If len(ls_result) > 0 Then
      addError(METHOD_NAME, "Invalid Modify expression ls_modifyexp="+ &
         ls_modifyexp+" ("+ls_result+")")
      Return -1
   End If
End If

// Perform the Additional Modify
If len(trim(as_additional)) > 0 Then 
   ls_result = lds_working.modify(as_additional)
   If len(ls_result) > 0 Then
      // Will log but allow for continuation
      addError(METHOD_NAME, "Invalid as_additional argument " + &
         " as_additional=" + as_additional+" ("+ls_result+")")
   End If
End If

// Determine the height of the Row
ls_result = lds_working.Describe( "Evaluate('rowheight()', 1)" )
If isNull(ls_result) Or Not isNumber(ls_result) Then
   addError(METHOD_NAME, "Invalid Describe/Evaluate operation")
   Return -1
End If
ll_height = long(ls_result)

destroy lds_working

Return ll_height


end function

protected function string buttontext (long al_action, long al_languageid);////////////////////////////////////////////////////////////////
// Description:
//    Get the Button Text
//
//    This method should be extended in order to support other
//    languages
// Revisions
//    1.0   - Initial version
// Arguments:  
//    al_action      - The action describing the desired button
//    al_languageid  - The desired language
// Returns: 
//    The Button Text in the appropriate language
//    "?" + English Day Name + "?" - Failure due to Unsupported Language
//             In this case, simply code descendant to add support
//    "!" - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "buttonText "

If ib_trace And ib_detailed Then
   inv_log.traceLog (METHOD_NAME, "(al_action, al_languageid)   " + &
      "al_action="+string(al_action) + " al_languageid=" + string(al_languageid))
End If   

// Declare local variables
string   ls_buttontext
string   ls_english[21] = {"", "Retrieve(Yield)", "Retrieve", "Cancel" ,"Page Next", &
                           "Page Prior", "Page First", "Page Last" , "Sort", "Filter", &
                           "Delete Row", "Append Row", "Insert Row", "Save", "Save Rows As", &
                           "Print", "Preview", "Preview Rulers", "Query Mode", "Query Sort", &
                           "Query Clear"}
string   ls_spanish[21] = {"", "Recuperar()", "Recuperar", "Anular" ,"Pg Siguiente", &
                           "Pg Anterior", "Pg Primera", "Pg Ultima" , "Ordenar", "Filtro", &
                           "Borrar Fila", "Anadir Fila", "Insercion F", "Actualizar", "Salvar Filas", &
                           "Imprimir", "Preview", "Preview Regla", "Consulta Modo", "Consulta Orden", &
                           "Consulta Limpia"}                           
string   ls_simplifiedchinese[21] = {"", "$$HEX2$$fb8bd653$$ENDHEX$$($$HEX2$$2d4e626b$$ENDHEX$$)", "$$HEX2$$fb8bd653$$ENDHEX$$", "$$HEX2$$d653886d$$ENDHEX$$" ,"$$HEX2$$0b4e7598$$ENDHEX$$", &
                           "$$HEX2$$0a4e7598$$ENDHEX$$", "$$HEX3$$2c7b004e7598$$ENDHEX$$", "$$HEX4$$00670e54004e7598$$ENDHEX$$" , "$$HEX2$$92638f5e$$ENDHEX$$", "$$HEX2$$c78fe46e$$ENDHEX$$", &
                           "$$HEX2$$20526496$$ENDHEX$$", "$$HEX2$$9e58a052$$ENDHEX$$", "$$HEX2$$d2636551$$ENDHEX$$", "$$HEX2$$dd4f585b$$ENDHEX$$", "$$HEX3$$dd4f585b8e4e$$ENDHEX$$", &
                           "$$HEX2$$53627053$$ENDHEX$$", "$$HEX2$$8498c889$$ENDHEX$$", "$$HEX4$$8498c88907683a5c$$ENDHEX$$", "$$HEX4$$e567e28b216a0f5f$$ENDHEX$$", "$$HEX2$$e567e28b$$ENDHEX$$", &
                           "$$HEX4$$e567e28b056e6496$$ENDHEX$$"}
string ls_tradionalchinese[21]   = {"", "$$HEX2$$808bd653$$ENDHEX$$($$HEX2$$2d4e626b$$ENDHEX$$)", "$$HEX2$$808bd653$$ENDHEX$$", "$$HEX2$$d653886d$$ENDHEX$$" ,"$$HEX2$$0b4e0198$$ENDHEX$$", &
                           "$$HEX2$$0a4e0198$$ENDHEX$$", "$$HEX3$$2c7b004e0198$$ENDHEX$$", "$$HEX4$$00678c5f004e0198$$ENDHEX$$" , "$$HEX2$$92638f5e$$ENDHEX$$", "$$HEX2$$4e90fe6f$$ENDHEX$$", &
                           "$$HEX2$$2a526496$$ENDHEX$$", "$$HEX2$$9e58a052$$ENDHEX$$", "$$HEX2$$d2636551$$ENDHEX$$", "$$HEX2$$dd4f585b$$ENDHEX$$", "$$HEX3$$dd4f585bbc65$$ENDHEX$$", &
                           "$$HEX2$$17527053$$ENDHEX$$", "$$HEX2$$1098bd89$$ENDHEX$$", "$$HEX4$$1098bd893a5c8f89$$ENDHEX$$", "$$HEX4$$e567628a216a0f5f$$ENDHEX$$", "$$HEX2$$e567628a$$ENDHEX$$", &
                           "$$HEX4$$e567628a056e6496$$ENDHEX$$"}


// Validate arguments
If isNull(al_action) Or al_action < 0 Or al_action > 20 Then
   addError(METHOD_NAME, "Invalid al_action argument")
   Return "!"
End If
If isNull(al_languageid) Or al_languageid <= 0 Then 
   addError(METHOD_NAME, "Invalid al_languageid argument")  
   Return "!"
End If

// Add one to the Action Code to make it match the Array
al_action ++

// Determine the button Text
Choose Case al_languageid
   Case 1 // English
      ls_buttontext = ls_english[al_action]
   Case 2 // Spanish
      ls_buttontext = ls_spanish[al_action]
   case 3 // Simplified Chinese
      ls_buttontext = ls_simplifiedchinese[al_action]
   case 4 // Tradional Chinese
      ls_buttontext = ls_tradionalchinese[al_action]
   Case Else
      ls_buttontext = "?" + ls_english[al_action] + "?"
      addError(METHOD_NAME, "Unsuported languageID. " + &
         "Code support on descendant of this method")
End Choose

// Use Custom Button Text
choose case al_action
   Case 5
      ls_buttontext = ">>"
   Case 6
      ls_buttontext = "<<"
   Case 7
      ls_buttontext = "|<"
   Case 8
      ls_buttontext = ">|"
end choose

Return ls_buttontext

end function

public function long getarguments (ref string as_names[], ref string as_datatypes[]);////////////////////////////////////////////////////////////////
// Description:
//    Returns the Argument Names and Datatypes for the Requestor
//    object
//
//    There are two places where datawindow arguments can be found
//       One set is found next to the "arguments" keyword
//       Another is found each next to an "args" keyword 
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_names[]     - Place holder to hold the Argument Names
//    as_datatypes[] - Place holder to hold the Argument Datatypes
// Returns: 
//     1 - Success - Arguments found
//     0 - Success - No arguments found
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "getArguments ( REF string[], REF string[] )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
long                       ll_pos_current
long                       ll_pos_namebegin
long                       ll_pos_nameend
long                       ll_pos_typebegin
long                       ll_pos_typeend
long                       ll_count
string                     ls_debug
string                     ls_dwsyntax
string                     ls_names[]
string                     ls_types[]
string                     ls_empty[]
string                     ls_working
boolean                    lb_foundargument = false

// Perform cleanup
as_names = ls_empty
as_datatypes = ls_empty

// Validate required references
If IsNull(ids_requestor) Or Not IsValid(ids_requestor) Then
   addError (METHOD_NAME, "Invalid ids_requestor reference")
   Return -1
End If

// Validate the dataobject
If Not validDataobject(ids_requestor) Then
   addError (METHOD_NAME, "Invalid dataobject")
   Return -1
End If

// Get the DataWindow Syntax
ls_dwsyntax = lower (ids_requestor.describe ("DataWindow.Syntax")) 
If isNull(ls_dwsyntax) Or len(trim(ls_dwsyntax)) = 0 Or &
   ls_dwsyntax = "!" Or ls_dwsyntax = "?" Then
   addError (METHOD_NAME, "Invalid DataWindow.Syntax describe operation")
   Return -1
End If   

if getArguments( ls_dwsyntax, as_names, as_datatypes ) = -1 then
   return -1
end if

Return 1
end function

public function long getarguments (string as_syntax, ref string as_names[], ref string as_datatypes[]);////////////////////////////////////////////////////////////////
// Description:
//    Returns the Argument Names and Datatypes based on the passed in syntax
//
//    There are two places where datawindow arguments can be found
//       One set is found next to the "arguments" keyword
//       Another is found each next to an "args" keyword 
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_syntax      - DataWindow syntax
//    as_names[]     - Place holder to hold the Argument Names
//    as_datatypes[] - Place holder to hold the Argument Datatypes
// Returns: 
//     1 - Success - Arguments found
//     0 - Success - No arguments found
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "getArguments ( string, REF string[], REF string[] )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
long                       ll_pos_current
long                       ll_pos_namebegin
long                       ll_pos_nameend
long                       ll_pos_typebegin
long                       ll_pos_typeend
long                       ll_count
string                     ls_debug
string                     ls_dwsyntax
string                     ls_names[]
string                     ls_types[]
string                     ls_empty[]
string                     ls_working
boolean                    lb_foundargument = false

n_cst_helperservice        lnv_helper

try
   // Perform cleanup
   as_names = ls_empty
   as_datatypes = ls_empty
   
   ls_dwsyntax = as_syntax
   
   // Look for the "arguments" keyword
   ll_pos_current = pos (ls_dwsyntax, "arguments=((", 1)
   
   If ll_pos_current > 0 Then
      // Loop around until there are no more arguments
      Do While (mid(ls_dwsyntax, ll_pos_current, 1) <> ")") And   (ll_pos_current < Len(ls_dwsyntax))
         // An argument has been found
         ll_count ++
         If lb_foundargument Then ll_pos_current ++
         lb_foundargument = true
         
         // Perform loop cleanup
         ll_pos_namebegin = 0
         ll_pos_nameend = 0
         ll_pos_typebegin = 0
         ll_pos_typeend = 0
   
         // Get the column Name (begins with an '"' and ends with an '"')
         ll_pos_namebegin = pos (ls_dwsyntax, "~"", ll_pos_current) + 1
         ll_pos_nameend = pos (ls_dwsyntax, "~"", ll_pos_namebegin)
         If ll_pos_namebegin <=0 Or ll_pos_nameend <=0 Then
            addError (METHOD_NAME, "Did not find Expected 'arguments' values "+ &
               "ll_pos_namebegin=" + string(ll_pos_namebegin) + " " + &
               "ll_pos_nameend=" + string(ll_pos_nameend))        
            Return -1      
         End If
         ls_names[ll_count] = trim (mid (ls_dwsyntax, ll_pos_namebegin, &
            ll_pos_nameend - ll_pos_namebegin))
   
         // Get the matching column Datatype (begins 3 spaces after 
         // name and ends with a ')' )
         ll_pos_typebegin = ll_pos_nameend + 3
         ll_pos_typeend = pos (ls_dwsyntax, ")", ll_pos_typebegin)
         If ll_pos_typebegin <=0 Or ll_pos_typeend <=0 Then 
            addError (METHOD_NAME, "Did not find Expected 'arguments' values "+ &
               "ll_pos_typebegin=" + string(ll_pos_typebegin) + " " + &
               "ll_pos_typeend=" + string(ll_pos_typeend))                 
            Return -1
         End If         
         ls_types[ll_count] = trim (mid (ls_dwsyntax, ll_pos_typebegin, ll_pos_typeend - ll_pos_typebegin))
         If Mid(ls_dwsyntax, ll_pos_current, 1) <> ")" Then // move to next argument
            ll_pos_current = ll_pos_typeend + 1
         End If         
      Loop
   Else
      // Check for the "arg" keywork
      ll_pos_current = pos (ls_dwsyntax, "arg(", 1)
   
      // Loop until all the arguments have been found (if any).
      Do While ll_pos_current > 0 
         // An argument has been found
         ll_count ++    
   //    If lb_foundargument Then ll_pos_current ++
         lb_foundargument = true
   
         // Perform loop cleanup
         ll_pos_namebegin = 0
         ll_pos_nameend = 0
         ll_pos_typebegin = 0
         ll_pos_typeend = 0
         
         // Get the column Name
         ll_pos_namebegin = pos (ls_dwsyntax, "name", ll_pos_current)
         ll_pos_nameend = pos (ls_dwsyntax, "type", ll_pos_namebegin)
         If ll_pos_namebegin <=0 Or ll_pos_nameend <=0 Then 
            addError (METHOD_NAME, "Did not find Expected 'arg' values "+ &
               "ll_pos_namebegin=" + string(ll_pos_namebegin) + " " + &
               "ll_pos_nameend=" + string(ll_pos_nameend))           
            Return -1
         End If
         ls_working = mid (ls_dwsyntax, ll_pos_namebegin, ll_pos_nameend - ll_pos_namebegin) 
         
         lnv_helper = create n_cst_helperservice
         inv_log.propagateSettings( lnv_helper )
         ls_working = lnv_helper.globalReplace (ls_working, "~~~"", "", true) 
         
         ls_names[ll_count] = trim (lnv_helper.getKeyValue (ls_working, "name", "=" ))
   
         // Get the matching column Datatype
         ll_pos_typebegin = ll_pos_nameend
         ll_pos_typeend = pos (ls_dwsyntax, ")", ll_pos_nameend) 
         If ll_pos_typebegin <=0 Or ll_pos_typeend <=0 Then 
            addError (METHOD_NAME, "Did not find Expected 'arg' values "+ &
               "ll_pos_typebegin=" + string(ll_pos_typebegin) + " " + &
               "ll_pos_typeend=" + string(ll_pos_typeend))                 
            Return -1
         End If
         ls_working = mid (ls_dwsyntax, ll_pos_typebegin, &
            ll_pos_typeend - ll_pos_typebegin) 
         ls_types[ll_count] = trim (lnv_helper.getKeyValue (ls_working, "type", "=" ))
         
         // Look for the next ARG( keyword.
         ll_pos_current = pos (ls_dwsyntax, "arg(", ll_pos_typeend)     
      Loop
   End If
   
   // See if arguments were found
   If Not lb_foundargument Then
      Return 0
   End If
   
   // Return the arguments found
   as_names = ls_names
   as_datatypes = ls_types
finally
   if isValid( lnv_helper ) then
      destroy lnv_helper
   end if
end try

Return 1
end function

public function string getcolumnheadername (string as_column, string as_suffix, boolean ab_capitalize);////////////////////////////////////////////////////////////////
// Description:
//    Attempts to get the proper Header Name for the passed in 
//    Column using the passed in Suffix
//
//    Very similar function found in helperservice
// Revisions
//    3.0   - Initial version
// Arguments:  
//    as_column - The column for which to get the header name
//    as_suffix - The suffix to use to get the header name
//    ab_capitalize - Turn on capitalization
// Returns: 
//    The column header name or the Origina passed in column name value
//    if none was found
//    "!" - Failure
////////////////////////////////////////////////////////////////
// Copyright $$HEX1$$a900$$ENDHEX$$ 2000 - 2007 Youngsoft Inc.  All rights reserved.
// Any distribution of the Youngsoft Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "getColumnHeaderName "

If ib_trace Then
   inv_log.traceLog (METHOD_NAME, "(as_column, as_suffix)   " + &
      "as_column="+as_column+" as_suffix="+as_suffix)
End If   

// Declare local variables
string                     ls_header
string                     ls_holdheader

n_cst_stringservice        lnv_string

try
   // Perform cleanup
   as_column = trim(as_column)
   as_suffix = trim(as_suffix)
   
   // Validate arguments
   If isNull(as_column) Or len(as_column) = 0 Then
      addError(METHOD_NAME, "Invalid as_column argument")
      Return "!"
   End If   
   If isNull(as_suffix) or len(as_suffix) = 0 Then
      as_suffix = is_headersuffix
   End If   
   
   // Validate required references
   If isNull(ids_requestor) Or Not isValid(ids_requestor) Then 
      addError(METHOD_NAME, "Invalid ids_requestor reference") 
      Return "!"
   End If
   
   // Attempt to get the column header name
   ls_header = ids_requestor.describe ( as_column + as_suffix + ".Text" )
   If isNull(ls_header) Or ls_header="" Or ls_header="?" Or ls_header = "!" Then
      // Failed on the attempt to get the column header name
      ls_header = as_column
   End If   
   
   lnv_string = create n_cst_stringservice
   inv_log.propagateSettings( lnv_string )
   
   // Remove Special characters
   ls_header = lnv_string.globalReplace ( ls_header, "~r", " ", true) 
   ls_header = lnv_string.globalReplace ( ls_header, "~n", " ", true) 
   ls_header = lnv_string.globalReplace ( ls_header, "_",  " ", true) 
   ls_header = lnv_string.globalReplace ( ls_header, "~"", "", true) 
   ls_header = lnv_string.globalReplace ( ls_header, "~'", "", true) 
   ls_header = lnv_string.globalReplace ( ls_header, "~~", "", true) 
   ls_header = lnv_string.globalReplace ( ls_header, ":", "", true ) 
   
   destroy lnv_string
   
   // Hold the string prior to the last step (just in case it fails)
   ls_holdheader = ls_header
   
   // Capitalize the Column Header string
   if ab_capitalize then
      ls_header = ids_requestor.describe ( "evaluate('wordCap(~"" + ls_header + "~")',0)" )
      If isNull(ls_header) Or ls_header="" Or ls_header="?" Or ls_header = "!" Then
         // Failed on the attempt to Capitalize string
         ls_header = ls_holdheader
      End If   
   end if
finally
   
end try

Return ls_header
end function

on eaf_n_cst_datastoreservice.create
call super::create
end on

on eaf_n_cst_datastoreservice.destroy
call super::destroy
end on