Sorry about that, I figured it was obvious. I did both _save_pos2(begrec) and _save_pos2(endrec) at the beginning of the macro, then did some modificiations, then got into the replace loops.
Here is the whole macro.
_command PrettifyMarcRecord() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
_save_pos2(begrec);
end_line();
_save_pos2(endrec);
_restore_pos2(begrec);
keyin("\"");
cursor_right(24);
keyin("\"");
split_line();
cursor_right(1);
ch = get_text(1, -3);
for(i=0; (i < 200) && (ch != "\036"); ++i) {
keyin("\"");
cursor_right(3);
keyin("\" \"");
cursor_right(4);
keyin("\" \"");
cursor_right(5);
keyin("\"");
split_line();
cursor_right(1);
ch = get_text(1, -3);
}
_restore_pos2(begrec);
select_line();
_restore_pos2(endrec);
select_line();
while(replace("\\x1e\\x1d", "\\\\036\\\\035\"", "R*P") != STRING_NOT_FOUND_RC) {
_restore_pos2(begrec);
select_line();
_restore_pos2(endrec);
select_line();
} ;
while(replace("\\x1e", "\\\\036\"\\n\"", "R*P") != STRING_NOT_FOUND_RC) {
_restore_pos2(begrec);
select_line();
_restore_pos2(endrec);
select_line();
} ;
while(replace("\\x1f", "\\\\037", "R*P") != STRING_NOT_FOUND_RC) {
_restore_pos2(begrec);
select_line();
_restore_pos2(endrec);
select_line();
} ;
}
The idea is to convert this:
00685nz 2200181n 4500003000600000008004100006010001600047035002300063040001800086100010700104400008800211400008100299643003600380644001100416645001100427646001100438670005400449OCoLC830429n| acabbaaan |a ana an 42030975 a(OCoLC)ocm00028972 aDLCcDLCdDLC1 aBoccherini, Luigi,d1743-1805.tSonatas,mvioloncello, continuo.kSelections (Edizioni Suvini Zerboni)1 aBoccherini, Luigi,d1743-1805.tDodici sonate per violoncello e basso.pParte prima1 aBoccherini, Luigi,d1743-1805.tSonate per violoncello e basso.pParte prima aMilanobEdizioni Suvini Zerboni af5DLC at5DLC as5DLC aBoccherini, L. Sonata in do minore, J.G.2B, 1981.
into a compilable:
"00685nz 2200181n 4500"
"003" "0006" "00000"
"008" "0041" "00006"
"010" "0016" "00047"
"035" "0023" "00063"
"040" "0018" "00086"
"100" "0107" "00104"
"400" "0088" "00211"
"400" "0081" "00299"
"643" "0036" "00380"
"644" "0011" "00416"
"645" "0011" "00427"
"646" "0011" "00438"
"670" "0054" "00449\036"
"OCoLC\036"
"830429n| acabbaaan |a ana \036"
" \037an 42030975\036"
" \037a(OCoLC)ocm00028972\036"
" \037aDLC\037cDLC\037dDLC\036"
"1 \037aBoccherini, Luigi,\037d1743-1805.\037tSonatas,\037mvioloncello, continuo.\037kSelections (Edizioni Suvini Zerboni)\036"
"1 \037aBoccherini, Luigi,\037d1743-1805.\037tDodici sonate per violoncello e basso.\037pParte prima\036"
"1 \037aBoccherini, Luigi,\037d1743-1805.\037tSonate per violoncello e basso.\037pParte prima\036"
" \037aMilano\037bEdizioni Suvini Zerboni\036"
" \037af\0375DLC\036"
" \037at\0375DLC\036"
" \037as\0375DLC\036"
" \037aBoccherini, L. Sonata in do minore, J.G.2B, 1981.\036\035"