Phadda
(Fresh Scripter)
2003-02-27 11:58 AM
is it possible with kixforms...

i would like to use a file with content as a selection for a "combobox". this file is a "database" to store some informations.
i seareched the board and test some udf, but i find nothing that helps me. either i´m seraching for the wrong subject or i´m to n00bie to get the answer [Wink] hope someone can help me, thanks a lot.


JochenAdministrator
(KiX Supporter)
2003-02-28 12:06 AM
Re: is it possible with kixforms...

Phadda ...

is the type 'database' a given fact or is there freedom in format ?

Ask that because of type 'ini' is much easier to implement [Smile]


Phadda
(Fresh Scripter)
2003-02-28 12:14 AM
Re: is it possible with kixforms...

wow, fast answer [Smile] i luv this board and the community, much better than the gamercommunity [Wink]
k back to the thread...
well the content of this file is only a single phrase which contains number/letter for example XH342d12Df, but it is possible that the phrase can be build with specialchars and/or larger than 10 chars and/or smaller. but it will never be more than one "word" each line. i hope you understand what i mean, as a german my "schoolenglish" is hmmmm 10 years old hehe


JochenAdministrator
(KiX Supporter)
2003-02-28 12:15 AM
Re: is it possible with kixforms...

to show what I am after :



break on

$ini = @scriptdir + "\cbo.ini"
$list = split(readprofilestring($ini,"List",""),chr(10))
redim preserve $List[ubound($list) -1]

$form           = createobject("kixtart.form")

$cbo1           = $form.ComboBox
$cbo1.List      = $List
$cbo1.ListIndex = 0


$form.Show
while $form.visible
    $=execute($form.Doevents)
loop

exit



Plus cbo.ini :

code:
[list]
Value1=ITEM1
Value2=ITEM2
Value3=ITEM3
Value4=ITEM4
Value5=ITEM5
Value6=ITEM6
Value7=ITEM7

hth
Jochen


LonkeroAdministrator
(KiX Master Guru)
2003-02-28 12:19 AM
Re: is it possible with kixforms...

k, phadda, with your current format...
something like:
code:
$=open(1,"DBfile.txt")
$file=readline(1)
while @error=0 $file=$file+chr(10)+readline(1) loop
for each $line in split($file,chr(10))
$combo.additem($line)
loop



[ 27. February 2003, 13:47: Message edited by: Lonkero ]


JochenAdministrator
(KiX Supporter)
2003-02-27 01:10 PM
Re: is it possible with kixforms...

thought that over and suggest doing the same as I did in PostPrep (simplified)

Testscript:



break on

$form           = createobject("kixtart.form")

$cbo1           = $form.ComboBox
$cbo1.List      = split(readprofilestring(@scriptdir + "\cbo.ini","ComboBoxes","cbo1"),',')
$cbo1.ListIndex = 0

$form.Show
while $form.visible
    $=execute($form.Doevents)
loop

exit



Ini-file (easy to enhance [Wink] ) :

code:
[ComboBoxes]
cbo1=ITEM1,ITEM2,ITEM3,ITEM4,ITEM5,ITEM6,ITEM7

J.


LonkeroAdministrator
(KiX Master Guru)
2003-02-27 01:13 PM
Re: is it possible with kixforms...

why you keep pulling that ini-file?
thought he has no ini-file.

wonder how the file is generated or is he doing it himself.
if latter, ini is good option but if some soft does it, simple read is easier.

btw, you should get that proxy fixed!
got no chat friends during coffee breaks [Wink]


JochenAdministrator
(KiX Supporter)
2003-02-27 01:26 PM
Re: is it possible with kixforms...

Yeah ... the proxy admin remain dead , awaiting the next [Mad]

I think Phadda indeed has control about the method the file is created , so I'll stick with ini [Wink]


Phadda
(Fresh Scripter)
2003-02-27 01:33 PM
Re: is it possible with kixforms...

thank you very much, when i read the lines from your both post it looks like a simple script ;-)
i test both scripts and "sorry" to jpols, but the idea with an ini file is nice but it is too much for my small "database" :-)
i prefer the example from lonkero, but i think i got a small problem with it. the combolist is not splited and i got only one value like "1 2 3 4 5 6". is there a import problem from the databasefile? i add the values in the file with this line:
code:
  
$x = WriteLine( 1, '$content' + @CRLF )

i expect that the "chr(10)" makes the prob...


LonkeroAdministrator
(KiX Master Guru)
2003-02-27 01:49 PM
Re: is it possible with kixforms...

nope.
I just forgot one argument from the split.
updated it.

now, is the file only one line having all the stuff or multiple lines with one option each?

the script I wrote assumes the latter.


Phadda
(Fresh Scripter)
2003-02-27 02:06 PM
Re: is it possible with kixforms...

the file contains one option each line and the lines are seperated with a cr. because it is much better for the manual fixing this file when they seperated each line one option [Wink]

LonkeroAdministrator
(KiX Master Guru)
2003-02-27 02:07 PM
Re: is it possible with kixforms...

k, so the updated scriptlet (above) works.

ShawnAdministrator
(KiX Supporter)
2003-02-27 02:17 PM
Re: is it possible with kixforms...

Phadda,

Are you wanting a list or combobox with multiple columns (to display many fields in a database) ? If so, might want to start looking into the ListView object.

-Shawn

[ 27. February 2003, 14:45: Message edited by: Shawn ]


Phadda
(Fresh Scripter)
2003-02-27 02:52 PM
Re: is it possible with kixforms...

@shawn
i only want a simple pulldown with a "dynamic database" content, like the "KIXPAD" font combobox [Smile] and i think mister never sleep lonkero hehe helped me to get a little bit closer to my problem [Wink]


JochenAdministrator
(KiX Supporter)
2003-02-27 03:41 PM
Re: is it possible with kixforms...

Still think that ini-based solution is easier/more reliable/faster !
(I even have coded a 'working' ini-based 4 player network game [Big Grin] )

How 'small' will the database be ?

[ 27. February 2003, 15:44: Message edited by: jpols ]


JochenAdministrator
(KiX Supporter)
2003-02-28 02:41 PM
Re: is it possible with kixforms...

ok ... got the chance to discuss this further on PMs with Phadda

Did a short sample to show that it is possible to control the contents of a Combobox dynamically [Big Grin]

description :

ComboBox 2 controls the amount of items in ComboBox 1 (Not the contents though; Think we need a deeper explanation of what exactly you try to achieve)
You'll see that the script doesn't even need the ini file at first start ...
Ah yeah ... and of course the Script 'remembers' the Items for next run [Wink]



break on

Global $List[0]

$ini  = @scriptdir + "\cbo.ini"
$List = split(readprofilestring($ini,"ComboBoxes","cbo1"),',')

$form           = createobject("kixtart.form")

$cbo1           = $form.ComboBox
$cbo1.Location  = 530
$cbo1.List      = $List
$cbo1.ListIndex = 0

$cbo2           = $form.ComboBox
$cbo2.Location  = $cbo1.Right + 530
$cbo2.List      = 0,1,2,3,4,5,6,7
$cbo2.ListIndex = ubound($List)
$cbo2.OnClick   = "cbo2_Click($$cbo2.ListIndex)"

$lbl1           = $form.Label("cbo1:",5,10,80,15)

$lbl2           = $form.Label("Items in cbo1:",$cbo2.Left,10,120,15)

$form.Show
while $form.visible
    $=execute($form.Doevents)
loop

exit

function cbo2_click($i)
    dim $$i
    redim $List[0]
    if $i
        for $ = 0 to $i - 1
            redim preserve $List[$i]
            $List[$] = "ITEM" + ($+1)
        next
        redim preserve $list[ubound($List)-1]
    endif
    $cbo1.List = $List
    $cbo1.ListIndex = 0
    $ = writeprofilestring($ini,"ComboBoxes","cbo1",join($List,','))
endfunction



hth

[Updated on 3rd of March with a more reliable version [Roll Eyes] ]

[ 03. March 2003, 14:03: Message edited by: jpols ]