$CPU 8086 ' make compatible with XT systems $LIB ALL OFF ' turn off all PowerBASIC libraries $ERROR ALL OFF ' turn off all PowerBASIC error checking $OPTIMIZE SIZE ' optimize for smaller code '$COMPILE EXE ' compile to a UNIT (.PBU) $COMPILE UNIT ' compile to a UNIT (.PBU) DEFINT A-Z ' Required for all numeric functions, forces PB to not ' include floating point in UNIT (makes it smaller) '/*------------------------------------------------------------------*/ $CODE SEG "MLIB4" '/*------------------------------------------------------------------*/ ' DELSTR(STRING,START,LENGTH) ' Delete subString. ' Deletes the sub-string of STRING that begins at start ' character and is of LENGTH. If LENGTH is 0 then the rest of ' the string is deleted (including the character at start). If ' START is greater than the length of STRING then the string is ' returned unchanged. ' EXAMPLE: DELSTR('abcd',3) = 'ab' ' DELSTR('abcde',3,2) = 'abe' ' DELSTR('abcde',6) = 'abcde' '/*------------------------------------------------------------------*/ FUNCTION DELSTR(BYVAL X AS STRING, BYVAL S AS INTEGER, BYVAL L AS INTEGER) PUBLIC AS STRING TL = LEN(X) IF S > TL THEN XRET$ = X ELSE IF L = 0 THEN XRET$ = LEFT$(X,S-1) ELSE TL$ = LEFT$(X,S-1) IF (S+L) > TL THEN TR$ = "" ELSE TR$ = RIGHT$(X,TL-S-L+1) END IF XRET$ = TL$ + TR$ END IF END IF DELSTR = XRET$ END FUNCTION '/*------------------------------------------------------------------*/ ' CLS ' A$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ' PRINT "1234567890123456789012345678901234567890" ' PRINT A$ ' PRINT DELSTR(A$,3,0) ' PRINT DELSTR(A$,3,2) ' PRINT DELSTR(A$,20,30) ' INPUT Z