Archive: writing to an ini file


writing to an ini file
Hi all,

Anyone knows how to create an ini keyString if the keyString doesnt exist, like:

[XSI]
Soft=45


Soft exist so, do not write, but Image doesnt exist so create a new keyString with a value of 60.

In the end, it will be:

[XSI]
Soft=45
Image=60

The ini filename is options.ini




THANKS IN ADVANCE!


Something like this:


Section ""
SetOutPath $INSTDIR
File options.ini

ReadINIStr $0 $INSTDIR\options.ini XSI Soft
StrCmp $0 "" 0 image
FileOpen $1 "$INSTDIR\options.ini" a
FileSeek $1 0 END
FileWrite $1 "$\r$\nSoft=45"
FileClose $1
image:
ReadINIStr $0 $INSTDIR\options.ini XSI Image
StrCmp $0 "" 0 done
FileOpen $1 "$INSTDIR\options.ini" a
FileSeek $1 0 END
FileWrite $1 "$\r$\nIMAGE=60"
FileClose $1
done:
SectionEnd

Thanks alot dienjd!

Now I need to ask you one more thing? Is it possible to create a key so that if there was a key, it will be overwritten. If not, a new key will be created.

Also the keyString I am trying to write is this:


Wow, that's a lot of numbers.

By 'key', do you mean INI section ([XSI] in your first example)?

Is it possible to create a key so that if there was a key, it will be overwritten. If not, a new key will be created.
Isn't this the same as just writing in a new key?

would you PLEASE edit your post, remove the codelist, and attach it as a txt file? :)


Thanks for replying. By key I meant Soft and Image.

- Isn't this the same as just writing in a new key?

You are right, it is probably the same thing. But I don't know this language so I thought without specifying it would create another key (duplicate).

Can you please show me an example of writing an ini key then? I would be glad if you could show me how to write the numbers I have posted.

I plan to use this key later in the base app to initialize an array based on this, which would be much better since it will lift much code from the software.


Thanks so much again!


Sorry commander, you are right. But I dont know how to attach files to a message. Can you please tell me how?


To attach a file, use the reply page. There's a link to it at the bottom of this page below the Quick Reply textarea.

To write in a new INI entry (let's use that term instead of key, since NSIS uses it), see http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.2.13

You should be able to set your numbers to a variable and then reference that variable in your WriteINIStr command.


Ok I have attached the file. Btw I had to zip the file because it was too big.

dienjd, thanks for replying. It looks like nsis cannot fit all the text in one line. Is it possible that I break it? Also it gives errors when I try to compile. I think this is because the ini entry is not the type it expects?



Thanks again!


Is it impossible to write this string as an ini entry?


For breaks, see Long Commands in http://nsis.sourceforge.net/Docs/Chapter4.html#4.1. Sorry, I don't have time to try to test this for you now. If you attach your script, somebody may be able to help.


Thanks man! If someone would like to help I would be glad.

I have successfully written the ini entry but dont know how to write something like my example.

Basically the text will be like this:

#(#(384745745...), #(4398534857...), ...)

How I can write something lie this, which is alot longer.

Thanks again!


Please show me how to write it, because I get compile errors. Writing 123 is easy but how about #(345745, 384638...)?

Thanks in advance!


I have written this:

Var "Serial"

Section "CoreFN" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
StrCpy "$Serial" "#(#(3342347, 3473420, 3407883, 3605261, 3538956, 3736335, 3670030, 3801103, 3998481, 3932945, 3932945, 4130067, 4129555, 4326677, 4458007, 4392470, 4392214, 4589336, 4589080, 4720410, 4720410, 4851483, 4785947, 4982557, 4917021, 5114143, 5114142, 5179679, 5245215, 5311009, 5179679, 5310751, 5310751, 5245215, 5310751, 5245215, 5245215, 5310751, 5310751, 5245215, 5310751, 5310751, 5376287, 5376287, 5310751, 5244702, 5310238, 5244702, 5179164, 5244701, 5178908, 5178907, 5178907, 5244444, 5178907, 5178651, 5244443, 5178650, 5178650, 5178650, 5047577, 5047577, 4982041, 4916504, 4850968, 4719895, 4719895, 4654358, 4522773, 4522773, 4457749, 4391701, 4326164, 4260628, 4260628, 4129556, 4129556, 4129556, 4129556, 4064020, 4064020, 3998484, 3998484, 3998484, 3998484, 3998484, 3998996, 3933460, 3933460, 3998996, 3933461, 3933461, 3933461, 3867925, 3867925, 3802389, 3802389, 3802389, 3736853, 3802389, 3736853, 3736852, 3736852, 3671315, 3671315, 3671315, 3605778, 3671314, 3736850, 3736850, 3802387, 3802643, 3868179, 3868180, 3933716, 3999252, 3999508, 4065045, 4065044, 4065045, 4065045, 4065045, 4130581, 4130581, 4130581, 4130582, 4130582, 4327190, 4327703, 4327703, 4458776, 4458776, 4327704, 4393496, 4262167, 4327960, 4262424, 4262424, 4328217, 4131352, 4131352, 4131352, 4131609, 4065816, 4066073, 3934744, 4066073, 3869207, 3934744, 3803671, 3869464, 3803928, 3803927, 3607063, 3803928, 3541526, 3738392, 3738136, 3869464, 3738136, 3935001, 3803671, 4000281, 4065817, 4000024, 3868439, 3999511, 3802645, 3933718, 3802644, 3868180), #(3474188, 3407883, 3407883, 3605261, 3538956, 3736335, 3801871, 3735566, 3998482, 3932945, 3932943, 4130067, 4129555, 4130068, 4458007, 4392470, 4589080, 4589336, 4589336, 4720410, 4851484, 4851484, 4982557, 4983069, 4982557, 5114142, 5114143, 5245215, 5114143, 5311009, 5179679, 5245215, 5311007, 5310751, 5245215, 5376545, 5245215, 5310751, 5376289, 5310751, 5376287, 5376287, 5376287, 5376287, 5441823, 5310238, 5375774, 5375774, 5310238, 5310237, 5375773, 5309981, 5309980, 5375517, 5309980, 5309980, 5375517, 5309980, 5309979, 5309980, 5178906, 5178906, 5047834, 4982041, 4916504, 4850968, 4785431, 4719894, 4653846, 4588309, 4457237, 4457237, 4391700, 4326164, 4260628, 4260628, 4129556, 4129556, 4129556, 4064020, 4064019, 4064020, 3998484, 3998483, 3998484, 3998484, 3998996, 3933460, 3933460, 3933460, 3933460, 3933460, 3867924, 3867925, 3867924, 3802389, 3802389, 3802388, 3736853, 3736852, 3736852, 3671316, 3671315, 3671315, 3605779, 3605778, 3605777, 3605777, 3605265, 3605263, 3671313, 3736849, 3802386, 3802643, 3868179, 3933715, 3933716, 3999508, 3999508, 4065045, 4130581, 4130581, 4130581, 4130580, 4130581, 4130581, 4261654, 4327702, 4327703, 4327191, 4458776, 4458776, 4393239, 4393496, 4393496, 4393496, 4393496, 4262424, 4327961, 4262424, 4262681, 4131608, 4131608, 4066072, 4131608, 4000536, 4066073, 3869207, 3935000, 4000537, 3803928, 3803927, 3803927, 3672855, 3738392, 3541527, 3738392, 3869465, 3869465, 3803672, 3935001, 3803672, 4000538, 4131610, 4000281, 4000024, 4131097, 3933975, 4065047, 3933717, 3999253), #(3539724, 3408651, 3407883, 3605261, 3670798, 3604493, 3801871, 3736335, 3998481, 3932945, 3932943, 4064018, 4261397, 4261140, 4392471, 4458007, 4589337, 4589081, 4720410, 4654874, 4851484, 4917020, 4982557, 4982557, 5114143, 5114143, 5245215, 5245215, 5311009,\ 5311009, 5245215, 5245215, 5310753, 5311009, 5310751, 5376289, 5311009, 5376545, 5376289, 5442081, 5376287, 5573154, 5507617, 5441823, 5507359, 5507359, 5441311, 5441311, 5506847, 5441310, 5441311, 5441310, 5441054, 5506846, 5441310, 5441309, 5506846, 5441309, 5375516, 5375516, 5309979, 5244442, 5178906, 5113113, 5047577, 4982040, 4916503, 4850967, 4785431, 4654358, 4588309, 4522773, 4457236, 4391700, 4391700, 4326163, 4260628, 4129555, 4129555, 4129556, 4064019, 4064019, 4064020, 3998483, 3998483, 3998484, 3998483, 3933460, 3932948, 3933460, 3933460, 3867924, 3867924, 3867924, 3802388, 3802388, 3802389, 3736852, 3736853, 3736852, 3736852, 3671316, 3671315, 3671315, 3605778, 3540241, 3540241, 3540239, 3474191, 3474191, 3539727, 3539727, 3670799, 3736849, 3736849, 3802386, 3868179, 3868178, 3999251, 3999508, 4065044, 4065044, 4130581, 4130580, 4130580, 4130581, 4261653, 4327190, 4327190, 4393239, 4458776, 4458776, 4458776, 4459032, 4458776, 4393496, 4393496, 4262424, 4393497, 4262424, 4262681, 4131608, 4131609, 4262682, 4131609, 4066072, 4066072, 4131609, 4000536, 4000537, 3869464, 3935001, 3738392, 3672856, 3738392, 3869465, 3803929, 3869465, 3803929, 4000794, 4000538, 3869464, 4066074, 4131610, 4066074, 4262683, 4131353, 4065561, 4130585, 3999510, 4130327), #(3539725, 3408651, 3342346, 3473420, 3605261, 3605261, 3867407, 3736335, 3998481, 3932943, 4064531, 4064018, 4261141, 4261141, 4458007, 4458007, 4589337, 4523544, 4785947, 4720410, 4917020, 4917020, 5048606, 4982558, 5114143, 5048606, 5179679, 5245471, 5311009, 5311009, 5376546, 5245215, 5442082, 5376546, 5376545, 5376545, 5376545, 5376545, 5441825, 5573154, 5441823, 5638690, 5573154, 5572897, 5572897, 5638434, 5572383, 5572383, 5637921, 5572383, 5572383, 5637919, 5572383, 5572383, 5572383, 5506846, 5506846, 5506846, 5506844, 5441308, 5441052, 5375515, 5309979, 5244442, 5178905, 5113369, 5047577, 4982040, 4916504, 4785431, 4785430, 4719382, 4588309, 4588309, 4522773, 4391700, 4391700, 4326163, 4260627, 4129555, 4129555, 4129555, 4129555, 4130067, 4064019, 4064019, 3998995, 3998483, 3998995, 3933460, 3933459, 3867924, 3867924, 3867924, 3802388, 3802388, 3736852, 3736852, 3736852, 3671316, 3671316, 3671316, 3605778, 3605778, 3605778, 3540241, 3474705, 3474191, 3408655, 3408655, 3474191, 3474190, 3474191, 3605263, 3539727, 3671311, 3736847, 3736847, 3867922, 3868178, 3933714, 3999507, 3999507, 4130580, 4130580, 4130581, 4261653, 4261654, 4327190, 4393239, 4458775, 4458775, 4458775, 4393240, 4458776, 4393496, 4393496, 4459033, 4393496, 4262424, 4328217, 4328217, 4131609, 4262682, 4131609, 4131609, 4066073, 4131866, 4000537, 4066073, 3869464, 3935257, 3738392, 3869465, 3738392, 3869721, 3804185, 3935001, 3869465, 4000794, 3869465, 4066330, 4066330, 4131867, 4131611, 4328475, 4131610, 4393755, 4327962, 4130584, 4261657), #(3539725, 3276809, 3474188, 3473419, 3670798, 3605261, 3867407, 3801871, 3867407, 3867407, 4130067, 4064018, 4261141, 4261397, 4458007, 4589337, 4589337, 4589080, 4785947, 4785946, 4917020, 4917020, 4982557, 5048606, 5114143, 5114142, 5179679, 5179679, 5245473, 5311009, 5442339, 5311009, 5376546, 5376546, 5442338, 5442081, 5573411, 5507618, 5573154, 5638947, 5638690, 5704227, 5704227, 5704227, 5703970, 5769507, 5703970, 5703970, 5769506, 5703457, 5703457, 5637919, 5637919, 5637919, 5637919, 5637919, 5637918, 5637918,\ 5637917, 5572381, 5572381, 5506588, 5441052, 5375515, 5309978, 5244442, 5178650, 5113369, 5113369, 5047576, 4982040, 4916503, 4850967, 4785430, 4719894, 4588821, 4588309, 4457236, 4392212, 4326164, 4260627, 4261139, 4129555, 4130067, 4129555, 4129555, 4064531, 4064532, 3998995, 3998995, 3998996, 3933459, 3867924, 3867924, 3802388, 3802388, 3736852, 3737108, 3671316, 3671316, 3671572, 3605779, 3540242, 3605778, 3540241, 3474703, 3474703, 3408655, 3343119, 3343119, 3343117, 3343117, 3408654, 3408654, 3474190, 3539726, 3539726, 3539726, 3670799, 3736335, 3802383, 3867921, 3867921, 3999250, 4064787, 4130580, 4130581, 4261653, 4327190, 4392726, 4393239, 4392727, 4458775, 4393239, 4458775, 4458776, 4393240, 4458776, 4393497, 4393497, 4327961, 4327961, 4131353, 4328217, 4131609, 4262938, 4066073, 4131609, 3935000, 4066329, 3935257, 4000793, 3803928, 3869721, 3738392, 3869721, 3869721, 3935258, 3869722, 4000794, 3935001, 4131867, 4000537, 4262939, 4131867, 4328475, 4262683, 4459548, 4262682, 4459035, 4459035), #(3343115, 3276810, 3474188, 3474187, 3670798, 3605261, 3867407, 3932945, 3867407, 4129555, 4130067, 4130067, 4261141, 4458007, 4392471, 4589337, 4654873, 4785947, 4785947, 4785947, 4917020, 4982557, 5048606, 5048606, 5114143, 5179935, 5179679, 5179679, 5311009, 5376802, 5376546, 5376546, 5442082, 5442082, 5573411, 5442081, 5638947, 5638691, 5704484, 5704227, 5901093, 5835300, 5835300, 5900837, 5835300, 5835300, 5835300, 5769506, 5835042, 5769506, 5768993, 5768993, 5768993, 5768991, 5768991, 5768991, 5768991, 5768991, 5768991, 5703454, 5703454, 5637661, 5637917, 5572380, 5506844, 5506588, 5441051, 5375515, 5309978, 5244442, 5178905, 5113369, 5047832, 4982296, 4850967, 4785430, 4719894, 4588821, 4588821, 4523284, 4391699, 4326675, 4260627, 4129555, 4130067, 4129555, 4130067, 4130068, 3998483, 3998995, 3998995, 3933459, 3933460, 3867924, 3802388, 3802644, 3736852, 3671572, 3671572, 3605779, 3606036, 3605779, 3540242, 3540498, 3474706, 3409169, 3409167, 3343119, 3343119, 3277582, 3212045, 3212045, 3343117, 3277580, 3343117, 3408653, 3408653, 3474189, 3539726, 3539725, 3605262, 3736335, 3736334, 3867919, 3867921, 3999250, 4130323, 4130580, 4261653, 4327190, 4392726, 4458262, 4327190, 4393239, 4393239, 4393239, 4393240, 4458776, 4393497, 4393497, 4327960, 4327961, 4393753, 4328217, 4131608, 4262682, 4131609, 4131866, 4131866, 4066329, 3935257, 4000793, 3869721, 3935258, 4000795, 3869722, 4066587, 3935258, 3935258, 4066330, 3935258, 4131867, 4262939, 4131867, 4262939, 4394012, 4262939, 4459549, 4328219, 4590621, 4393755), #(3408651, 3342346, 3474188, 3474187, 3736335, 3801871, 3736335, 3998482, 3932945, 4130067, 4129556, 4130067, 4130068, 4523544, 4458007, 4654873, 4654873, 4785947, 4785947, 4917020, 4851484, 4983069, 4983070, 5048607, 5048607, 5245473, 5179679, 5245473, 5311009, 5442339, 5442082, 5573412, 5507618, 5638947, 5704484, 5704484, 5704484, 5770021, 5835557, 5835301, 6032423, 5966630, 5966629, 6032166, 5901092, 5900836, 5966372, 5900835, 5900835, 5900579, 5835042, 5900578, 5900066, 5900065, 5900065, 5900065, 5900063, 5900063, 5965599, 5900063, 5900063, 5900063, 5900063, 5834526, 5768990, 5703453, 5637916, 5572380, 5506844, 5375515, 5375770, 5244442, 5178905, 5113369, 5047576, 4982296, 4916503, 4785429, 4719894, 4654357, 4522772, 4457748, 4391699, 4326163, 4326676, 4129555, 4130068,\ 4130068, 4064019, 4064532, 3998996, 3933459, 3933460, 3867923, 3802387, 3802644, 3671315, 3671572, 3671572, 3540243, 3540499, 3540499, 3474706, 3474962, 3409169, 3343631, 3343631, 3343119, 3277583, 3277582, 3212045, 3146508, 3212044, 3212044, 3277580, 3343117, 3343116, 3408653, 3408652, 3474188, 3539725, 3539725, 3605261, 3670798, 3801871, 3867919, 3998993, 4064786, 4130323, 4261653, 4327189, 4327189, 4261654, 4327191, 4392726, 4327702, 4393239, 4393239, 4393239, 4393240, 4459032, 4393497, 4393497, 4328217, 4328218, 4262681, 4262682, 4131609, 4262938, 4131865, 4131866, 4000794, 4132123, 3935258, 4066331, 3935258, 4132123, 3935258, 4131867, 4131867, 4000794, 4131867, 4328732, 4262940, 4394268, 4328476, 4328476, 4525341, 4394012, 4656414, 4459548), #(3408652, 3605262, 3539725, 3474188, 3605261, 3801871, 3801871, 3998482, 3932945, 4130068, 4064018, 4326934, 4261141, 4523544, 4523544, 4654873, 4654618, 4785947, 4654874, 4851484, 4851484, 4983069, 4983070, 5114143, 5114143, 5179679, 5179935, 5311009, 5311010, 5507875, 5442082, 5639204, 5638948, 5704484, 5770021, 5901350, 5835557, 5966887, 6032423, 6032423, 6097959, 6097959, 6032166, 6032166, 6032165, 6032165, 6031909, 6031908, 6031651, 6031651, 6031651, 6031651, 6097187, 6031138, 6096674, 6097186, 6162210, 6162210, 6162722, 6162209, 6096673, 6031135, 6096671, 5965599, 5900063, 5900062, 5768989, 5768989, 5703453, 5572379, 5572380, 5441307, 5375515, 5309978, 5178905, 5178905, 5047577, 5047833, 4916504, 4785431, 4785431, 4653846, 4588822, 4523285, 4391701, 4326677, 4326677, 4129556, 4130068, 4130068, 4064532, 3998996, 3933460, 3867924, 3867924, 3736851, 3671315, 3671571, 3606035, 3474706, 3474963, 3409170, 3343633, 3409426, 3343631, 3278095, 3278095, 3212046, 3212046, 3212046, 3146509, 3080972, 3080972, 3146508, 3146508, 3212044, 3212044, 3277580, 3277579, 3343115, 3408652, 3408651, 3474188, 3539725, 3670798, 3670798, 3801871, 3933455, 3998993, 4130322, 4130323, 4261652, 4130581, 4130581, 4130581, 4262166, 4327703, 4327702, 4327703, 4393240, 4393495, 4327960, 4393496, 4328217, 4328217, 4262681, 4328218, 4131609, 4262938, 4066329, 4131867, 4066330, 4066331, 3935258, 4132123, 4066587, 4132123, 4000794, 4132124, 4066331, 4132124, 4131867, 4328732, 4328732, 4394268, 4328476, 4525341, 4525341, 4459548, 4656414, 4525084), #(3408652, 3408651, 3474188, 3670798, 3605261, 3867407, 3801871, 3998994, 3998482, 4064019, 4064019, 4326934, 4326677, 4523544, 4458008, 4589337, 4720410, 4785947, 4851484, 4851484, 4983070, 4983069, 4983070, 5114143, 5245471, 5245471, 5376802, 5376546, 5376545, 5573412, 5573155, 5704485, 5770022, 5835558, 5835558, 6032424, 5966887, 6097960, 6163752, 6163752, 6163496, 6163496, 6163495, 6163495, 6163238, 6163237, 6162981, 6162981, 6162724, 6162980, 6228260, 6228260, 6228260, 6294052, 6293796, 6293796, 6359332, 6359332, 6293794, 6293794, 6293794, 6227745, 6228257, 6162207, 6096671, 6096671, 5965599, 5900063, 5834527, 5834527, 5703454, 5637918, 5572382, 5506589, 5441309, 5375516, 5309980, 5244444, 5178907, 5047834, 4982298, 4916505, 4785433, 4719896, 4654360, 4523287, 4523287, 4392214, 4326678, 4261142, 4130069, 4130069, 3998997, 3933460, 3933460, 3802388, 3736851, 3671571, 3605779, 3540499, 3474962, 3343634, 3343889, 3278353, 3212559, 3212559, 3212559, 3080973, 3146510, 3080973, 3015436, 3015436, 3015435, 3015435, 3080971, 3080971,\ 3146507, 3212043, 3277579, 3277579, 3343115, 3343115, 3408651, 3474188, 3539724, 3605262, 3736334, 3801871, 3867407, 3998993, 3998993, 4064785, 4064786, 4130579, 4065044, 4130581, 4130582, 4262166, 4262167, 4327703, 4327703, 4327960, 4393496, 4328217, 4327961, 4262681, 4328217, 4328218, 4262682, 4131609, 4131866, 4066330, 4132123, 4001050, 4132123, 4263196, 4132123, 4132123, 4263196, 4132123, 4263196, 4132123, 4460061, 4328732, 4459804, 4394269, 4590877, 4459805, 4656414, 4721950, 4590877), #(3474189, 3539725, 3474188, 3670798, 3670798, 3867409, 3801871, 3932945, 4130324, 4130068, 4326934, 4326678, 4326678, 4523544, 4654873, 4589337, 4720410, 4720411, 4851484, 4851484, 5048606, 4983070, 5048607, 5114143, 5245473, 5245471, 5442338, 5442338, 5573412, 5638948, 5835814, 5835814, 6032424, 6032424, 6098216, 6163753, 6229289, 6163753, 6229289, 6294825, 6294824, 6294568, 6294568, 6294567, 6294311, 6294310, 6294310, 6359846, 6359590, 6359590, 6425126, 6490662, 6490662, 6490661, 6490662, 6490661, 6490661, 6556197, 6424867, 6490404, 6424867, 6359331, 6359331, 6359331, 6293795, 6227746, 6228259, 6162210, 6096674, 6096674, 5965601, 5900065, 5900065, 5768991, 5703455, 5637919, 5572383, 5441310, 5375774, 5310237, 5244701, 5113372, 4982299, 4982299, 4851226, 4719897, 4654617, 4588824, 4457751, 4392215, 4261142, 4130069, 4130069, 3998997, 3998997, 3933460, 3802388, 3737108, 3671571, 3606035, 3540499, 3409426, 3343889, 3278353, 3212815, 3147023, 3081486, 3081486, 3015949, 3015436, 2949900, 2949899, 2884362, 2884362, 2949898, 2949898, 3015434, 3080971, 3080970, 3146507, 3212043, 3276811, 3277579, 3408652, 3474188, 3539725, 3605261, 3670798, 3736335, 3867407, 3867407, 3867407, 3933457, 3933457, 3933714, 3933971, 4065044, 4065045, 4130582, 4131094, 4262167, 4262167, 4327960, 4262424, 4327960, 4393753, 4328217, 4328217, 4262938, 4262938, 4131866, 4262939, 4131867, 4263196, 4132123, 4328733, 4263196, 4132124, 4328732, 4132123, 4328733, 4460062, 4328732, 4525598, 4525597, 4460061, 4590877, 4525341, 4722207, 4590877, 4918815), #(3671311, 3605262, 3539725, 3736847, 3670799, 3867921, 3998995, 3998994, 4130325, 4130068, 4392470, 4326678, 4458008, 4392471, 4589337, 4589337, 4720411, 4720411, 4917533, 4851484, 4983070, 4983070, 5114399, 5179679, 5311265, 5311009, 5507875, 5573411, 5704485, 5770021, 5966888, 5966888, 6163753, 6163754, 6229289, 6229289, 6294826, 6294825, 6426154, 6425898, 6360361, 6425897, 6425641, 6425640, 6425640, 6490920, 6490920, 6556456, 6556456, 6621992, 6621991, 6621991, 6621991, 6621734, 6687527, 6621734, 6687270, 6687270, 6687271, 6621478, 6621734, 6621734, 6621478, 6555942, 6555942, 6490406, 6490405, 6424869, 6359333, 6293796, 6228260, 6097187, 6097187, 6031651, 5900065, 5834529, 5768991, 5637919, 5572383, 5441310, 5375774, 5310237, 5179164, 5113628, 4982555, 4851226, 4785690, 4720153, 4589080, 4523287, 4392214, 4326678, 4130070, 4130069, 4064533, 3933716, 3867924, 3802644, 3737107, 3606035, 3540499, 3474962, 3409426, 3343890, 3212815, 3147279, 3081487, 3015950, 3015949, 2949901, 2884364, 2884363, 2818826, 2753290, 2818825, 2818825, 2884361, 2949897, 2949129, 3015433, 3146506, 3080202, 3212042, 3277579, 3408652, 3408652, 3539725, 3605261, 3736335, 3736334, 3801870, 3801871, 3802383, 3736847, 3802383, 3802641, 3933714, 3933971, 4065044, 4065045, 4131094, 4131095, 4131095, 4262424, 4262424,\ 4262424, 4262425, 4328217, 4262682, 4328218, 4131866, 4262939, 4131867, 4328475, 4263195, 4394269, 4328732, 4394269, 4328989, 4525598, 4394525, 4525598, 4394525, 4591134, 4460061, 4525598, 4656670, 4591134, 4787743, 4656414, 4853279), #(3736847, 3605775, 3605262, 3736847, 3670799, 3802383, 4130324, 4064531, 4261397, 4130069, 4392471, 4130069, 4458008, 4458007, 4589337, 4589338, 4720411, 4720411, 4851485, 5048606, 4983070, 5048606, 5179935, 5179679, 5442338, 5573412, 5573412, 5835814, 5835815, 5901351, 6098217, 6163753, 6229290, 6229290, 6295082, 6360618, 6426155, 6425898, 6491691, 6557227, 6491434, 6556970, 6622506, 6622250, 6687786, 6687786, 6753322, 6753321, 6753321, 6753321, 6753064, 6818601, 6818601, 6753064, 6818344, 6884137, 6883881, 6883881, 6884137, 6883881, 6818345, 6818345, 6818345, 6752808, 6753064, 6687272, 6621735, 6621735, 6556198, 6490662, 6425125, 6294052, 6228516, 6162723, 6031651, 5966114, 5835041, 5769505, 5703455, 5572383, 5506846, 5441310, 5310237, 5179164, 5113628, 4982555, 4916762, 4785689, 4720153, 4589080, 4457751, 4392214, 4326678, 4130069, 4130069, 4064533, 3933716, 3868180, 3802643, 3671571, 3606035, 3474962, 3409426, 3343889, 3212815, 3147279, 3081743, 2950414, 2950414, 2884877, 2884364, 2818827, 2753290, 2753289, 2687753, 2686983, 2753289, 2752519, 2883593, 2884361, 2949127, 3014665, 3080969, 3146506, 3277579, 3343116, 3474188, 3539725, 3605261, 3670798, 3736334, 3736334, 3670798, 3670798, 3670799, 3605775, 3736847, 3802641, 3933714, 3933971, 4065044, 4065045, 4131094, 4131095, 4262167, 4131351, 4262424, 4262680, 4262681, 4262681, 4262938, 4262939, 4131866, 4394011, 4328732, 4459804, 4328732, 4525598, 4394525, 4525597, 4460061, 4591134, 4525598, 4656671, 4525597, 4722207, 4722207, 4656671, 4787743, 4722206, 4918815), #(3736849, 3671311, 3605263, 3671311, 3933714, 3867921, 4130324, 4064531, 4261397, 4392470, 4326934, 4458263, 4458007, 4458007, 4589337, 4589338, 4720411, 4851996, 4851485, 5048863, 5048606, 5245471, 5311009, 5442338, 5507618, 5704741, 5704485, 5966887, 6032680, 6163753, 6163753, 6295082, 6360619, 6426156, 6426155, 6557227, 6557227, 6688300, 6622764, 6688300, 6688044, 6753580, 6819372, 6884652, 6884652, 6884651, 6884651, 6884394, 6884394, 6949930, 6884138, 6949674, 7015467, 7015211, 7015211, 7015212, 7080748, 7080748, 7080748, 7081004, 7015467, 7015467, 7015467, 6949674, 6884138, 6884137, 6818601, 6753064, 6687527, 6621991, 6490662, 6425125, 6359589, 6228516, 6162723, 6097187, 5966114, 5835041, 5769505, 5703455, 5572383, 5506847, 5375774, 5310237, 5179164, 5113627, 4982555, 4916762, 4785689, 4720153, 4589080, 4457751, 4392215, 4261142, 4130069, 4130325, 3999252, 3933716, 3868180, 3737107, 3671571, 3606034, 3474962, 3409425, 3278351, 3212815, 3081743, 3015950, 2950414, 2819341, 2818828, 2753291, 2687754, 2687754, 2622217, 2556679, 2687753, 2686983, 2752519, 2752519, 2752519, 2883591, 2949127, 3080969, 3146506, 3212043, 3343115, 3408652, 3474189, 3605262, 3670798, 3670797, 3605262, 3605262, 3539726, 3539726, 3539726, 3605775, 3605775, 3737103, 3737362, 3933971, 3933972, 4065046, 4065558, 4131351, 4131352, 4131351, 4131352, 4262681, 4262681, 4328218, 4394011, 4394012, 4459548, 4459804, 4394268, 4591133, 4460061, 4591134, 4460062, 4656670, 4591134, 4722207, 4591135, 4853535, 4656671, 4853279, 4853279, 4787999, 4984607), #(3802641, 3736847, 3802385,\ 3736847, 3999251, 3933457, 4130324, 4064531, 4130324, 4327190, 4326934, 4458264, 4392472, 4654874, 4589337, 4654875, 4720411, 4917533, 4917021, 5179935, 5114143, 5311009, 5376545, 5573412, 5638692, 5901350, 5901351, 6032680, 6098217, 6229546, 6295082, 6360619, 6426155, 6557484, 6622764, 6688300, 6688301, 6819630, 6819373, 6885165, 6950702, 7015982, 7015981, 7015981, 7081517, 7015724, 7081261, 7081005, 7081004, 7081005, 7146541, 7146542, 7146542, 7212078, 7212079, 7212078, 7277870, 7277870, 7212077, 7212333, 7146541, 7146540, 7081004, 7015467, 7015467, 6949674, 6884137, 6884137, 6753064, 6687527, 6621991, 6556198, 6425125, 6359589, 6228516, 6162979, 6097187, 5966114, 5900577, 5769503, 5703455, 5572383, 5506846, 5375773, 5310237, 5179164, 5113627, 4982555, 4851226, 4785689, 4654616, 4523543, 4457751, 4326678, 4261142, 4130325, 4064533, 3999252, 3933716, 3802643, 3737107, 3671570, 3540498, 3474962, 3343889, 3278351, 3147279, 3015950, 2950414, 2819341, 2753804, 2687755, 2622218, 2556682, 2556681, 2491143, 2556679, 2622215, 2621447, 2686983, 2686983, 2818055, 2818055, 2949897, 3015433, 3080970, 3212042, 3277579, 3408652, 3474188, 3539725, 3605261, 3539726, 3539725, 3474189, 3474190, 3474190, 3540238, 4396575, 6832713, 7556951, 5910584, 3737361, 3933971, 3933972, 4065558, 4065559, 4131351, 4131608, 4131608, 4262681, 4328218, 4459546, 4459548, 4525084, 4525340, 4525341, 4591133, 4525341, 4656670, 4787999, 4722207, 4853535, 4787999, 4722463, 4919071, 4722207, 4919071, 4853535, 4853535, 5050143), #(3868178, 3933971, 3933714, 3802385, 3999251, 3933458, 4130324, 4261654, 4130325, 4327190, 4327191, 4458264, 4458007, 4589337, 4589337, 4720411, 4785947, 4983070, 4982557, 5245471, 5376546, 5442082, 5507619, 5770021, 5770021, 5966887, 6032680, 6163753, 6295082, 6295082, 6491947, 6491692, 6557228, 6688557, 6754093, 6819630, 6885166, 7016239, 7081775, 7147311, 7147311, 7212847, 7212591, 7212591, 7278127, 7278127, 7277871, 7277871, 7343408, 7277872, 7343408, 7343408, 7343408, 7343408, 7409200, 7343407, 7343407, 7343407, 7343407, 7277870, 7277869, 7212333, 7212077, 7146540, 7081003, 7015467, 6949930, 6949929, 6884137, 6753064, 6753063, 6621991, 6556198, 6490661, 6359588, 6294052, 6162979, 6097186, 5966114, 5900577, 5769503, 5703455, 5572383, 5506846, 5375773, 5310237, 5179164, 5048091, 4982554, 4851226, 4785689, 4654616, 4523543, 4458007, 4326934, 4261398, 4130325, 4064789, 3999252, 3868180, 3802643, 3671571, 3606034, 3540498, 3409425, 3278351, 3212815, 3081487, 3016206, 2884877, 2753805, 2687756, 2556683, 2491146, 2491145, 2425607, 2425607, 2490375, 2490375, 2622215, 2621447, 2686983, 2752519, 2818823, 2949897, 2949897, 3080970, 3146506, 3277579, 3343116, 3474189, 3539725, 3539725, 3408653, 3474189, 3408653, 3343117, 4791846, 16579836, 16777215, 16777215, 16777215, 12957626, 3606031, 3737362, 3933972, 3933973, 4065558, 4065816, 4131352, 4131609, 4262681, 4393754, 4459547, 4525083, 4590877, 4656413, 4590877, 4787486, 4722206, 4853279, 4787743, 4919073, 4853535, 4853535, 4919071, 4853535, 5050145, 4919071, 5050145, 5115681), #(3736849, 3999508, 3999251, 3867922, 4064788, 4130580, 3999251, 4130581, 4130581, 4327191, 4327191, 4523801, 4392471, 4589337, 4589338, 4785947, 4785947, 5114142, 5245471, 5310751, 5573411, 5573412, 5770277, 5901351, 6032680, 6032680, 6163753, 6295081, 6360619, 6426155, 6623020,\
6622764, 6819630, 6885166, 7016240, 7081776, 7212849, 7212848"
WriteINIStr $INSTDIR\options.ini NEW XSI $Serial

SectionEnd

But this doesnt compile. Please somebody tell me how to break long strings, because normally it is done with \, which I have also used here, as I have read it in the docs.

Anyone can please help?

Btw in NSIS editor, \ is included for each line, but you cant see it here due to formatting of this forum.


No one knows?


Try splitting your huge string up into several smaller ones and assigning them to different registers or variables. Then, write all of those in with your WriteINISTr command.


You mean I should split the string into several lines of which each variable will be only 1 line?

If so, will I have to use strCpy after that?

Lastly how will I combine all variables into one and use WriteINISTr at the end? Because if I should WriteINISTr for each of them, only the last string will be saved to the ini, right?


Thanks alot!


My guess is that you exceeded the max string length allowed for a variable. This compiles for me:


Name "longstring"
OutFile "longstring.exe"

Section ""
StrCpy $0 "#(#(3342347, 3473420, 3407883, 3605261, 3538956, 3736335, 3670030, 3801103, 3998481, 3932945, 3932945, 4130067, 4129555, 4326677, 4458007, 4392470, 4392214"
StrCpy $1 ", 4589336, 4589080, 4720410, 4720410, 4851483, 4785947, 4982557, 4917021, 5114143, 5114142, 5179679, 5245215, 5311009, 5179679, 5310751, 5310751, 5245215"
StrCpy $2 ", 5310751, 5245215, 5245215, 5310751, 5310751, 5245215, 5310751, 5310751, 5376287, 5376287, 5310751, 5244702, 5310238, 5244702, 5179164, 5244701, 5178908"
MessageBox MB_OK "$0$1$2"
SectionEnd

You can play around with how long a string you can assign each variable, and then use
WriteINIStr $INSTDIR\options.ini NEW XSI $Var1$Var2...

dienjd,

You rock! This is something I was expecting. These "$0$1$2" is so different from my language, thats why I couldnt think about it. Now I will really try on this and will let you know about it!

Thanks again!


Hi dienjd,

I have found out the limit of StrCpy and splitted the code before the limit.

But unfortunately I couldnt write the full code with writeINIStr, with this:

StrCpy $0 "#(#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124 ,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,104 62124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,1046212 4,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10 462124,A"
StrCpy $1 "10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,104 62124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10988211,15856371,16580093,16580093,14540513,10462124,10462124,10462124,10462124,1046212 4,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10593710,15264235,16777215,16777215,16777215,14672099,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),# (10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,14277598,16777215,16645629,16777215,16777215,14672099,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,104 62124,B"
StrCpy $2 "10462124,10462124,10462124,10462124,10462124,13224912,16777215,16185079,13422547,16777215,16777215,14672099,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,104 62124,12172483,16711422,16580093,11843518,12830155,16777215,16777215,14672099,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,11383224,16382458,16777215,1269882 6,10462124,12830155,16777215,16777215,14672099,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10856881,15856115,16777215,13817048,10462124,10462124,12830155,16777215,16 777215,14672099,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,12435654,16777215,16777215,16448251,16382714,16382714,16579836,16777215,16777215,16711422,16382714,124356 54,C"
StrCpy $3 "10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,12435654,16777215,16777215,16777215,16777215,16777215,16777215,16777215,16777215,16777215,16777215,12567240,10462124,10462124,10462124,104 62124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10988211,12040897,12040897,12040897,12040897,12040897,13817048,16777215,16777215,15198442,12040897,10988467,10462124,10462124,10462124,10462124,10462124,10462124),#(1046 2124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,12830155,16777215,16777215,14672099,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124 ,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,12830155,16777215,16777215,14672099,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,104 62124,D"
StrCpy $4 "10462124,10462124,10462124,10462124,10527917,10659503,10659503,10593710,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,104 62124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,1046212 4,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10 462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,104621 24E"
StrCpy $5 "10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124XXX"


WriteINIStr $INSTDIR\options.ini NEW XSI "$0$1$2$3$4$5"


It has written only this:
[NEW]
XSI=#(#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462 124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124, 10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,1046 2124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124),#(10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124,10462124 ,10462124,A10462124,1046212


According to kichik, WriteINIStr uses a call to WritePrivateProfileString. I didn't see anything in the MSDN docs about size limitations, but you don't have to use WriteINIStr.

Look at my first post in this thread. It shows how to append text to a file and write it in with FileWrite. There's no way that this shouldn't work, since you can continually append to a file, meaning you don't have to try to write in that huge string all at once.


I have used this and it wrote the same thing as writeINIStr:

FileOpen $7 "$INSTDIR\options.ini" a
FileSeek $7 0 END
FileWrite $7 "$0$1$2$3$4$5"
FileClose $7

Is it possible that I use this method to create an INI entry?


You're still trying to write it in all at once. Use that method to write in _part_ of your string. Then use it again to write in the next part, etc. Each time, it should append your new part to the existing entry. I'm sure there's a more elegant way of doing this, but this is the only way I can think of right now.


Hey dienjd,

Now it works man! Thanks so much! Now I have one question:

How I can find out if there is a section called [NEW] in the ini, and if not create one. But if it exists, then find an entry named XSI. If it doesn't exist, then use FileWrite to write it to an appropriate place. If it exists, then change it.

I know this will be hard to recreate, but isnt there a function like getINIKey so I can see if it returns a value or nothing.


Thanks so much again.


Please see my original response again. Copy the code into a script, add OutFile to the top, and compile. Then, make a sample INI file that contains:
[XSI]
Soft=45


Thanks deinjd. But your example doesnt add the entries to XSI, instead they write it to file directly. Is this what is supposed to happen?

Thanks!


I found a new way.

I will have to create a few ini entries in the same file, of which only this one is very long. So instead of writing alot of routines to see if there is an ini key created, etc. I can first create them like so:

WriteINIStr $INSTDIR\options.ini XSI A "#(true, false, true)"
WriteINIStr $INSTDIR\options.ini XSI B ""
WriteINIStr $INSTDIR\options.ini XSI C ""

After that, I need to know how you can seek the current writing position to a specific position so, when I will write, it will write the values near them, like so:

1st:
[XSI]
A=#(true, false, true)
B=
C=

2nd:
[XSI]
A=#(true, false, true)
B=write here
C=and then here

Please help me out on this, as this is really important for me.

Thanks for all your help already!


Note that Win INI's have different limits under Win9x/ME thant under W2K and XP.

If you have big ini's be sure to test unde Win98