of_dwarguments


pfcdwsrv.pbl   >   pfc_n_cst_dwsrv   >   of_dwarguments   

Full name pfc_n_cst_dwsrv.of_dwarguments
Access public
Extend of integer
Return value integer
Prototype public function integer of_dwarguments(ref string[],ref string[])

Name Datatype
No Data

Name Datatype
li_currpos integer
li_nameendpos integer
li_namestartpos integer
li_numargs integer
li_typeendpos integer
li_typestartpos integer
lnv_string n_cst_string
ls_args string[]
ls_syntax string
ls_types string[]
ls_workstring string

public function integer of_dwarguments (ref string as_argnames[], ref string as_argdatatypes[]);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_DWArguments (Format 2)
//
//	Access:  Public
//
//	Arguments:
//	as_argnames[]:  A string array (by reference) to hold the argument names
//	as_argdatatypes[]:  A string array (by reference) to hold argument datatypes
//
//	Returns:  Integer
//	The number of arguments found
//	-1 = error
//
//	Description:  To determine if the requesting datawindow has arguments and 
//		what they are
//
//		Note: This function has a (Format 1) which is very similar.
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	5.0   Initial version
//	5.0.01 Fixed bug so that reference arguments are populated correctly
//	5.0.01 Function returns -1 if DW requestor is not valid
// 5.0.02 Added Stored Procedures support.
// 5.0.04 Fixed bug which prevented the looping around multiple arguments.
//
//////////////////////////////////////////////////////////////////////////////
//
//	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.
//
//////////////////////////////////////////////////////////////////////////////
integer	li_currpos=1
integer	li_namestartpos
integer	li_nameendpos
integer	li_typestartpos
integer	li_typeendpos
integer	li_numargs=0
string	ls_syntax
string	ls_args[]
string	ls_types[]
string	ls_workstring
n_cst_string lnv_string

// Clear reference values.
as_argnames = ls_args
as_argdatatypes = ls_types

// Check DW requestor
if IsNull(idw_requestor) or not IsValid(idw_requestor) then
	return -1
end if

// Get the Requestor datawindow syntax.
ls_syntax = Lower (idw_requestor.Describe ("DataWindow.Syntax")) 

// Look for the ARGUMENTS keyword.
li_currpos = Pos (ls_syntax, "arguments=((", 1)

If li_currpos > 0 Then
	// Loop until all the arguments have been found.
	do while (Mid(ls_syntax, li_currpos, 1) <> ")") And (li_currpos < Len(ls_syntax))
		// Reset values.
		li_namestartpos = 0
		li_nameendpos = 0
		li_typestartpos = 0
		li_typeendpos = 0

		// New argument has been found.
		li_numargs++

		// Get the column NAME.
		li_namestartpos = Pos (ls_syntax, "~"", li_currpos) + 1
		li_nameendpos = Pos (ls_syntax, "~"", li_namestartpos)
		If li_namestartpos <=0 or li_nameendpos <=0 Then Return -1		
		ls_args[li_numargs] = Trim (Mid (ls_syntax, li_namestartpos, li_nameendpos - li_namestartpos))

		// Get the column TYPE.
		li_typestartpos = li_nameendpos + 3
		li_typeendpos = Pos (ls_syntax, ")", li_typestartpos)
		If li_typestartpos <=0 or li_typeendpos <=0 Then Return -1		
		ls_types[li_numargs] = Trim (Mid (ls_syntax, li_typestartpos, li_typeendpos - li_typestartpos))
		
		// Update the current position past the current argument.
		li_currpos = li_typeendpos	+ 1
	loop
Else
	// This will find Arguments that have been defined on the datawindow object.
	// They are not necesarily being used by the datawindow SQL statement.
	
	// Look for the ARG( keyword.
	li_currpos = Pos (ls_syntax, "arg(", 1)

	// Loop until all the arguments have been found (if any).
	do while li_currpos > 0 

		// Reset values.
		li_namestartpos = 0
		li_nameendpos = 0
		li_typestartpos = 0
		li_typeendpos = 0
		
		// New argument has been found.
		li_numargs++

		// Get the column NAME.
		li_namestartpos = Pos (ls_syntax, "name", li_currpos)
		li_nameendpos = Pos (ls_syntax, "type", li_namestartpos)
		If li_namestartpos <=0 or li_nameendpos <=0 Then Return -1				
		ls_workstring = Mid (ls_syntax, li_namestartpos, li_nameendpos - li_namestartpos) 
		ls_workstring = lnv_string.of_GlobalReplace (ls_workstring, "~~~"", "") 
		ls_args[li_numargs] = Trim (lnv_string.of_GetKeyValue (ls_workstring, "name", "=" ))

		// Get the column TYPE.
		li_typestartpos = li_nameendpos
		li_typeendpos = Pos (ls_syntax, ")", li_nameendpos) 
		If li_typestartpos <=0 or li_typeendpos <=0 Then Return -1		
		ls_workstring = Mid (ls_syntax, li_typestartpos, li_typeendpos - li_typestartpos) 
		ls_types[li_numargs] = Trim (lnv_string.of_GetKeyValue (ls_workstring, "type", "=" ))
		
		// Look for the next ARG( keyword.
		li_currpos = Pos (ls_syntax, "arg(", li_typeendpos)		
	loop
End If

// Return arguments found
as_argnames = ls_args
as_argdatatypes = ls_types
return li_numargs
end function

     
Name Owner
No Data

     
Name Owner
datawindow.describe datawindow
systemfunctions.isnull systemfunctions
systemfunctions.isvalid systemfunctions
systemfunctions.len systemfunctions
systemfunctions.lower systemfunctions
systemfunctions.mid systemfunctions
systemfunctions.pos systemfunctions
systemfunctions.trim systemfunctions
pfc_n_cst_string.of_globalreplace pfc_n_cst_string
pfc_n_cst_string.of_getkeyvalue pfc_n_cst_string

     
Full name
No Data

     
Name Scope
No Data