I want to create a "config file".
using the prompt
I want to create an ini file like the example below.
Please write and read source.
example
--------------------------------------------
[body]
cropx= 100
cropy= 200
[hair]
cropx= 10
cropy= 80
config file
Re: config file
Code: Select all
ini = '[body]\ncropx= 100\ncropy= 200\n\n[hair]\ncropx= 10\ncropy= 80';
(fle = File('~/Desktop/File.ini')).open('w'), fle.write(ini), fle.close()
Code: Select all
(fle = File('~/Desktop/File.ini')).open('r'), ini = fle.read(), fle.close(), ini
Re: config file
Thank you very much.
When cropx = 100
When reading only "cropx" values
How do you extract variable values?
When cropx = 100
When reading only "cropx" values
How do you extract variable values?
Last edited by lee ky on Thu Mar 26, 2020 1:10 am, edited 1 time in total.
Re: config file
Code: Select all
ini.match(/\d+(?=\ncropy)/g)[0]
Re: config file
(fle = File('~/Desktop/config.ini')).open('r'), ini = fle.read(), fle.close(), ini
var y=ini.match(/\d+(?=\ncropy)/g)[0]
alert(y);
------------------------------------------------------------------------
(fle = File('~/Desktop/config.ini')).open('r'), ini = fle.read()
var y=ini.match(/\d+(?=\ncropy)/g)[0]
fle.close(), ini
alert(y);
I'm sorry, I can't.
Call the first line only
------------------------------------------------------------------------
[dress]
cropx= 100
cropy= 200
[hair]
cropx= 10
cropy= 50
[glasses]
cropx= 1
cropy= 30
alert(dress_cropx);
alert(dress_cropy);
alert(hair_cropx);
alert(hair_cropy);
alert(glasses_cropx);
alert(glasses_cropy);
We need to create a total of 6 variables each
Could you please give me more advice
var y=ini.match(/\d+(?=\ncropy)/g)[0]
alert(y);
------------------------------------------------------------------------
(fle = File('~/Desktop/config.ini')).open('r'), ini = fle.read()
var y=ini.match(/\d+(?=\ncropy)/g)[0]
fle.close(), ini
alert(y);
I'm sorry, I can't.
Call the first line only
------------------------------------------------------------------------
[dress]
cropx= 100
cropy= 200
[hair]
cropx= 10
cropy= 50
[glasses]
cropx= 1
cropy= 30
alert(dress_cropx);
alert(dress_cropy);
alert(hair_cropx);
alert(hair_cropy);
alert(glasses_cropx);
alert(glasses_cropy);
We need to create a total of 6 variables each
Could you please give me more advice
Last edited by lee ky on Fri Mar 27, 2020 5:26 am, edited 5 times in total.
Re: config file
You were not precise, saying of first value and then of all of them in your post, so I extracted examplary first cell from array, while you can have all of them at once removeing [0] from latest code. To get other values separatly use (singly) another numbers in square brackets.