Overload question

General FreeBASIC programming questions.
Post Reply
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Overload question

Post by bcohio2001 »

The array is filled with different string data.

Code: Select all

dim as string T(45),TFind = "the dog,the cat, the moon,queens,nothing"

declare sub FindIt overload (TComma as string,FindStr as string)
declare sub FindIt overload (T() as string,FindStr as string)

FindIt TFind,"the"
FindIt T(),"cat"
Would this work?
Hexadecimal Dude!
Posts: 360
Joined: Jun 07, 2005 20:59
Location: england, somewhere around the middle
Contact:

Post by Hexadecimal Dude! »

It seems like it should, note that...

Code: Select all

Declare Sub FindIt overload (TComma As String,FindStr As String)
Declare Sub FindIt overload (T() As String,FindStr As String)

Sub FindIt  (TComma As String,FindStr As String)
	print "normal called"
end sub

Sub FindIt  (T() As String,FindStr As String)
	print "array version called"
end sub

dim foo(10) as string

Findit("hello","hi")
Findit(foo(),"hi")
...works as you would expect. Often writing a little test program like this will give you an answer faster than the forum. (In fact, as I have just shown, people answering in the forum may well have used this method to check their knowledge before answering).

P.S. It looks like you might be interested in the "instr" function when you come to write your functions, see http://www.freebasic.net/wiki/wikka.php ... KeyPgInstr
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Post by bcohio2001 »

Sorry to mislead you a little. that was a quick and dirty example of what I was asking. My true intention was to write a sub to either fill a combobox with a comma dilimited string of values, or an array of values.

ie....

Code: Select all

declare sub fillCombo overload (T as string)
declare sub fillCombo overload (T() as string)

sub fillCombo(T as string)
dim as string x(45)
'code to split the string into the array
fillCombo x()
end sub

sub fillCombo(A() as string)
'actually fills the combobox with the data in array
end sub
depending on what is sent. the first one splits string into an array then passes it to the other fillCombo.
Post Reply