gcue Posted August 6, 2015 Posted August 6, 2015 hello world =)i am trying to add a new column after every record. the method i am using is pretty dirty - writing to a tempfile and going through each line to add a new column after every last instance of a record. i think it might be a better job for stringregexp? here is the string (basically a declaration of an array with unpredictable values)$string = 'Local $flash[7][3]' & @CRLF & @CRLF $string &= '$flash[0][0] = "AAAAAA1111-111"' & @CRLF $string &= '$flash[0][1] = "AAAAAA1111*111"' & @CRLF $string &= '$flash[0][2] = "AAAAAA1111^111"' & @CRLF $string &= '$flash[1][0] = "BBBB!BB1111111"' & @CRLF $string &= '$flash[1][1] = "BBB$BBB1111111"' & @CRLF $string &= '$flash[1][2] = "BBBBB%B1111111"' & @CRLF $string &= '$flash[2][0] = "CCCCCC222-2222"' & @CRLF $string &= '$flash[2][1] = "CCC*CCC2222222"' & @CRLF $string &= '$flash[2][2] = "CCCCCC22-22222"' & @CRLF $string &= '$flash[3][0] = "DDDD-DDD333333"' & @CRLF $string &= '$flash[3][1] = "DDD#DDDD333333"' & @CRLF $string &= '$flash[3][2] = "DDDDD*DD333333"' & @CRLF $string &= '$flash[4][0] = "EEEEEE$4444444"' & @CRLF $string &= '$flash[4][1] = "EEEEEE#4444444"' & @CRLF $string &= '$flash[4][2] = "EEEEEE!4444444"' & @CRLF $string &= '$flash[5][0] = "FFFFFF-5555555"' & @CRLF $string &= '$flash[5][1] = "FFFFFF;5555555"' & @CRLF $string &= '$flash[5][2] = "FFFFFF*5555555"' & @CRLF $string &= '$flash[6][0] = "GG%GGGGGG6666666"' & @CRLF $string &= '$flash[6][1] = "GGG^GGGGG6666666"' & @CRLF $string &= '$flash[6][2] = "GGGGGG*GG6666666"'i am trying to add a third column ($flash[X][3] = "") for each recordso id like to be able to say replace X_TEXT with Y_TEXTY_TEXT would essentially be the [2] column line for every record PLUS the new line $flash[X][3] = ""hope this makes sense.thank you in advance!
water Posted August 6, 2015 Posted August 6, 2015 UseReDim $flash[7][4]to add a column to the array. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
gcue Posted August 6, 2015 Author Posted August 6, 2015 right.. but im actually writing the text syntax to rebuild the array.. not actually rebuilding the array.. not sure if that makes sense?
water Posted August 6, 2015 Posted August 6, 2015 So you want to change the script source?$string = 'Local $flash[7][3]' & @CRLF & @CRLF $string &= '$flash[0][0] = "AAAAAA1111-111"' & @CRLF $string &= '$flash[0][1] = "AAAAAA1111*111"' & @CRLF $string &= '$flash[0][2] = "AAAAAA1111^111"' & @CRLFto$string = 'Local $flash[7][3]' & @CRLF & @CRLF $string &= '$flash[0][0] = "AAAAAA1111-111"' & @CRLF $string &= '$flash[0][1] = "AAAAAA1111*111"' & @CRLF $string &= '$flash[0][2] = "AAAAAA1111^111"' & @CRLF $string &= '$flash[0][3] = "AAAAAA1111/111"' & @CRLF ... My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
gcue Posted August 7, 2015 Author Posted August 7, 2015 almost...from this$string = 'Local $flash[7][3]' & @CRLF & @CRLF $string &= '$flash[0][0] = "AAAAAA1111-111"' & @CRLF $string &= '$flash[0][1] = "AAAAAA1111*111"' & @CRLF $string &= '$flash[0][2] = "AAAAAA1111^111"' & @CRLF $string &= '$flash[1][0] = "BBBB!BB1111111"' & @CRLF $string &= '$flash[1][1] = "BBB$BBB1111111"' & @CRLF $string &= '$flash[1][2] = "BBBBB%B1111111"' & @CRLF $string &= '$flash[2][0] = "CCCCCC222-2222"' & @CRLF $string &= '$flash[2][1] = "CCC*CCC2222222"' & @CRLF $string &= '$flash[2][2] = "CCCCCC22-22222"' & @CRLF $string &= '$flash[3][0] = "DDDD-DDD333333"' & @CRLF $string &= '$flash[3][1] = "DDD#DDDD333333"' & @CRLF $string &= '$flash[3][2] = "DDDDD*DD333333"' & @CRLF $string &= '$flash[4][0] = "EEEEEE$4444444"' & @CRLF $string &= '$flash[4][1] = "EEEEEE#4444444"' & @CRLF $string &= '$flash[4][2] = "EEEEEE!4444444"' & @CRLF $string &= '$flash[5][0] = "FFFFFF-5555555"' & @CRLF $string &= '$flash[5][1] = "FFFFFF;5555555"' & @CRLF $string &= '$flash[5][2] = "FFFFFF*5555555"' & @CRLF $string &= '$flash[6][0] = "GG%GGGGGG6666666"' & @CRLF $string &= '$flash[6][1] = "GGG^GGGGG6666666"' & @CRLF $string &= '$flash[6][2] = "GGGGGG*GG6666666"'to this$string = 'Local $flash[7][3]' & @CRLF & @CRLF $string &= '$flash[0][0] = "AAAAAA1111-111"' & @CRLF $string &= '$flash[0][1] = "AAAAAA1111*111"' & @CRLF $string &= '$flash[0][2] = "AAAAAA1111^111"' & @CRLF $string &= '$flash[0][3] = ""' & @CRLF $string &= '$flash[1][0] = "BBBB!BB1111111"' & @CRLF $string &= '$flash[1][1] = "BBB$BBB1111111"' & @CRLF $string &= '$flash[1][2] = "BBBBB%B1111111"' & @CRLF $string &= '$flash[1][3] = ""' & @CRLF $string &= '$flash[2][0] = "CCCCCC222-2222"' & @CRLF $string &= '$flash[2][1] = "CCC*CCC2222222"' & @CRLF $string &= '$flash[2][2] = "CCCCCC22-22222"' & @CRLF $string &= '$flash[2][3] = ""' & @CRLF $string &= '$flash[3][0] = "DDDD-DDD333333"' & @CRLF $string &= '$flash[3][1] = "DDD#DDDD333333"' & @CRLF $string &= '$flash[3][2] = "DDDDD*DD333333"' & @CRLF $string &= '$flash[3][3] = ""' & @CRLF $string &= '$flash[4][0] = "EEEEEE$4444444"' & @CRLF $string &= '$flash[4][1] = "EEEEEE#4444444"' & @CRLF $string &= '$flash[4][2] = "EEEEEE!4444444"' & @CRLF $string &= '$flash[4][3] = ""' & @CRLF $string &= '$flash[5][0] = "FFFFFF-5555555"' & @CRLF $string &= '$flash[5][1] = "FFFFFF;5555555"' & @CRLF $string &= '$flash[5][2] = "FFFFFF*5555555"' & @CRLF $string &= '$flash[5][3] = ""' & @CRLF $string &= '$flash[6][0] = "GG%GGGGGG6666666"' & @CRLF $string &= '$flash[6][1] = "GGG^GGGGG6666666"' & @CRLF $string &= '$flash[6][2] = "GGGGGG*GG6666666"' & @CRLF $string &= '$flash[6][3] = ""'thanks for your help!
water Posted August 7, 2015 Posted August 7, 2015 I still don't fully understand your problem.Can't you just copy the changed lines from your last post to your script? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
gcue Posted August 7, 2015 Author Posted August 7, 2015 actually im working on a script that modifies existing arrays.. so in case you wanted to add/delete a column/record to your existing array you can do so without losing your existing values.
water Posted August 7, 2015 Posted August 7, 2015 So you write a script to modify the source code of another script? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
BrewManNH Posted August 7, 2015 Posted August 7, 2015 Have you tried using _ArrayColInsert or _ArrayColDelete? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
gcue Posted August 7, 2015 Author Posted August 7, 2015 actually its meant for hard coded arrays.. where values to arrays are set within the script. so its for cases where those arrays need modifying..
water Posted August 7, 2015 Posted August 7, 2015 Hard coded values ... BBRRR.Wouldn't it make more sense to store those values in a file?Proof of concept:Store the array in a CSV and retrieve it when needed. #include <File.au3> Local $flash[7][3] $flash[0][0] = "AAAAAA1111-111" $flash[0][1] = "AAAAAA1111*111" $flash[0][2] = "AAAAAA1111^111" $flash[1][0] = "BBBB!BB1111111" $flash[1][1] = "BBB$BBB1111111" $flash[1][2] = "BBBBB%B1111111" $flash[2][0] = "CCCCCC222-2222" $flash[2][1] = "CCC*CCC2222222" $flash[2][2] = "CCCCCC22-22222" $flash[3][0] = "DDDD-DDD333333" $flash[3][1] = "DDD#DDDD333333" $flash[3][2] = "DDDDD*DD333333" $flash[4][0] = "EEEEEE$4444444" $flash[4][1] = "EEEEEE#4444444" $flash[4][2] = "EEEEEE!4444444" $flash[5][0] = "FFFFFF-5555555" $flash[5][1] = "FFFFFF;5555555" $flash[5][2] = "FFFFFF*5555555" $flash[6][0] = "GG%GGGGGG6666666" $flash[6][1] = "GGG^GGGGG6666666" $flash[6][2] = "GGGGGG*GG6666666" _ArrayDisplay($flash) _FileWriteFromArray("C:\temp\test.csv", $flash, 0) Global $aArray _FileReadToArray("C:\temp\test.csv", $aArray, $FRTA_NOCOUNT, "|") _ArrayDisplay($aArray)This makes changes much easier. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted August 7, 2015 Posted August 7, 2015 Hard coded values ... BBRRR.Wouldn't it make more sense to store those values in a file?Proof of concept:Store the array in a CSV and retrieve it when needed. #include <File.au3> Local $flash[7][3] $flash[0][0] = "AAAAAA1111-111" $flash[0][1] = "AAAAAA1111*111" $flash[0][2] = "AAAAAA1111^111" $flash[1][0] = "BBBB!BB1111111" $flash[1][1] = "BBB$BBB1111111" $flash[1][2] = "BBBBB%B1111111" $flash[2][0] = "CCCCCC222-2222" $flash[2][1] = "CCC*CCC2222222" $flash[2][2] = "CCCCCC22-22222" $flash[3][0] = "DDDD-DDD333333" $flash[3][1] = "DDD#DDDD333333" $flash[3][2] = "DDDDD*DD333333" $flash[4][0] = "EEEEEE$4444444" $flash[4][1] = "EEEEEE#4444444" $flash[4][2] = "EEEEEE!4444444" $flash[5][0] = "FFFFFF-5555555" $flash[5][1] = "FFFFFF;5555555" $flash[5][2] = "FFFFFF*5555555" $flash[6][0] = "GG%GGGGGG6666666" $flash[6][1] = "GGG^GGGGG6666666" $flash[6][2] = "GGGGGG*GG6666666" _ArrayDisplay($flash) _FileWriteFromArray("C:\temp\test.csv", $flash, 0) Global $aArray _FileReadToArray("C:\temp\test.csv", $aArray, $FRTA_NOCOUNT, "|") _ArrayDisplay($aArray)This makes changes much easier. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now