home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
clarion
/
library
/
memoed
/
me_util.cla
< prev
next >
Wrap
Text File
|
1992-02-15
|
6KB
|
174 lines
!═════════════════════════════════════════════════════════════════════════
!
! %%keyword%% '%n'
! 'ME_UTIL.CLA' - Utility Library functions for MEMOEDIT
!
! %%keyword%% '%v'
! Revision Number: '1'
! %%keyword%% '%d'
! Revision Date : '15-Feb-92'
!
! Copyright : Bobcat Systems (c) 1992
! Author : Robert J. Pupazzoni
! CIS:[70441,204]
!
! Compiler : Clarion Professional Developer v. 2.1, Batch 2105
!
!
! DESCRIPTION
!
! This module contains various generic funcitons used in MEMOEDIT.
!
!═════════════════════════════════════════════════════════════════════════
ME_Util MEMBER()
! ═════════════════════════════════════════════════════════════════════════
! Find Next Word Left
! ═════════════════════════════════════════════════════════════════════════
Word_Left FUNCTION( sLine, ibCol )
! Parameters:
sLine STRING(255) ! Line of text
ibCol BYTE ! Column to start in
! Locals:
aLine BYTE,DIM(255),OVER(sLine) ! String array alias
CODE
LOOP WHILE (ibCol > 0) ! Loop
IF aLine[ibCol] <> 32 THEN BREAK. ! Break on non-space
ibCol -= 1 ! Decrement column index
. ! End loop
LOOP WHILE (ibCol > 0) ! Loop
IF aLine[ibCol] = 32 THEN BREAK. ! Break on space
ibCol -= 1 ! Decrement column index
. ! End loop
RETURN( ibCol+1 ) !
! ═════════════════════════════════════════════════════════════════════════
! Find Next Word Right
! ═════════════════════════════════════════════════════════════════════════
Word_Right FUNCTION( sLine, ibCol )
! Parameters:
sLine STRING(255) ! Line of text
ibCol BYTE ! Column to start in
! Locals:
aLine BYTE,DIM(255),OVER(sLine) ! String array alias
ibMaxLen BYTE ! Max. length of string
CODE
ibMaxLen = LEN(CLIP(sLine)) ! Get max length
LOOP WHILE (ibCol <= ibMaxLen) ! Loop
IF aLine[ibCol] = 32 THEN BREAK. ! Break on space
ibCol += 1 ! Increment column index
. ! End loop
LOOP WHILE (ibCol <= ibMaxLen) ! Loop
IF aLine[ibCol] <> 32 THEN BREAK. ! Break on non-space
ibCol += 1 ! Increment column index
. ! End loop
RETURN( ibCol ) !
! ═════════════════════════════════════════════════════════════════════════
! Insert Characters in String
! ═════════════════════════════════════════════════════════════════════════
Str_Insert FUNCTION( sSource, sTarget, ibIndex )
! Parameters:
sSource EXTERNAL ! String to insert
sTarget EXTERNAL ! String to insert into
ibIndex BYTE ! Position to insert into
! Return:
sRetVal STRING(255) ! Returned string
CODE
IF CLIP(sSource) ! If not all spaces
sRetVal = SUB(sTarget, 1, ibIndex-1) & | ! Insert string
CLIP(sSource) & | !
SUB(sTarget, ibIndex, 255) !
ELSE ! Else
sRetVal = SUB(sTarget, 1, ibIndex-1) & | ! Insert a space
' ' & | !
SUB(sTarget, ibIndex, 255) !
. ! Endif
RETURN( sRetVal ) ! Return result
! ═════════════════════════════════════════════════════════════════════════
! Delete Characters in String
! ═════════════════════════════════════════════════════════════════════════
Str_Delete FUNCTION( sString, ibIndex, ibCount )
! Parameters:
sString EXTERNAL ! String to operate on
ibIndex BYTE ! Start index
ibCount BYTE ! # of chars to delete
! Return:
sRetVal STRING(255) ! Returned string
CODE
sRetVal = SUB(sString, 1, ibIndex-1) & | ! Delete string portion
SUB(sString, ibIndex+ibCount, 255) !
RETURN( sRetVal ) ! Return result
! ═════════════════════════════════════════════════════════════════════════
! Remap Strings Within Another String
! ═════════════════════════════════════════════════════════════════════════
Str_ReMap FUNCTION( sString, sFrom, sTo )
! Parameters:
sString EXTERNAL ! String to operate on
sFrom EXTERNAL ! 'From' string
sTo EXTERNAL ! 'To' string
! Return:
sRetVal STRING(255) ! Returned string
! Locals:
ibIndex LONG ! Loop index
CODE
sRetVal = sString ! Copy to string
ibIndex = INSTRING(sFrom, sRetVal, 1) ! Get first ocurrence
LOOP WHILE ibIndex ! Loop while found
sRetVal = Str_Delete(sRetVal, ibIndex, LEN(CLIP(sFrom)))
sRetVal = Str_Insert(sTo, sRetVal, ibIndex) ! Replace ocurrence
ibIndex = INSTRING(sFrom, sRetVal, 1, ibIndex+LEN(CLIP(sTo)))
. ! End loop
RETURN( sRetVal ) ! Return result
! ═════════════════════════════════════════════════════════════════════════
! Return Greater of Two Integers
! ═════════════════════════════════════════════════════════════════════════
Greater_Of FUNCTION( ilArg1, ilArg2 )
! Parameters:
ilArg1 LONG ! Argument #1
ilArg2 LONG ! Argument #2
CODE
IF ilArg1 > ilArg2 THEN RETURN(ilArg1) ELSE RETURN(ilArg2).
! ═════════════════════════════════════════════════════════════════════════
! Return Lesser of Two Integers
! ═════════════════════════════════════════════════════════════════════════
Lesser_Of FUNCTION( ilArg1, ilArg2 )
! Parameters:
ilArg1 LONG ! Argument #1
ilArg2 LONG ! Argument #2
CODE
IF ilArg1 < ilArg2 THEN RETURN(ilArg1) ELSE RETURN(ilArg2).