[split] Buffer Exchange cleanup script


RE: [split] Buffer Exchange cleanup script
#5
Well, now that my son (and his Christmas Minecraft™ LEGO) has gone off to bed, I think I have worked out the basic logic for this problem.

The key, I think, is to loop the lines in reverse. And since this script is only intended to display the model in its final state, it doesn't have to apply the full rules of buffer exchange and account for all the different visibility changes as you step through the model.

On the first loop, we would look for the first instance of a BUFEXCHG RETRIEVE statement (being the last one in the file). When we find one, we would return its buffer ID (A, B, C, etc.) since only the lines stored in that buffer will display at the final step of the model.

Then we loop the lines a second time, checking whether each line is a BUFEXCHG STORE or RETRIEVE statement—and if so, whether it matches the active buffer ID—or a type 1 reference line. Assuming a starting condition of "true", we would store any type 1 lines in an array. If we encounter a RETRIEVE statement with the active ID, we would toggle the condition to "false". The next ref lines we encounter would then not be stored to the array, since they would be hidden in the final model, until we reach a STORE statement with the active ID. This toggles the condition back to "true", and so on until the beginning of the file is reached.

Finally, we would apply a function to any type 1 lines that are not stored in the array, to comment them out. (Or maybe it makes more sense to change the starting condition to "false" and apply the function to the lines that are in the array.)

This, I think, should do the trick—at least for the main subfile. (But it should be no problem to simply loop through each subfile separately, right?—perhaps on the condition that the subfile isn't called by a ref line that's being commented out…)
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: [split] Buffer Exchange cleanup script - by N. W. Perry - 2022-12-26, 5:10
RE: Simple LDCad script - by Roland Melkert - 2022-04-02, 19:47
RE: Simple LDCad script - by N. W. Perry - 2022-12-24, 14:25
RE: Simple LDCad script - by Roland Melkert - 2022-12-28, 22:00
RE: Simple LDCad script - by N. W. Perry - 2022-12-28, 23:14
RE: Simple LDCad script - by Roland Melkert - 2022-12-29, 19:28
RE: Simple LDCad script - by N. W. Perry - 2022-12-30, 0:25
RE: Simple LDCad script - by N. W. Perry - 2022-04-03, 3:16

Forum Jump:


Users browsing this thread: 1 Guest(s)