Awachi Posted April 7, 2022 Share Posted April 7, 2022 Goal is to read the # of the last row in the 2da. Error is "weidu can't make song an integer" (and is on the second instance, not the read) COPY_EXISTING songlist.2da override COUNT_2DA_ROWS 1 rows READ_2DA_ENTRY rows 1 1 song COPY_EXISTING_REGEXP "^.*\.are$" override READ_LONG 0x00bc songoff WRITE_LONG (songoff + 0x0c) song BUT_ONLY Quote Link to comment
subtledoctor Posted April 7, 2022 Share Posted April 7, 2022 (edited) %song% is a string. So I guess you need WRITE_ASCII. EDIT - or rather WRITE_EVALUATED_ASCII. EDIT 2 - or, not sure what you are actually trying to read. Remember that READ_2DA_ENTRY designates the first counted row or column as 0. SO if you are trying to get the index number in the first column, you would do READ_2DA_ENTRY rows 0 1 song Also COUNT_2DA_ROWS gives you the actual number of rows, but when doing a READ or WRITE it again counts one as row 0. In this case because your column count is 1, %rows% matches up because it is counting the row with no valid data in it. (" Name RESOURCE") But it might not be best to include rows like that in your READ. If you are trying to get the value of the bottom-most index in the first column, if it was me, I would probably do this: COPY_EXISTING songlist.2da override COUNT_2DA_COLS cols COUNT_2DA_ROWS cols rows READ_2DA_ENTRY (rows - 1) 0 cols song_num BUT_ONLY Edited April 7, 2022 by subtledoctor Quote Link to comment
jmerry Posted April 7, 2022 Share Posted April 7, 2022 (edited) Considering you're looking for the second entry (the song's name) in the row after the last one, no wonder it can't be converted to an integer. All of the indexing for 2da stuff starts at zero. Edited April 7, 2022 by jmerry Quote Link to comment
Awachi Posted April 7, 2022 Author Share Posted April 7, 2022 (edited) Ah, so first entry is 0 and count from there. Another pixel of width added to my progress bar. Edited April 7, 2022 by Awachi Quote Link to comment
subtledoctor Posted April 7, 2022 Share Posted April 7, 2022 (edited) 7 hours ago, Awachi said: Ah, so first entry is 0 and count from there. Yeah but only in READ_ and SET_ commands. COUNT_2DA_ROWS starts from 1. So COUNT_2DA_ROWS 3 rows might give you a value of 20 in the %rows% variable; but a subsequent READ_2DA_ENTRY rows 1 3 val will error out because the last row number is 19. It can be annoying. Edited April 7, 2022 by subtledoctor Quote Link to comment
Awachi Posted April 7, 2022 Author Share Posted April 7, 2022 This is like idioms in a foreign language. Thanks. Quote Link to comment
guyudennis Posted April 7, 2022 Share Posted April 7, 2022 8 hours ago, subtledoctor said: Yeah but only in READ_ and SET_ commands. COUNT_2DA_ROWS starts from 1. So COUNT_2DA_ROWS 3 rows might give you a value of 20 in the %rows% variable; but a subsequent READ_2DA_ENTRY rows 1 3 val will error out because the last row number is 19. It can be annoying. I met the same annoy-ness and thought I was an idiot... took a big chunk of me hair (pulling) to get it working eventually. Quote Link to comment
jastey Posted April 8, 2022 Share Posted April 8, 2022 On 4/7/2022 at 9:26 AM, Awachi said: Another pixel of width added to my progress bar. We expect a well-explained tutorial at the end of the road. Quote Link to comment
Awachi Posted April 10, 2022 Author Share Posted April 10, 2022 Oof, yeah. I'll gladly pay my debt. Do we like whiteboard presentation via MS Paint? Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.