kunkel321 Posted July 22, 2019 Report Share Posted July 22, 2019 Hi All. I'm trying to learn to use arrays--which I've never done. My experimental setup is as follows: I have a file on my Desktop called 4MacExp.txt. It contains four lines. foo bar bip wam I have a Text Variable called ProcessedFile that is an array variable with 10 parts. My (not working) code is as follows: <TEXT FILE BEGIN PROCESS Filename="C:\\Users\\SWKunkel\\Desktop\\4MacExp.txt" Start_Record="1" Process_All="TRUE" Records="1" Variable="%ProcessedFile%"/> <TEXT FILE END PROCESS/> <TEXT BOX DISPLAY Title="Variable results" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}{\\f1\\fnil\\fcharset0 Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 ProcessedFile[1]\r\n\\par ProcessedFile[\\f1 2\\f0 ]\r\n\\par ProcessedFile[\\f1 3\\f0 ]\r\n\\par ProcessedFile[\\f1 4\\f0 ]\r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> My textbox at the end has ProcessedFile[1] ProcessedFile[2] ProcessedFile[3] ProcessedFile[4] It seems like the processed parts of the text file should get saved into the first four components of the array, then get displayed in the textbox like foo bar bip wam It doesn't work though. I get an error: Undefined variable or the variable is the wrong type "%ProcessedFile%" Macro Name: ReadWriteIni Line Number: 1 I also tried ProcessedFile[] but that didn't work either. Ideas? Quote Link to comment Share on other sites More sharing options...
rberq Posted July 22, 2019 Report Share Posted July 22, 2019 Text File Process places the entire line into a single variable. When Text File Process reads the first record of your file, "foo" will be placed in ProcessedFile[1]. When Text File Process reads the second record of your file, "bar" will be placed in ProcessedFile[1]. When Text File Process reads the third record of your file, "bip" will be placed in ProcessedFile[1]. When Text File Process reads the fourth record of your file, "wam" will be placed in ProcessedFile[1]. Nothing will ever be placed in ProcessedFile [2], [3], or [4]. If your text file was only a single line, AND that single line contained foo,bar,bip,wam AND you used ASCII File Begin instead of Text File Begin, AND you specified the file as ASCII Delimited Text, then I think the variables would be distributed into [1], [2]. [3]. and [4] as you wish. Quote Link to comment Share on other sites More sharing options...
rberq Posted July 22, 2019 Report Share Posted July 22, 2019 The alternative is to leave your file as is, continue to read it with Text File Process, but put some code after Text File Begin (and before Text File End) to keep count of which record is being handed to the macro and move to [1], [2], [3] and so on as appropriate. Quote Link to comment Share on other sites More sharing options...
kunkel321 Posted July 22, 2019 Author Report Share Posted July 22, 2019 Thanks rberq -- yes, that worked. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.