$IFNDEF __FILEOPS_INC
$DEFINE __FILEOPS_INC
FUNCTION Quote$(StringToQuote AS STRING) AS STRING
StringToQuote = CHR$(34) + StringToQuote + CHR$(34)
Result = REPLACESUBSTR$(stringtoquote , CHR$(34) + CHR$(34) , CHR$(34))
END FUNCTION
FUNCTION StripPath(fullname AS STRING) AS STRING
Result = LEFT$(fullname , rinstr(fullname , "\"))
END FUNCTION
FUNCTION StripFileName(fullname AS STRING) AS STRING
Result = RIGHT$(fullname , LEN(fullname) - rinstr(fullname , "\"))
END FUNCTION
FUNCTION StripFileExt(fullname AS STRING) AS STRING
Result = RIGHT$(fullname , LEN(fullname) - rinstr(fullname , ".") + 1)
END FUNCTION
FUNCTION FileNameNoExt(fullname AS STRING) AS STRING
fullname = RIGHT$(fullname , LEN(fullname) - rinstr(fullname , "\"))
Result = LEFT$(fullname , rinstr(fullname , ".") - 1)
END FUNCTION
FUNCTION FullPathNoExt(fullname AS STRING) AS STRING
Result = LEFT$(fullname , rinstr(fullname , ".") - 1)
END FUNCTION
FUNCTION C_Style(fullname AS STRING) AS STRING
fullname = REPLACESUBSTR$(fullname , "\\" , "\")
Result = REPLACESUBSTR$(fullname , "\" , "/")
END FUNCTION
FUNCTION SysDir(dir AS STRING) AS STRING
DIM fo_reg AS QREGISTRY
fo_reg.RootKey = &H80000001
fo_reg.openkey("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" , 0)
Result = fo_reg.readstring(dir) + "\"
END FUNCTION
SUB FileCopy(FileSrc$ AS STRING, FileDst$ AS STRING)
DIM FileSrc AS QFILESTREAM
DIM FileDst AS QFILESTREAM
FileSrc.OPEN(FileSrc$ , fmOpenRead)
FileDst.OPEN(FileDst$ , fmCreate)
FileDst.CopyFrom(FileSrc , 0)
FileSrc.CLOSE
FileDst.CLOSE
END SUB
$ENDIF
FUNCTION TRIM$(Str AS STRING) AS STRING
Result = LTRIM$(RTRIM$(Str))
END FUNCTION
FUNCTION StripTabs(TheString AS STRING) AS STRING
IF INSTR(TheString, Tab) THEN
StripTabs = REPLACESUBSTR$(TheString, Tab, CHR$(32))
ELSE
StripTabs = TheString
END IF
END FUNCTION
FUNCTION NOT!(n AS INTEGER) AS INTEGER
IF n = 0 THEN RESULT = 1 ELSE RESULT = 0
END FUNCTION
SUB LaunchMe(Sender AS QLABEL)
DEFSTR s = Sender.CAPTION
DEFINT l, i = INSTR(UCASE$(s), "HTTP://")
IF i = 0 THEN
i = INSTR("WWW.", UCASE$(s))
IF i > 0 THEN l = LEN(s) - 4
ELSE
l = LEN(s) - 7
END IF
IF i > 0 THEN s = MID$(s, i, l)
ShellExecute(0,"open",s,"","",1)
END SUB
FUNCTION GetChildHandle(BYVAL hParent AS LONG, BYVAL sClass AS STRING, BYVAL lInstance AS LONG) AS LONG
DEFLNG gCnt = 0
DEFLNG gWnd = GetWindow(hParent, GW_CHILD)
DEFSTR gStr = ""
DO
gStr = SPACE$(255)
GetClassName(gWnd, VARPTR(gStr), 255)
IF LCASE$(LEFT$(gStr, INSTR(gStr, CHR$(0))-1)) = LCASE$(sClass) THEN INC(gCnt)
IF gCnt = lInstance THEN EXIT DO
gWnd = GetWindow(gWnd, GW_HWNDNEXT)
LOOP UNTIL gWnd = 0
Result = gWnd
END FUNCTION
FUNCTION IDE_AttemptToFindFile(inTxt AS STRING) AS STRING
DEFSTR s = "\" + StripFileName(inTxt)
IF FILEEXISTS(inTxt) THEN
RESULT = inTxt
EXIT FUNCTION
ELSEIF FILEEXISTS(Application.Path + s) THEN
RESULT = Application.Path + s
EXIT FUNCTION
ELSEIF FILEEXISTS(Application.Path +"\tools" + s) THEN
RESULT = Application.Path +"\tools" + s
EXIT FUNCTION
ELSEIF FILEEXISTS(Application.Path +"\help" + s) THEN
RESULT = Application.Path +"\help" + s
EXIT FUNCTION
ELSEIF FILEEXISTS(Application.Path +"\templates" + s) THEN
RESULT = Application.Path +"\templates" + s
EXIT FUNCTION
ELSEIF FILEEXISTS("\rapidq" + s) THEN
RESULT = "\rapidq" + s
EXIT FUNCTION
ELSEIF FILEEXISTS("\rapidq\lib" + s) THEN
RESULT = "\rapidq\lib" + s
EXIT FUNCTION
ELSEIF FILEEXISTS("\rapidq\inc" + s) THEN
RESULT = "\rapidq\inc" + s
EXIT FUNCTION
ELSEIF FILEEXISTS("\rapidq\include" + s) THEN
RESULT = "\rapidq\include" + s
EXIT FUNCTION
ELSEIF FILEEXISTS("\rapidq\help" + s) THEN
RESULT = "\rapidq\help" + s
EXIT FUNCTION
ELSEIF FILEEXISTS("\rapidq\doc" + s) THEN
RESULT = "\rapidq\doc" + s
EXIT FUNCTION
ELSEIF FILEEXISTS("\rapidq\templates" + s) THEN
RESULT = "\rapidq\templates" + s
EXIT FUNCTION
ELSE
RESULT = ""
END IF
END FUNCTION
FUNCTION IDE_AttemptToFindFolder(inTxt AS STRING) AS STRING
DEFSTR s = RIGHT$(inTxt, LEN(inTxt) - RINSTR(inTxt, "\") + 1)
IF DIREXISTS(inTxt) THEN
RESULT = inTxt
EXIT FUNCTION
ELSEIF DIREXISTS(Application.Path + s) THEN
RESULT = Application.Path + s
EXIT FUNCTION
ELSEIF DIREXISTS(Application.Path +"\tools" + s) THEN
RESULT = Application.Path +"\tools" + s
EXIT FUNCTION
ELSEIF DIREXISTS(Application.Path +"\help" + s) THEN
RESULT = Application.Path +"\help" + s
EXIT FUNCTION
ELSEIF DIREXISTS(Application.Path +"\templates" + s) THEN
RESULT = Application.Path +"\templates" + s
EXIT FUNCTION
ELSEIF DIREXISTS("\rapidq" + s) THEN
RESULT = "\rapidq" + s
EXIT FUNCTION
ELSEIF DIREXISTS("\rapidq\lib" + s) THEN
RESULT = "\rapidq\lib" + s
EXIT FUNCTION
ELSEIF DIREXISTS("\rapidq\inc" + s) THEN
RESULT = "\rapidq\inc" + s
EXIT FUNCTION
ELSEIF DIREXISTS("\rapidq\include" + s) THEN
RESULT = "\rapidq\include" + s
EXIT FUNCTION
ELSEIF DIREXISTS("\rapidq\help" + s) THEN
RESULT = "\rapidq\help" + s
EXIT FUNCTION
ELSEIF DIREXISTS("\rapidq\doc" + s) THEN
RESULT = "\rapidq\doc" + s
EXIT FUNCTION
ELSEIF DIREXISTS("\rapidq\templates" + s) THEN
RESULT = "\rapidq\templates" + s
EXIT FUNCTION
ELSE
RESULT = ""
END IF
END FUNCTION
|
|