Content Supported by Sourcelens Consulting

7NVERSION =   3.00filelibPixelsClass1customfilelibE*justext 
*juststem 
*addbs 
*justfname 
*forceext 
*justpath 
���� ���+%�M-��UH���T��C�������i��%���
��A�
�����UNERRORTHISHCONNECTHANDLECSQLCCURSORNAMEPROCESSERRORT����exec ����UTHISCSQLCSPNAME���������(�C�����y�$T������ C�����%��C�����u�T������,�����UNARRAYCOUNTTHISAPARAMSCSQLE���
�������C���z��T��C�������C��x��UCMESSAGETEXT	ASQLERRORB�����UTHISCSQL+4�����%�C��
��h�>��C�2You must pass at least 3 parameters to this class.�x��B�-�����������C�����
��%�C��
����T����
����T����
���%�C������T����	sqlresult���
�T����
����
��C����
��C����UCSPNAMEHCONNECTHANDLEAPARAMSCCURSORNAMETHISSETSQL	SETPARAMSdosql,��setsql���	setparams���processerror���getsql���Init��1q��A3�2q�Aa�AA3q��A�3�21�qA1!A"��!A��2���
	��
�`}� �#)�custom*Height = 19
Width = 97
Name = "execsp"
vccursorname
hconnecthandle
csql
cspname
*dosql 
^aparams[1,0] 
*setsql 
*setparams 
*processerror 
*getsql 
execspcustom1ClassPixelsVccursorname
hconnecthandle
csql
cspname
aparams
setsql
setparams
processerror
execsp	containerOWidth = 50
Height = 15
Visible = .F.
BackColor = 0,0,255
Name = "menulib"
*showmenu 
*deactivatemenu 
menulib	container1ClassPixelsmenulibcustomName = "arraylib"
arraylibcustom	�PROCEDURE justext
* Return just the extension from "filname"
LPARAMETERS m.filname
LOCAL m.ext
m.filname = this.justfname(m.filname)   && prevents problems with ..\ paths
m.ext = ""
IF AT('.', m.filname) > 0
   m.ext = SUBSTR(m.filname, AT('.', m.filname) + 1, 3)
ENDIF
RETURN UPPER(m.ext)

ENDPROC
PROCEDURE juststem
* Return just the stem name from "filname"
LPARAMETERS m.filname
IF RAT('\',m.filname) > 0
   m.filname = SUBSTR(m.filname,RAT('\',m.filname)+1,255)
ENDIF
IF RAT(':',m.filname) > 0
   m.filname = SUBSTR(m.filname,RAT(':',m.filname)+1,255)
ENDIF
IF AT('.',m.filname) > 0
   m.filname = SUBSTR(m.filname,1,AT('.',m.filname)-1)
ENDIF
RETURN ALLTRIM(UPPER(m.filname))

ENDPROC
PROCEDURE addbs
* Add a backslash unless there is one already there.
LPARAMETER m.pathname
LOCAL m.separator
m.separator = IIF(_MAC,":","\")
m.pathname = ALLTRIM(UPPER(m.pathname))
IF !(RIGHT(m.pathname,1) $ '\:') AND !EMPTY(m.pathname)
   m.pathname = m.pathname + m.separator
ENDIF
RETURN m.pathname

ENDPROC
PROCEDURE justfname
* Return just the filename (i.e., no path) from "filname"
LPARAMETERS m.filname
LOCAL clocalfname, cdirsep
clocalfname = SYS(2027,m.filname)
cdirsep = IIF(_mac,':','\')
IF RAT(m.cdirsep ,m.clocalfname) > 0
   m.clocalfname= SUBSTR(m.clocalfname,RAT(m.cdirsep,m.clocalfname)+1,255)
ENDIF
IF AT(':',m.clocalfname) > 0
   m.clocalfname= SUBSTR(m.clocalfname,AT(':',m.clocalfname)+1,255)
ENDIF
RETURN ALLTRIM(UPPER(m.clocalfname))

ENDPROC
PROCEDURE forceext
* Force filename to have a particular extension.
LPARAMETERS m.filname,m.ext
LOCAL m.ext, m.pname
IF SUBSTR(m.ext,1,1) = "."
   m.ext = SUBSTR(m.ext,2,3)
ENDIF
m.pname = THIS.justpath(m.filname)
m.filname = THIS.justfname(UPPER(ALLTRIM(m.filname)))
IF AT('.',m.filname) > 0
   m.filname = SUBSTR(m.filname,1,AT('.',m.filname)-1) + '.' + m.ext
ELSE
   m.filname = m.filname + '.' + m.ext
ENDIF
RETURN THIS.addbs(m.pname) + m.filname

ENDPROC
PROCEDURE justpath
* Returns just the pathname.
LPARAMETERS m.filname
LOCAL cdirsep
cdirsep = IIF(_mac,':','\')
m.filname = SYS(2027,ALLTRIM(UPPER(m.filname)))
IF m.cdirsep $ m.filname
   m.filname = SUBSTR(m.filname,1,RAT(m.cdirsep,m.filname))
   IF RIGHT(m.filname,1) = m.cdirsep AND LEN(m.filname) > 1 ;
            AND SUBSTR(m.filname,LEN(m.filname)-1,1) <> ':'
         filname = SUBSTR(m.filname,1,LEN(m.filname)-1)
   ENDIF
   RETURN m.filname
ELSE
   RETURN ''
ENDIF

ENDPROC
Name = "filelib"
customarraylibPixelsClass1$*insaitem 
*delaitem 
*acolscan 
�PROCEDURE insaitem
* Inserts an array element into an array.
* For 1-D array
* aArray - array name
* sContents - contents to insert
* iRow - row to insert into
LPARAMETER aArray,sContents,iRow
IF ALEN(aArray) = 1 AND EMPTY(aArray[1])
  aArray[1]=m.sContents
ELSE
  DIMENSION aArray[ALEN(aArray)+1,1]
  IF PARAM()=2
    aArray[ALEN(aArray)]=m.sContents
  ELSE
    =AINS(aArray,m.iRow+1)
	aArray[m.iRow+1]=m.sContents
  ENDIF	
ENDIF

ENDPROC
PROCEDURE delaitem
* Generic routine to delete an array element.
* aArray- array to scan
* wziRow - row to delete
LPARAMETERS aArray,wziRow
IF ALEN(aArray)>=m.wziRow
  IF ALEN(aArray)=1
    aArray=''
  ELSE
    =ADEL(aArray,m.wziRow)
    DIMENSION aArray[ALEN(aArray)-1]
  ENDIF
ENDIF

ENDPROC
PROCEDURE acolscan
* This function does an ASCAN for a specific row
* aSearch - array to scan
* sExpr - expression to scan
* nColumn - column to scan
* lRetRow - return row (T) or array element (F)
LPARAMETER aSearch,sExpr,nColumn,lRetRow
LOCAL apos
IF TYPE('m.nColumn')#'N'
	nColumn =1
ENDIF
IF TYPE('m.lRetRow')#'L'
	m.RetRow = .F.
ENDIF

m.apos = 1
DO WHILE .T.
	m.apos = ASCAN(aSearch,m.sExpr,m.apos)
	DO CASE
	CASE m.apos=0	&&did not find match
		EXIT
	CASE ASUBSCRIPT(aSearch,m.apos,2)=m.nColumn
		EXIT
	OTHERWISE
		m.apos=m.apos+1
	ENDCASE
ENDDO
IF m.lRetRow
	RETURN ASUBSCRIPT(aSearch,m.apos,1)
ELSE
	RETURN m.apos
ENDIF

ENDPROC
��� ffq%d�/��Ur�����������������$%�C���C�taMenub�C��\�B�-���
T�����T��C������%�������B�-���T��C�������t&�u���s���C���C����W������(����*�(T��C��C����C��6��s�����"������-1����!DEACTIVATE POPUP _popShortcutMenu�t���<���%�Cl�����B�-���
%�����T��CCl����-%�C��
�C�lcMenuSelectionb�C	����T��C�����%�C�����T��CCC������6�����?�T��CCC������6����%�C����Y�B�-���&lcOnSelection
U	TAMENU
TCONSELECTION
LCONSELECTIONLNMENUCOUNTLNCOUNT
LLDOUBLEARRAY
LCMENUITEMLCMENUSELECTION_POPSHORTCUTMENUu��U_POPSHORTCUTMENU

����UTHISDEACTIVATEMENUshowmenu,��deactivatemenu��Destroy=��1�1��BqA�1qA�Q�Uq�QA���qA�1��A��A��A�qA!3�3�2�+#2-AV6)fS��� ::�/%7�2m�U������!%�C�����
CC���	��E�T������
��������C���������%�C������T��C������
��������C���
�����T���
�����
�����UAARRAY	SCONTENTSIROW{����%�C����
���t�%�C������B�
T������p���C���
������C��������UAARRAYWZIROWX���������%�C�	m.nColumnb�N��D�
T������%�C�	m.lRetRowb�L��r�
T�
��-���T�
�����+�a���T�
��C���
��
����
H������
������!��C���
����
�����!�2��T�
���
������%��
���>�B�C���
������Q�B��
����UASEARCHSEXPRNCOLUMNLRETROWAPOSRETROWinsaitem,��delaitem��acolscan���1�Q����a�AA3�aA��!AAA36q��A��A����1A�A�QAA�Q��A2����$):aPROCEDURE showmenu
LPARAMETERS taMenu,tcOnSelection
LOCAL lcOnSelection,lnMenuCount,lnCount,llDoubleArray
LOCAL lcMenuItem,lcMenuSelection
EXTERNAL ARRAY taMenu

IF PARAMETERS()=0 OR TYPE("taMenu")#"C"
	RETURN .F.
ENDIF
lnMenuCount=0
lnMenuCount=ALEN(taMenu,1)
IF lnMenuCount=0
	RETURN .F.
ENDIF
llDoubleArray=(ALEN(taMenu,2)>0)
ACTIVATE SCREEN
DEACTIVATE POPUP _popShortcutMenu
DEFINE POPUP _popShortcutMenu ;
		FROM MROW(),MCOL() ;
		MARGIN ;
		RELATIVE ;
		SHORTCUT
FOR lnCount = 1 TO lnMenuCount
	lcMenuItem=IIF(llDoubleArray,taMenu[lnCount,1],taMenu[lnCount])
	DEFINE BAR lnCount OF _popShortcutMenu PROMPT (lcMenuItem)
ENDFOR
ON SELECTION POPUP _popShortcutMenu DEACTIVATE POPUP _popShortcutMenu
ACTIVATE POPUP _popShortcutMenu
RELEASE POPUP _popShortcutMenu
IF BAR()=0
	RETURN .F.
ENDIF
IF llDoubleArray
	 lcMenuSelection=taMenu[BAR(),2]
	 IF NOT EMPTY(lcMenuSelection) AND TYPE("lcMenuSelection")=="C"
	 	lcOnSelection=ALLTRIM(lcMenuSelection)
	 ENDIF
	 IF EMPTY(lcOnSelection)
		lcOnSelection=ALLTRIM(IIF(EMPTY(tcOnSelection),"",tcOnSelection))
	 ENDIF
ELSE
	lcOnSelection=ALLTRIM(IIF(EMPTY(tcOnSelection),"",tcOnSelection))
ENDIF
IF EMPTY(lcOnSelection)
	RETURN .F.
ENDIF
&lcOnSelection

ENDPROC
PROCEDURE deactivatemenu
DEACTIVATE MENU _popShortcutMenu

ENDPROC
PROCEDURE Destroy
this.DeactivateMenu

ENDPROC
PROCEDURE dosql
LOCAL nError

nError = SQLEXEC (this.hConnectHandle, this.cSQL, this.cCursorName)
IF nError < 0
	this.ProcessError
ENDIF

ENDPROC
PROCEDURE setsql
this.cSQL = "exec " + this.cSPName
ENDPROC
PROCEDURE setparams
LOCAL nArrayCount
FOR nArrayCount = 1 TO ALEN (this.aParams)
	this.cSQL = this.cSQL + ' ' + this.aParams[nArrayCount]
	IF nArrayCount <> ALEN (this.aParams)
		this.cSQL = this.cSQL + ','
	ENDIF
ENDFOR

ENDPROC
PROCEDURE processerror
LOCAL cMessageText
DIMENSION aSQLError[5]

=AERROR (aSQLError)
cMessageText = aSQLError[1,2]
=MESSAGEBOX (cMessageText)

ENDPROC
PROCEDURE getsql
RETURN this.cSQL
ENDPROC
PROCEDURE Init
*This sample class library is used for SQL Pass Thru and can allow you to execute stored procedures
* on your host database. For example, the sample belows shows how you might want to called a stored
* procedure called "UpdateAuthorName" on the database "pubs". The result set is returned to a cursor.

*	Sample code
*!*	sqldisconn(0)
*!*	DIME aParams[3]
*!*	aParams[1] = "'172-32-1176'"
*!*	aParams[2] = "'S'"
*!*	aParams[3] = "'E'"
*!*	hConnect = SQLCONNECT ('pubs','sa','')
*!*	set classlib to HOME()+"classes\utility.vcx"
*!*	x=createobj('ExecSP', 'UpdateAuthorName', hConnect, @aParams)
*!*	x.dosql()

#DEFINE BADPARMS_LOC	"You must pass at least 3 parameters to this class."

PARAMETERS cSPName, hConnectHandle, aParams, cCursorName

IF PARAMETERS() < 3
	MESSAGEBOX(BADPARMS_LOC)
	RETURN .F.
ENDIF

DIMENSION this.aParams[1]
ACOPY(aParams,this.aParams)

IF NOT EMPTY (cSPName)
	this.cSPName = m.cSPName
ENDIF

this.hConnectHandle = m.hConnectHandle

IF PARAMETERS () = 3
	this.cCursorName = 'sqlresult'
ELSE
	this.cCursorName = m.cCursorName
ENDIF

this.SetSQL()
this.SetParams()

ENDPROC
���� }}�`%��GV�U�	��
��	��
��T�
��C�
�����T�
�����%�C�.�
����x�%T�
��C�
�C�.�
���\���
B�C�
�f��UFILNAMEEXTTHIS	JUSTFNAME�	��
��%�C�\�
�����G�%T�
��C�
�C�\�
�����\���%�C�:�
�������%T�
��C�
�C�:�
�����\���%�C�.�
������%T�
��C�
��C�.�
��\���B�CC�
�f���UFILNAME�	��
��	��
��T�
��C�3��:��\6��T�
��CC�
�f���(%�C�
��R�\:
�	C�
��
	����T�
���
��
����B��
���UPATHNAME	SEPARATOR�	��
������T��C���
�]��T��C�3��:��\6��%�C�
��
�������&T�
��C�
�C�
��
�����\���%�C�:�
������%T�
��C�
�C�:�
����\���B�CC�
�f���UFILNAMECLOCALFNAMECDIRSEP��
��
����
��
��%�C�
���\�.��S�T�
��C�
���\���T�
��C�
�����T�
��CCC�
��f����%�C�.�
������0T�
��C�
��C�.�
��\�.�
������T�
���
��.�
����B�C�
����
���UFILNAMEEXTPNAMETHISJUSTPATH	JUSTFNAMEADDBS	��
�����T��C�3��:��\6��T�
��C��CC�
�f�]��%��
��
�����"T�
��C�
��C�
��
��\��G%�C�
��R�
��C�
�>�	�C�
�C�
�>��\�:	����T��C�
��C�
�>�\���B��
�����	B�����UFILNAMECDIRSEPjustext,��juststem���addbs���	justfnamex��forceextx��justpath���1�����QA�3��QA�QA�QA�3���Q�qA�3��Q��aA�QA�3����A�����A�3�q��Q!r�A���A2,
K�
�&�(+��79��	H)}