Gremlin010
(Fresh Scripter)
2003-08-26 08:30 AM
simple question (variable, write ini file )

Hi all,
i have 3 simple point i cant program to my own.

1. I have a Question to the User !

?"How old are you ? example 25 = "

2. This nummber i want to save in a variable.

Gets $age

3. Now i want to save this variable in a text or ini file. Here is my main problem, i tried writeline, writeprofilestring and others but nothing happens. It´s possible that my "gets" is wrong ?
I´m afraid its a very simple syntax.

Thank you for helping me with my first stepps in kix programming.

Best regards
Gremlin


LonkeroAdministrator
(KiX Master Guru)
2003-08-26 08:44 AM
Re: simple question (variable, write ini file )

ok, why don't you post what you have tried?
this way we don't feed you with ready code, if you know what I mean [Wink]


NTDOCAdministrator
(KiX Master)
2003-08-26 08:48 AM
Re: simple question (variable, write ini file )

Hello Gremlin and welcome to the board.

Please take some time and review the Manual that ships with KiXtart as well as the FAQ section on this board. It should prove to be very helpful in getting you started with KiXtart.

Here is an example that you can display in a DOS console window. Then writing to file is easy.

Please let us know if you need further assitance.

The $age var now holds what ever the user types in until they hit the enter key. However, this code does not check for invalid input but KiX does support validation checking as well.


break on
? 'What is your age? Please type in your age and then press the enter key ' ?
gets $age
? 'You entered '+$age


Gremlin010
(Fresh Scripter)
2003-08-26 09:08 AM
Re: simple question (variable, write ini file )

WOOW this forum works fast *happy*
Thank u for helping me.

I think i read every fac abaout variable and write in files, but i´m afriad im only a stupid beginner. I dont want i complet programm i think i need only help with the syntax of my programm.

here my trys:
Please dont laugh [Smile]

My stupid simple script i cant program :/

?"How old are U ?? example 25 = "

Gets $age

$file= "t:\age.ini"
$rc=WriteProfileString($file, "$age")

or

WriteLine("t:\age.ini","$age")

shame on me :/

best regards

Gremlin


NTDOCAdministrator
(KiX Master)
2003-08-26 09:14 AM
Re: simple question (variable, write ini file )

Gremlin... relax guy. No one wanting to beat you up for being new and not understanding. Some guys get a little "short on manners" when someone shows or continues to show they don't take the time to read the manual or FAQs.

We all had to start out new at some time.

Anyways... please take a look at this post for more information on using an INI file.
Also, please take the time and read at least some of the FAQs here on Korg.

http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=007101


Gremlin010
(Fresh Scripter)
2003-08-26 09:45 AM
Re: simple question (variable, write ini file )

Thank u !
I must be blind. The Link works great.

now i use a ini file
[MyHeader]
age=

and the script

?"How old are u ? z.B 25 = "

Gets $age

Break On
$File="t:\text.ini"
If EXST $File
$nul=WRITEPROFILESTRING ("$File", "MyHeader", "age", "$age")

ELSE
? 'Unable to locate file '+@ERROR +' '+@SERROR
Endif

and it works [Frown] )

Thanks a lot

best regards
Gremlin


NTDOCAdministrator
(KiX Master)
2003-08-26 10:08 AM
Re: simple question (variable, write ini file )

Cool

Just a minor note. The "MyHeader" name can be anything you want. It was just an example.

For future postings with code please use either the [CODE] Tags to maintain your code layout or PostPrep.

There is a link in my signature for PostPrep.
Very cool app by Lonkero and Jochen for posting code to Korg.


Gremlin010
(Fresh Scripter)
2003-08-26 02:30 PM
Re: simple question (variable, write ini file )

1. question solved 1000 new questions are open [Smile]

How i write in a blank file .
In the moment my file looks like this

[CODE]
[MyHeader]
age=25

but how i get only the 25 in my file ?
i tried this->

[CODE]
$nul=WRITEPROFILESTRING ("$File", "", "", "$age")

but it does´nt work [Frown]

any tips for me ?

best regard
Gremlin


maciep
(Korg Regular)
2003-08-26 04:32 PM
Re: simple question (variable, write ini file )

code:
 
Break On
$File="t:\text.ini"
$nul=open(1, $File, 5)
$nul = writeline(1, $age + @crlf)
$nul = close(1)



LonkeroAdministrator
(KiX Master Guru)
2003-08-26 05:07 PM
Re: simple question (variable, write ini file )

gremlin, with the code-tags he ment pressing the  - button and placing your code between the tags [Wink]

Gremlin010
(Fresh Scripter)
2003-08-27 10:22 AM
Re: simple question (variable, write ini file )

Thank u maciep

it works [Smile]

best regards
Gremlin


Gremlin010
(Fresh Scripter)
2003-08-28 12:41 AM
Re: simple question (variable, write ini file )

I´m back sorry

everything works good but now i have a new problem with my syntax.

How i write more as 1 variable in a row split by ",".

I try this:
code:
Break On
$File="t:\text.ini"
$nul=open(1, $File, 5)
$nul = writeline(1, $age,$name,$city + @crlf)
$nul = close(1)

But program said i need "(".
The ini-file should be
25,John,Houston,
`cause i wanted to make a xls evaluation.

Hope this is my last question for this week,
but i believe i will be back soon.

best regards
Gremlin


LonkeroAdministrator
(KiX Master Guru)
2003-08-28 12:44 AM
Re: simple question (variable, write ini file )

quess you should read some of the manual or the starters guide in faq...
over even try out... [Wink]

anyway:
code:
$nul = writeline(1, $age  + "," + $name + "," + $city + @crlf)

cheers


LonkeroAdministrator
(KiX Master Guru)
2003-08-28 12:45 AM
Re: simple question (variable, write ini file )

btw,
as you still keep talking about ini, you should not use writeline but writeprofilestring.


maciep
(Korg Regular)
2003-08-27 03:32 PM
Re: simple question (variable, write ini file )

Or use a txt file instead of an ini. All depends on what you want.