mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-09-07 16:30:18 +00:00
The new dialogs includes 5 settings: 1. Flag to turn on Optimization (off by default) 2. Flag to strip symbols (On by default) 3. String for extra compiler flags 4. String for extra linker flags 5. Setting for max compiler processes (default of 3) Fixes: #65 Fixes: #40
125 lines
3.3 KiB
QBasic
125 lines
3.3 KiB
QBasic
'
|
|
' String manipulation functions
|
|
'
|
|
|
|
FUNCTION StrRemove$ (myString$, whatToRemove$) 'noncase sensitive
|
|
DIM a$, b$
|
|
DIM AS LONG i
|
|
|
|
a$ = myString$
|
|
b$ = LCASE$(whatToRemove$)
|
|
i = INSTR(LCASE$(a$), b$)
|
|
DO WHILE i
|
|
a$ = LEFT$(a$, i - 1) + RIGHT$(a$, LEN(a$) - i - LEN(b$) + 1)
|
|
i = INSTR(LCASE$(a$), b$)
|
|
LOOP
|
|
StrRemove$ = a$
|
|
END FUNCTION
|
|
|
|
FUNCTION StrReplace$ (myString$, find$, replaceWith$) 'noncase sensitive
|
|
DIM a$, b$
|
|
DIM AS LONG basei, i
|
|
IF LEN(myString$) = 0 THEN EXIT FUNCTION
|
|
a$ = myString$
|
|
b$ = LCASE$(find$)
|
|
basei = 1
|
|
i = INSTR(basei, LCASE$(a$), b$)
|
|
DO WHILE i
|
|
a$ = LEFT$(a$, i - 1) + replaceWith$ + RIGHT$(a$, LEN(a$) - i - LEN(b$) + 1)
|
|
basei = i + LEN(replaceWith$)
|
|
i = INSTR(basei, LCASE$(a$), b$)
|
|
LOOP
|
|
StrReplace$ = a$
|
|
END FUNCTION
|
|
|
|
FUNCTION AddQuotes$ (s$)
|
|
AddQuotes$ = CHR$(34) + s$ + CHR$(34)
|
|
END FUNCTION
|
|
|
|
'
|
|
' Convert a boolean value to 'True' or 'False'
|
|
'
|
|
FUNCTION BoolToTFString$ (b AS LONG)
|
|
IF b THEN
|
|
BoolToTFString$ = "True"
|
|
ELSE
|
|
BoolToTFString$ = "False"
|
|
END IF
|
|
END FUNCTION
|
|
|
|
'
|
|
' Convert 'True' or 'False' to a boolean value
|
|
'
|
|
' Any string not 'True' or 'False' is returned as -2
|
|
'
|
|
FUNCTION TFStringToBool% (s AS STRING)
|
|
DIM s2 AS STRING
|
|
s2 = _TRIM$(UCASE$(s))
|
|
|
|
IF s2 = "TRUE" THEN
|
|
TFStringToBool% = -1
|
|
ELSEIF s2 = "FALSE" THEN
|
|
TFStringToBool% = 0
|
|
ELSE
|
|
TFStringToBool% = -2
|
|
END IF
|
|
END FUNCTION
|
|
|
|
'
|
|
' Reads the bool setting at section:setting. If it is not there or invalid, writes the default value to it
|
|
'
|
|
FUNCTION ReadWriteBooleanSettingValue% (section AS STRING, setting AS STRING, default AS INTEGER)
|
|
DIM checkResult AS INTEGER
|
|
DIM value AS STRING
|
|
DIM result AS INTEGER
|
|
|
|
result = ReadConfigSetting(section, setting, value)
|
|
|
|
checkResult = TFStringToBool%(value)
|
|
|
|
IF checkResult = -2 THEN
|
|
WriteConfigSetting section, setting, BoolToTFString$(default)
|
|
ReadWriteBooleanSettingValue% = default
|
|
ELSE
|
|
ReadWriteBooleanSettingValue% = checkResult
|
|
END IF
|
|
END FUNCTION
|
|
|
|
'
|
|
' Reads the string setting at section:setting. If it is not there or invalid, writes the default value to it
|
|
'
|
|
FUNCTION ReadWriteStringSettingValue$ (section AS STRING, setting AS STRING, default AS STRING)
|
|
DIM value AS STRING
|
|
DIM result AS INTEGER
|
|
|
|
result = ReadConfigSetting(section, setting, value)
|
|
|
|
IF result = 0 THEN
|
|
WriteConfigSetting section, setting, default
|
|
ReadWriteStringSettingValue$ = default
|
|
ELSE
|
|
ReadWriteStringSettingValue$ = value
|
|
END IF
|
|
END FUNCTION
|
|
|
|
'
|
|
' Reads the integer setting at section:setting. If it is not there or invalid, writes the default value to it
|
|
'
|
|
' Verfies the value is positive and non-zero
|
|
'
|
|
FUNCTION ReadWriteLongSettingValue& (section AS STRING, setting AS STRING, default AS LONG)
|
|
DIM value AS STRING
|
|
DIM result AS INTEGER
|
|
DIM checkResult AS LONG
|
|
|
|
result = ReadConfigSetting(section, setting, value)
|
|
|
|
checkResult = VAL(value)
|
|
|
|
IF result = 0 OR checkResult <= 0 THEN
|
|
WriteConfigSetting section, setting, str2$(default)
|
|
ReadWriteLongSettingValue& = default
|
|
ELSE
|
|
ReadWriteLongSettingValue& = checkResult
|
|
END IF
|
|
END FUNCTION
|