home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 December
/
PCWorld_2000-12_cd.bin
/
Software
/
Topware
/
scrworx
/
_SETUP.1
/
vbasic.slf
< prev
next >
Wrap
Text File
|
2000-07-13
|
3KB
|
102 lines
DEFINT A-Z
DECLARE FUNCTION StrTrimLeft$ (a$, b$)
DECLARE FUNCTION StrTrimRight$ (a$, b$)
DECLARE FUNCTION StrTrim$ (a$, b$)
DECLARE SUB StrSplitString (SplitString$, SplitChars$, SplitField$(), SplitCount%)
DECLARE FUNCTION Min% (a%, b%)
DECLARE FUNCTION StrInstrLeft% (SearchStart%, SearchIn$, SearchFor$)
DECLARE FUNCTION StrAscii% (a$)
CLS
DIM LineData$(1 TO 2)
WHILE NOT EOF(1)
LINE INPUT #1, l$
CALL StrSplitString(l$, ";", LineData$(), SplitCount)
IF SplitCount THEN
LineData$(1) = StrTrim$(LineData$(1), CHR$(9) + " ")
IF LEN(LineData$(1)) THEN
PRINT #2, " " + CHR$(34) + LineData$(1) + CHR$(34) + ","
END IF
END IF
WEND
PRINT #2, " NULL"
PRINT #2, "};"
CLOSE 2
CLOSE 1
SYSTEM
FUNCTION Min% (a%, b%)
IF a% < b% THEN Min% = a% ELSE Min% = b%
END FUNCTION
SUB StrSplitString (SplitString$, SplitChars$, SplitField$(), SplitCount)
StartIndex = LBOUND(SplitField$)
LastIndex = UBOUND(SplitField$)
ActualIndex& = StartIndex
SplitCount = 0
LastPos = 1
FoundPos = StrInstrLeft(LastPos, SplitString$, SplitChars$ + CHR$(34))
GetDirect = 0
EndLoop = 0
TempString$ = ""
DO WHILE FoundPos > 0
FoundCharVal = StrAscii(MID$(SplitString$, FoundPos, 1))
PosDiff = (FoundPos - LastPos) + 1
SELECT CASE FoundCharVal
CASE 34
TempString$ = TempString$ + MID$(SplitString$, LastPos, PosDiff - 1)
SELECT CASE EndLoop
CASE 0
EndLoop = 2
CASE 3
EndLoop = 0
END SELECT
CASE ELSE
TempString$ = TempString$ + MID$(SplitString$, LastPos, PosDiff - 1)
SplitField$(ActualIndex&) = TempString$
TempString$ = ""
ActualIndex& = ActualIndex& + 1
IF ActualIndex& > LastIndex THEN
ActualIndex& = LastIndex
EndLoop = 1
END IF
END SELECT
SELECT CASE EndLoop
CASE 0
DO
LastPos = FoundPos + 1
FoundPos = StrInstrLeft(LastPos, SplitString$, SplitChars$)
LOOP WHILE LastPos = FoundPos
FoundPos = StrInstrLeft(LastPos, SplitString$, SplitChars$ + CHR$(34))
CASE 1
FoundPos = 0
LastPos = LEN(SplitString$) + 1
CASE 2
EndLoop = 3
LastPos = FoundPos + 1
FoundPos = StrInstrLeft(LastPos, SplitString$, CHR$(34))
IF FoundPos = 0 THEN
SplitString$ = SplitString$ + CHR$(34)
FoundPos = LEN(SplitString$)
END IF
END SELECT
LOOP
IF EndLoop = 0 THEN
IF LEN(TempString$) > 0 THEN
SplitField$(ActualIndex&) = TempString$
ELSEIF LastPos <= LEN(SplitString$) THEN
SplitField$(ActualIndex&) = MID$(SplitString$, LastPos)
ELSE
ActualIndex& = ActualIndex& - 1
END IF
END IF
FOR a = ActualIndex& + 1 TO LastIndex
SplitField$(a) = ""
NEXT
SplitCount = (ActualIndex& - StartIndex) + 1
END SUB