Jump to content

Update Variable from 2D Array - (Moved)


JohnTWI
 Share

Recommended Posts

I have a variable that needs to be updated based on 2D array (first column is the match for the variable, 2nd column is the updated variable value).

I was able to get this to work using an ini file, but the array has gotten way to big for the 32K limit on an ini file.

Sample code below of working ini option, I am looking for text or csv file option:

 

$sources = IniReadSection("sources.ini", "source")  

$txt = FileRead("file.txt")

For $i = 1 to $sources[0][0]
   $txt = StringRegExpReplace($txt, $sources[$i][0], $sources[$i][1])
Next


FileWrite("tesxxout.txt", $txt & @CRLF)

Link to comment
Share on other sites

  • Developers

Are you going to take notice this time as this isn't the first time we move your thread!

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Hi.

you can keep an INI like structure

#include <Array.au3>
#include <Debug.au3>


; create a sample file with OldVal=NewVal, like INI files do, just without [SECTIONS]
$StrSample="old=new" & @CRLF & _
"alt=neu" & @CRLF & _
"history=future"

$ReplTableTXT="C:\temp\ReplTable.txt"
$f=FileOpen($ReplTableTXT,2+8)
FileWrite($f,$StrSample)
FileClose($f)

; read the full file into a STRING variable
$StrReplacmenets=FileRead($ReplTableTXT)

; add the value pairs to pre-DIM-med array using _arrayadd()
dim $aRegEx[1][2]=[[0]]
_DebugArrayDisplay($aRegEx)

_ArrayAdd($aRegEx,$StrReplacmenets,0,"=",@CRLF)
$aRegEx[0][0]=UBound($aRegEx) - 1
_DebugArrayDisplay($aRegEx)

cu, rudi

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...