Page 1 of 1 1
Topic Options
#115287 - 2004-03-01 10:52 PM Fill label on form with value from ini file
Scripter2004 Offline
Fresh Scripter

Registered: 2004-03-01
Posts: 31
Loc: Minneapolis, MN (USA)
I would like one of the text labels on a form (or text box, if that's earier) to automatically take the value of an ini file entry when the form is opened. Is there any way of doing that? (I'm a KiXtart beginner.)

Top
#115288 - 2004-03-01 11:18 PM Re: Fill label on form with value from ini file
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Well...

what type of form is it? a KiXform form... a web page form... someother type of Form that is displayed on the desktop....

as for getting information from an INI in to your script, take a look at the readprofilestring() command. Once you have the data, and an answer to the "type of form" question, i am sure somone will be glad to give you some pointers.

Bryce

Quote:

I would like one of the text labels on a form (or text box, if that's earier) to automatically take the value of an ini file entry when the form is opened. Is there any way of doing that? (I'm a KiXtart beginner.)





Top
#115289 - 2004-03-02 09:55 AM Re: Fill label on form with value from ini file
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hi there and welcome,

as far as I follow this you'd like to be able to do something alike this :

Code:
break on

$ini = @scriptdir + '\labels.ini'
$f = createobject("KiXtart.Form")

$l1 = $f.Label(readprofilestring($ini,"Labels","Label1"),10,10,200,20)

$f.Show

while $f.Visible
$_ = execute($f.DoEvents)
loop
exit 1



with such an ini-file (labels.ini)

Quote:

[Labels]
Label1=Value from ini file





hth
_________________________



Top
#115290 - 2004-03-02 04:19 PM Re: Fill label on form with value from ini file
Scripter2004 Offline
Fresh Scripter

Registered: 2004-03-01
Posts: 31
Loc: Minneapolis, MN (USA)
Excellent! This is exactly what I was looking for.

On a related note, is it also possible to have a text box where users can specify a file path manually, with a browse button next to it that allows them to navigate to a file. When they then select a file, the text box contents (and the associated variable) are automatically updated.

I'm sorry for asking all these question, but I'm just beginning to discover the awsome possibilities of KiXtart!

Thx
Ron

Top
#115291 - 2004-03-02 04:48 PM Re: Fill label on form with value from ini file
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
try something like this :

Code:
break on

$form = createobject("kixtart.form")

$lblPath = $form.Label("Path:",10,10,60,15)
$txtPath = $form.TextBox("",10,$lblPath.Bottom,200,20)

$btnBrws = $form.ToolButton("Browse...",$txtPath.Right+5,$lblPath.Bottom,60,21)
$btnBrws.FlatStyle = 1
$btnBrws.OnClick = "btnBrws_Click()"

$form.Show

while $form.Visible
$_ = execute($form.DoEvents)
loop

function btnBrws_Click()
dim $f
$f = $Form.Dialogs.FolderBrowserDialog
$f.Rootfolder = 17
if $f.ShowDialog = 1
$txtPath.Text = $f.SelectedPath
endif
endfunction



instead of updating a variable you can also refering to $txtPath.Text every time the path is needed
_________________________



Top
#115292 - 2004-03-02 04:59 PM Re: Fill label on form with value from ini file
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX




I'm just beginning to discover the awsome possibilities of KiXtart!

Thx
Ron




Ok quick!! run don't walk to http://kixforms.org


Top
#115293 - 2004-03-02 05:04 PM Re: Fill label on form with value from ini file
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
And don't forget to read the KiXtart & KiXforms Manuals!
_________________________
There are two types of vessels, submarines and targets.

Top
#115294 - 2004-03-02 05:06 PM Re: Fill label on form with value from ini file
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
oopps forgot the code snipit!!

Code:

Break On

$System = CreateObject("Kixtart.System")
$Form = $System.Form()
$Form.Text = "Browse for file"

$BrowseButton = $form.Controls.Button
$BrowseButton.text = "Browse for file"

$BrowseButton.onclick = "$BrowseDisplay.text = FileBrowse"
$BrowseButton.Height = 20

$BrowseDisplay = $Form.Controls.TextBox()
$BrowseDisplay.top = $BrowseButton.bottom
$BrowseDisplay.left = $BrowseButton.left
$BrowseDisplay.Width = $Form.ClientWidth

$Form.ClientHeight = $BrowseDisplay.Bottom
$Form.Show

While $Form.Visible
$=Execute($Form.DoEvents)
Loop

Exit(0)

Function FileBrowse
$OpenFileDialog = $System.OpenFileDialog()
$ = $OpenFileDialog.ShowDialog()
$fileBrowse = $OpenFileDialog.filename
EndFunction




Top
#115295 - 2004-03-02 05:18 PM Re: Fill label on form with value from ini file
Scripter2004 Offline
Fresh Scripter

Registered: 2004-03-01
Posts: 31
Loc: Minneapolis, MN (USA)
Perfect! Again, just what I needed! Thanks!
I have already discovered KiXforms. I'm experimenting with that now. I'm currently looking into using KiXtart to automate a conversion process, which we used to do with command-line batch files. However, these are not as flexible and powerful as KiXtart, especially when it comes to file handling and text manipulation (both of which are important for our process).

I also bought (and printed) NetImpress' Start To Finish Guide to Scripting With KiXtart e-book, which I find very useful (highly recommended!).

Thanks again for all your (fast!) help.
(I will probably need to call on you again at some point... ;-)

Ron

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 837 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.299 seconds in which 0.061 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org