darknezz21

Help to write multiple files from an array

13 posts in this topic

How would one use  _FileCreate and an array to create multiple files?

#Include <Array.au3>
#include <File.au3>

Global $Array1[226] = ["2020bb", "2020bba", "2020bbh", "3countb", "alpham2", "androdun", "aodk", "aof2a", "aof2", "aof3", "aof3k", "aof", "bakatono", "bangbead", "bjourney", "blazstar", "breakers", "breakrev", "bstars2", "bstars", "burningf", "burningh", "crsword", "ct2k3sp", "cthd2003", "ctomaday", "cyberlip", "diggerma", "doubledr", "eightman", "fatfursa", "fatfursp", "fatfury1", "fatfury2", "fatfury3", "fbfrenzy", "fightfev", "fightfva", "flipshot", "fswords", "galaxyfg", "ganryu", "garoubl", "garou", "garouo", "garoup", "ghostlop", "goalx3", "gowcaizr", "gpilots", "gururin", "irrmaze", "janshin", "jockeygp", "joyjoy", "kabukikl", "karnovr", "kf10thep", "kf2k2mp2", "kf2k2mp", "kf2k2pla", "kf2k2pls", "kf2k3bla", "kf2k3bl", "kf2k3pcb", "kf2k3pl", "kf2k3upl", "kf2k5uni", "kizuna", "kof10th", "kof2000n", "kof2000", "kof2001h", "kof2001", "kof2002", "kof2003", "kof2k4se", "kof94", "kof95a", "kof95", "kof96h", "kof96", "kof97a", "kof97pls", "kof97", "kof98k", "kof98n", "kof98", "kof99a", "kof99e", "kof99n", "kof99p", "kof99", "kog", "kotm2", "kotmh", "kotm", "lans2004", "lastblad", "lastbld2", "lastbldh", "lastsold", "lbowling", "legendos", "lresort", "magdrop2", "magdrop3", "maglordh", "maglord", "mahretsu", "marukodq", "matrim", "miexchng", "minasan", "mosyougi", "ms4plus", "ms5pcb", "ms5plus", "mslug2", "mslug3b6", "mslug3", "mslug3n", "mslug4", "mslug5", "mslug", "mslugx", "mutnat", "nam1975", "ncombata", "ncombat", "ncommand", "neobombe", "neocup98", "neodrift", "neogeo", "neomrdo", "ninjamas", "nitd", "overtop", "panicbom", "pbobbl2n", "pbobblen", "pbobblna", "pgoal", "pnyaa", "popbounc", "preisle2", "pspikes2", "pulstar", "puzzldpr", "puzzledp", "quizdai2", "quizdais", "quizkof", "ragnagrd", "rbff1", "rbff2h", "rbff2k", "rbff2", "rbffspec", "ridheroh", "ridhero", "roboarma", "roboarmy", "rotd", "s1945p", "samsh5sh", "samsh5sn", "samsh5sp", "samsho2", "samsho3a", "samsho3", "samsho4", "samsho5b", "samsho5h", "samsho5", "samsho", "savagere", "sdodgeb", "sengokh", "sengoku2", "sengoku3", "sengoku", "shocktr2", "shocktra", "shocktro", "socbrawl", "sonicwi2", "sonicwi3", "spinmast", "ssideki2", "ssideki3", "ssideki4", "ssideki", "stakwin2", "stakwin", "strhoop", "superspy", "svcboot", "svcpcba", "svcpcb", "svcplusa", "svcplus", "svcsplus", "svc", "tophunta", "tophuntr", "tpgolf", "trally", "turfmast", "twinspri", "tws96", "viewpoin", "vlinero", "vliner", "wakuwak7", "wh1h", "wh1", "wh2j", "wh2", "whp", "wjammers", "zedblade", "zintrckb", "zupapa"]

$File = "E:\FightCade\config\games\cps.ini"

$Read = ClipPut(FileRead($File))

_FileCreate ( $Array1 )

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'm not in the practice of assigning & declaring an array like you have.

For me, I would do it this way.

Global $a, $Array1

$Array1 = "2020bb, 2020bba, 2020bbh, 3countb, alpham2, androdun, aodk"

$Array1 = StringSplit($Array1, ", ", 1)

For $a = 1 To $Array1[0]

     _FileCreate($Array1[$a])

Next

Obviously I have truncated your very long string (just for the example), and you could still declare and assign on the same line if you wanted.

Also, those are just names, without any extension, so no file type ... and no path.

NOTE - Hopefully you've noticed I've removed brackets and extra quotes from your long string, for this to work. I did this not knowing where that long string was coming from.

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for the reply Saint. When trying to run your example this happens.

$Array1 = _StringSplit($Array1, ", ", 1)
$Array1 = ^ ERROR

My oppologies if I'm going at it wrong with the example.

Edited by darknezz21

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Oops, there is no leading underslash.

$Array1 = StringSplit($Array1, ", ", 1)

Sorry about that.

I had a momentary lapse of memory. :sweating:

Fixed the example.

P.S. And I use that bugger all the time, would you believe. :wacko:

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

I do mine in a similar way

Global $sRegString = "|24x7HELP|331BigDog|*WerKernelReporting|%FP%Friendly fts.exe|*WerKernelReporting|4oD"

Global $aRegKeys = StringSplit($sRegString, "|")

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

It works, thanks Saint. Now how would one go about reading a file and copying the text to the clipboard? I tried my hand at it but it just returns a '1' when tested in a message box.

#include <File.au3>
#Include <Array.au3>

Global $a, $Array1

$Array1 = "2020bb, 2020bba, 2020bbh, 3countb, alpham2, androdun, aodk, aof2a, aof2, aof3, aof3k, aof, bakatono, bangbead, bjourney, blazstar, breakers, breakrev, bstars2, bstars, burningf, burningh, crsword, ct2k3sp, cthd2003, ctomaday, cyberlip, diggerma, doubledr, eightman, fatfursa, fatfursp, fatfury1, fatfury2, fatfury3, fbfrenzy, fightfev, fightfva, flipshot, fswords, galaxyfg, ganryu, garoubl, garou, garouo, garoup, ghostlop, goalx3, gowcaizr, gpilots, gururin, irrmaze, janshin, jockeygp, joyjoy, kabukikl, karnovr, kf10thep, kf2k2mp2, kf2k2mp, kf2k2pla, kf2k2pls, kf2k3bla, kf2k3bl, kf2k3pcb, kf2k3pl, kf2k3upl, kf2k5uni, kizuna, kof10th, kof2000n, kof2000, kof2001h, kof2001, kof2002, kof2003, kof2k4se, kof94, kof95a, kof95, kof96h, kof96, kof97a, kof97pls, kof97, kof98k, kof98n, kof98, kof99a, kof99e, kof99n, kof99p, kof99, kog, kotm2, kotmh, kotm, lans2004, lastblad, lastbld2, lastbldh, lastsold, lbowling, legendos, lresort, magdrop2, magdrop3, maglordh, maglord, mahretsu, marukodq, matrim, miexchng, minasan, mosyougi, ms4plus, ms5pcb, ms5plus, mslug2, mslug3b6, mslug3, mslug3n, mslug4, mslug5, mslug, mslugx, mutnat, nam1975, ncombata, ncombat, ncommand, neobombe, neocup98, neodrift, neogeo, neomrdo, ninjamas, nitd, overtop, panicbom, pbobbl2n, pbobblen, pbobblna, pgoal, pnyaa, popbounc, preisle2, pspikes2, pulstar, puzzldpr, puzzledp, quizdai2, quizdais, quizkof, ragnagrd, rbff1, rbff2h, rbff2k, rbff2, rbffspec, ridheroh, ridhero, roboarma, roboarmy, rotd, s1945p, samsh5sh, samsh5sn, samsh5sp, samsho2, samsho3a, samsho3, samsho4, samsho5b, samsho5h, samsho5, samsho, savagere, sdodgeb, sengokh, sengoku2, sengoku3, sengoku, shocktr2, shocktra, shocktro, socbrawl, sonicwi2, sonicwi3, spinmast, ssideki2, ssideki3, ssideki4, ssideki, stakwin2, stakwin, strhoop, superspy, svcboot, svcpcba, svcpcb, svcplusa, svcplus, svcsplus, svc, tophunta, tophuntr, tpgolf, trally, turfmast, twinspri, tws96, viewpoin, vlinero, vliner, wakuwak7, wh1h, wh1, wh2j, wh2, whp, wjammers, zedblade, zintrckb, zupapa"

$Array1 = StringSplit($Array1, ", ", 1)

For $a = 1 To $Array1[0]

    _FileCreate($Array1[$a] & ".ini")

Next

$File = @ScriptDir & "\neo.ini"

$Read = ClipPut(FileRead($File))

MsgBox(1, "test", $Read)
Edited by darknezz21

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

$string = fileread()

clipput($string)

though i was recently discouraged from nesting functions, your way works fine....and you are reading text files....

 

you are msgboxing the output of clipput (which is a 1 or 0), just hit ctrl v to see if its in the clipboard, or msgbox clipget

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Alright, it is copying to the clipboard. Finally how would one write whats in the clipboard to the array of files?

#include <File.au3>
#Include <Array.au3>
#include <FileConstants.au3>


Global $a, $Array1

$Array1 = "2020bb, 2020bba, 2020bbh, 3countb, alpham2, androdun, aodk, aof2a, aof2, aof3, aof3k, aof, bakatono, bangbead, bjourney, blazstar, breakers, breakrev, bstars2, bstars, burningf, burningh, crsword, ct2k3sp, cthd2003, ctomaday, cyberlip, diggerma, doubledr, eightman, fatfursa, fatfursp, fatfury1, fatfury2, fatfury3, fbfrenzy, fightfev, fightfva, flipshot, fswords, galaxyfg, ganryu, garoubl, garou, garouo, garoup, ghostlop, goalx3, gowcaizr, gpilots, gururin, irrmaze, janshin, jockeygp, joyjoy, kabukikl, karnovr, kf10thep, kf2k2mp2, kf2k2mp, kf2k2pla, kf2k2pls, kf2k3bla, kf2k3bl, kf2k3pcb, kf2k3pl, kf2k3upl, kf2k5uni, kizuna, kof10th, kof2000n, kof2000, kof2001h, kof2001, kof2002, kof2003, kof2k4se, kof94, kof95a, kof95, kof96h, kof96, kof97a, kof97pls, kof97, kof98k, kof98n, kof98, kof99a, kof99e, kof99n, kof99p, kof99, kog, kotm2, kotmh, kotm, lans2004, lastblad, lastbld2, lastbldh, lastsold, lbowling, legendos, lresort, magdrop2, magdrop3, maglordh, maglord, mahretsu, marukodq, matrim, miexchng, minasan, mosyougi, ms4plus, ms5pcb, ms5plus, mslug2, mslug3b6, mslug3, mslug3n, mslug4, mslug5, mslug, mslugx, mutnat, nam1975, ncombata, ncombat, ncommand, neobombe, neocup98, neodrift, neogeo, neomrdo, ninjamas, nitd, overtop, panicbom, pbobbl2n, pbobblen, pbobblna, pgoal, pnyaa, popbounc, preisle2, pspikes2, pulstar, puzzldpr, puzzledp, quizdai2, quizdais, quizkof, ragnagrd, rbff1, rbff2h, rbff2k, rbff2, rbffspec, ridheroh, ridhero, roboarma, roboarmy, rotd, s1945p, samsh5sh, samsh5sn, samsh5sp, samsho2, samsho3a, samsho3, samsho4, samsho5b, samsho5h, samsho5, samsho, savagere, sdodgeb, sengokh, sengoku2, sengoku3, sengoku, shocktr2, shocktra, shocktro, socbrawl, sonicwi2, sonicwi3, spinmast, ssideki2, ssideki3, ssideki4, ssideki, stakwin2, stakwin, strhoop, superspy, svcboot, svcpcba, svcpcb, svcplusa, svcplus, svcsplus, svc, tophunta, tophuntr, tpgolf, trally, turfmast, twinspri, tws96, viewpoin, vlinero, vliner, wakuwak7, wh1h, wh1, wh2j, wh2, whp, wjammers, zedblade, zintrckb, zupapa"

$Array1 = StringSplit($Array1, ", ", 1)

For $a = 1 To $Array1[0]

    _FileCreate($Array1[$a] & ".ini")

Next

$File = @ScriptDir & "\neo.ini"

$Read = ClipPut(FileRead($File))

;MsgBox(1, $Array1, $Array1)

For $a = 1 To $Array1[0]

    FileWrite($Array1[$a] & ".ini", $Read)

Next

Share this post


Link to post
Share on other sites

darknezz21,

I see "$File = "E:FightCadeconfiggamescps.ini"" in the code you posted - what exactly are you trying to do here? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Hi Melba23. It's for an emulator that has you setup keys for each game individually as you load them. The concept here is that it will take a predefined config for a capcom.ini and a neogeo.ini and write the configs for each game using a capcom setup and a neo geo setup. It's just a pain to setup keys for a game you havn't played yet on fightcade. My buddy hosts a stream on twitch where everyone joins a queue to play random games with other people, but more often than not new comers don't have keys setup for the games yet and everyone has to wait.

Edit: This is his channel if anyone were interested in such an event:)

Edit2: Cobbled something together that works using the example in FileWrite. Thanks again for the help everyone.

Edited by darknezz21

Share this post


Link to post
Share on other sites

darknezz21,

That sounds perilously close to being off-limits. As you are obviously a keen gamer, could I suggest that you read our Forum rules before you post again - no-one wants you to fall foul of them. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now