Topic: Save and restore textmarkers to a file (1 of 1), Read 50 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Friday, January 21, 2000 04:23 AM


It's not possible to upload macros to ftp.vedit.com/share : "Disk quotas exceeded".
So I put it here:

//
// BOOKMARK.VDM Christian Ziemski
// ChZiemski@...
//
// 21.01.2000
//
// Makes it possible to save/restore the textmarkers of a vedit buffer.
//
// The textmarker positions are saved to a file .mrk where
// is the actual filename of the buffer.
//
// Attention: This macro is coded quick and dirty within 30 minutes.
// So there is no much error handling!
// And the used registers are not saved/restored.
//
//
// It is recommended to assign those two macros to two keys for easy usage.
//
// (Or maybe the file-close-event-macro and file-open-event-macro are a good
// place for them. But that's not so easy to implement.)
//
//----------------------------------------------------------------------------

// 1.) Save the Text-Markers to a file

// get the actual filename
Out_Reg(99) Name_Write(EXTRA+NOMSG+NOCR) Out_Reg(CLEAR)

// save the markers temporary
#98=80
for(#99=0;#99<10;#99++){
#@98 = Marker(#99)
#98++
}

#98=Buf_Num

//fill the bookmark file
File_Open("|@(99).mrk")
EoF
Del_Block(0,Cur_Pos)
for(#99=80;#99<90;#99++){
Num_Ins(#@99, LEFT+NOCR)
IT(":")
}
File_Save()
Buf_Close(NOMSG)
Buf_Switch(#98)

Return

//-----------------------------------------

// 2.) Restore the Markers from the bookmark file

// get the actual filename
Out_Reg(99) Name_Write(EXTRA+NOMSG+NOCR) Out_Reg(CLEAR)

// get the markers from the bookmark file
if (!File_Exist("|@(99).mrk")){
)
return
}

#98=Buf_Num
File_Open("|@(99).mrk")

for(#99=80;#99<90;#99++){
#@99=Num_Eval(ADVANCE)
Char(1)
}
Buf_Close(NOMSG)
Buf_Switch(#98)

// set the markers for the correct buffer
#98=80
for(#99=0;#99<10;#99++){
Set_Marker(#99,#@98)
#98++
}

Return