Code: Select all
DIM as UINTERGER list(1)
list(0) = "hi"
list(1) = "hello"
I'm sure this won;t work because words are strings and contain mre then 1 byte or whatever UINTEGER does. What would I dim the array as for strings?
Code: Select all
DIM as UINTERGER list(1)
list(0) = "hi"
list(1) = "hello"
Code: Select all
Dim as String list(1)
list(0) = "hi"
list(1) = "hello"
Code: Select all
ENUM ColorList
Black
Blue
Green
Cyan
Red
Magenta
Brown
Grey
DarkGrey
LightBlue
LightGreen
LightCyan
LightRed
LightMagenta
Yellow
White
END ENUM
Code: Select all
ENUM TimeIntervals
Yearly = 1
SixMonths = 2
FourMonths = 3
ThreeMonths = 4
TwoMonths = 6
Monthly = 12
BiMonthly = 24
TwoWeeks = 26
Weekly = 52
END ENUM
Code: Select all
DIM ForegroundColor AS ColorList
DIM BackgroundColor AS ColorList
DIM TimeLaps AS TimeIntervals
ForegroundColor = Grey ' any of the other names in the ENUM
BackgroundColor = Black ' any of the other names in the ENUM
TimeLaps = Monthly
Code: Select all
option explicit
function FindWord( wordList() as string, word as string ) as integer
if( len( word ) = 0 ) then return 0
dim as integer it = 0
while( it <> ubound( wordList ) )
if( wordList( it ) = word ) then return -1
it += 1
wend
return 0
end function
function StringArrayExample( ) as integer
const MaxWords as uinteger = 3
dim as string SafeList( MaxWords - 1 ) => { _
"ribeye", _
"t-bone", _
"prime rib" _
}
dim as string IgnoreList( MaxWords - 1 ) => { _
"broccoli", _
"cauliflower", _
"brussel sprouts" _
}
dim as string userWord
print "Enter a word: " ;: input userWord
if( FindWord( SafeList(), userWord ) ) then
print userWord ; " found in the safe list."
elseif( FindWord( IgnoreList(), userWord ) ) then
print userWord ; " found in the ignore list."
else
print userWord ; " not in either list."
end if
sleep : return 0
end function
end StringArrayExample()
Users browsing this forum: No registered users and 12 guests