My first error is a suffix % with Upper. Is Z1$ bad too as a variable?
Code: Select all
DECLARE SUB QuickSortValues2 (Upper%)
Code: Select all
DECLARE SUB QuickSortValues2 (Upper%)
Code: Select all
CLEAR , , 6000
Code: Select all
' Returns the number of times that a substring is found within a string.
' ----------------------------------------------------------------------
DEF fnstrn (Search$, LookFor$)
Count% = 0
IF Search$ = "" OR LookFor$ = "" THEN
fnstrn = Count%
EXIT DEF
END IF
x% = INSTR(Search$, LookFor$)
DO WHILE x% > 0
Count% = Count% + 1
last% = x%
x% = INSTR((last% + 1), Search$, LookFor$)
LOOP
fnstrn = Count%
END DEF
Code: Select all
#lang "QB"
DIM SHARED Search$
DIM SHARED LookFor$
DIM SHARED X1%
' Returns the number of times that a substring is found within a string.
' ----------------------------------------------------------------------
FUNCTION fnstrn (Search$, LookFor$)
Count% = 0
IF Search$ = "" OR LookFor$ = "" THEN
fnstrn = Count%
EXIT FUNCTION
END IF
x% = INSTR(Search$, LookFor$)
DO WHILE x% > 0
Count% = Count% + 1
last% = x%
x% = INSTR((last% + 1), Search$, LookFor$)
LOOP
fnstrn = Count%
END FUNCTION
Search$="Cantalope"
LookFor$="a"
X1%=fnstrn
PRINT X1%
SLEEP
Sorry I meant to say DOS not 32-bit QBasic. Been a long time since.
Thanks for your input badidea
Stuck with what? You defined a function that takes two string arguments, and then when calling it you don't pass them:
Code: Select all
#lang "QB"
'DIM SHARED Search$
'DIM SHARED LookFor$
'DIM SHARED X1%
' Returns the number of times that a substring is found within a string.
' ----------------------------------------------------------------------
FUNCTION fnstrn (Search$, LookFor$)
Count% = 0
IF Search$ = "" OR LookFor$ = "" THEN
fnstrn = Count%
EXIT FUNCTION
END IF
x% = INSTR(Search$, LookFor$)
DO WHILE x% > 0
Count% = Count% + 1
last% = x%
x% = INSTR((last% + 1), Search$, LookFor$)
LOOP
fnstrn = Count%
END FUNCTION
Search$="Cantalope"
LookFor$="a"
X1%=fnstrn( Search$, LookFor$ )
PRINT X1%
SLEEP
Thank You paul doe! That works! Simple now. Problem solved.
Code: Select all
X1%=fnstrn( Search$, LookFor$ )
Code: Select all
REDIM SortArray#(Upper%, 2) ' Dimension 1 = Values Dimension 2 = Index
Code: Select all
COMMON SHARED SortArray#() ' Sort Array
Code: Select all
#lang "qb"
'.....
COMMON SHARED SortArray#() ' Sort Array
'.....
REDIM SortArray#(Upper%, 2) ' Dimension 1 = Values Dimension 2 = Index
'.....
REDIM SortArray#(Upper%, 2) ' Dimension 1 = Values Dimension 2 = Index
'.....
fxm wrote: ↑May 27, 2022 11:46 Yet the following code works under FreeBASIC:Code: Select all
#lang "qb" '..... COMMON SHARED SortArray#() ' Sort Array '..... REDIM SortArray#(Upper%, 2) ' Dimension 1 = Values Dimension 2 = Index '..... REDIM SortArray#(Upper%, 2) ' Dimension 1 = Values Dimension 2 = Index '.....
Code: Select all
#lang "qb"
DIM SHARED Upper as Integer
DIM SHARED SortArray(2,2) as Integer ' Sort Array
Upper=1
'.....
REDIM SortArray(Upper, 2) ' Dimension 1 = Values Dimension 2 = Index
'.....
REDIM SortArray(Upper, 2) ' Dimension 1 = Values Dimension 2 = Index
'.....
Print __FB_Version__:Sleep
Code: Select all
DIM SHARED Sp, Sp$, v, Clor1, CLOR2, P, L
Code: Select all
DECLARE SUB Initialization ()