2012-11-28 14:53 UTC+0100 Viktor Szakats (harbour syenar.net)
* contrib/xhb/xhb.hbx
* contrib/xhb/xhbcomp.prg
+ added OCCURS() from xhb which appears there in CT lib,
but it's not a CT function. Reworked to meet Harbour standards
and to avoid compiler warning.
This commit is contained in:
@@ -10,6 +10,13 @@
|
||||
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
|
||||
*/
|
||||
|
||||
2012-11-28 14:53 UTC+0100 Viktor Szakats (harbour syenar.net)
|
||||
* contrib/xhb/xhb.hbx
|
||||
* contrib/xhb/xhbcomp.prg
|
||||
+ added OCCURS() from xhb which appears there in CT lib,
|
||||
but it's not a CT function. Reworked to meet Harbour standards
|
||||
and to avoid compiler warning.
|
||||
|
||||
2012-11-28 13:19 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* harbour/src/vm/classes.c
|
||||
! fixed passing be reference pseudo object variables which
|
||||
|
||||
@@ -330,6 +330,7 @@ DYNAMIC NumOrX
|
||||
DYNAMIC NumRolX
|
||||
DYNAMIC NumToHex
|
||||
DYNAMIC NumXorX
|
||||
DYNAMIC Occurs
|
||||
DYNAMIC Ole2txtError
|
||||
DYNAMIC OleError
|
||||
DYNAMIC os_IsWin2000
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
* Harbour Project source code:
|
||||
* xhb compatibility functions
|
||||
*
|
||||
* Copyright 2007 Viktor Szakats (harbour syenar.net)
|
||||
* Copyright 2007-2012 Viktor Szakats (harbour syenar.net)
|
||||
* Copyright 2004 Eduardo Fernandes <modalsist@yahoo.com.br> (original of OCCURS())
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -147,3 +148,27 @@ CREATE CLASS Block FUNCTION _Block
|
||||
OPERATOR "==" FUNCTION xhb_EEqual()
|
||||
|
||||
ENDCLASS
|
||||
|
||||
/* Return the number of times s1 occurs in s2 */
|
||||
FUNCTION Occurs( s1, s2 )
|
||||
|
||||
LOCAL nCount := 0
|
||||
LOCAL nPos
|
||||
|
||||
IF HB_ISSTRING( s1 ) .AND. ;
|
||||
HB_ISSTRING( s2 ) .AND. ;
|
||||
Len( s1 ) != 0 .AND. ;
|
||||
Len( s2 ) != 0
|
||||
|
||||
DO WHILE .T.
|
||||
nPos := At( s1, s2 )
|
||||
IF nPos > 0
|
||||
nCount++
|
||||
s2 := SubStr( s2, nPos + 1 )
|
||||
ELSE
|
||||
EXIT
|
||||
ENDIF
|
||||
ENDDO
|
||||
ENDIF
|
||||
|
||||
RETURN nCount
|
||||
|
||||
Reference in New Issue
Block a user