Magus Posted January 25, 2017 Share Posted January 25, 2017 I have the following approximate code COPY_EXISTING_REGEXP GLOB ~^.+\.bcs$~ ~override~ changed1 = 0 changed2 = 0 DECOMPILE_AND_PATCH BEGIN REPLACE_TEXTUALLY ~a~ ~b~ PATCH_IF (...) BEGIN changed1 = 1 END END PATCH_IF changed1 = 1 BEGIN PATCH_PRINT ~file %SOURCE_FILE% was changed by patch1~ END DECOMPILE_AND_PATCH BEGIN REPLACE_TEXTUALLY ~c~ ~d~ PATCH_IF (...) BEGIN changed2 = 1 END END PATCH_IF changed2 = 1 BEGIN PATCH_PRINT ~file %SOURCE_FILE% was changed by patch2~ END BUT_ONLY How would I detect the change to set the corresponding vars? Link to comment
DavidW Posted January 25, 2017 Share Posted January 25, 2017 If you just want to tell if the file is changed, use FILE_MD5. 99% of the time, you should be able to check for the specific thing you're changing, though. e.g. in your actual examples, use INDEX_BUFFER to see if there are any occurrences of the swapped character. Link to comment
Mike1072 Posted January 25, 2017 Share Posted January 25, 2017 REPLACE_EVALUATE is similar to REPLACE_TEXTUALLY and lets you execute some code for each match it finds. Link to comment
Magus Posted January 25, 2017 Author Share Posted January 25, 2017 I'm not sure how index_buffer would help, it needs a string, and I have a file. But it looks like replace_evaluate should do the job, I forgot about it, thanks. Link to comment
DavidW Posted January 25, 2017 Share Posted January 25, 2017 I'm not sure how index_buffer would help, it needs a string, and I have a file. But it looks like replace_evaluate should do the job, I forgot about it, thanks. In this context, the string is the file. Link to comment
K4thos Posted January 25, 2017 Share Posted January 25, 2017 either REPLACE_EVALUATE or use code like this: COUNT_REGEXP_INSTANCES ~text~ num_matches PATCH_IF num_matches > 0 BEGIN REPLACE_TEXTUALLY ~test~ ~replacedText~ END ELSE BEGIN //do something if text for replace is not present, for example use PATCH_WARN END Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.