Reply To: macro to toggle between c/cpp and h

Product Compare Forums Multi-Edit Support macro to toggle between c/cpp and h Reply To: macro to toggle between c/cpp and h

#4215
Tim
Participant

The changes you made allowed the file to open if it was not already open. And asked to reload if already loaded. Also, change didn’t allow to switch from .h to .cpp and .cpp to .h.

Combined attachment works as intended.

Thanks,
Tim

[code:3015th6g]
#include Win32.sh

void FlipC2H() {
str CurrentExtension = Get_Extension(File_Name);
str CurrentFilepath = Truncate_Extension(File_Name);
str NewFile1;
str NewFile2;
switch(Lower(CurrentExtension)) {
case ‘c’:
NewFile1 = CurrentFilepath + ‘.h’;
NewFile2 = CurrentFilepath + ‘.hpp’;
break;
case ‘cpp’:
NewFile1 = CurrentFilepath + ‘.hpp’;
NewFile2 = CurrentFilepath + ‘.h’;
break;
case ‘h’:
NewFile1 = CurrentFilepath + ‘.c’;
NewFile2 = CurrentFilepath + ‘.cpp’;
break;
case ‘hpp’:
NewFile1 = CurrentFilepath + ‘.cpp’;
NewFile2 = CurrentFilepath + ‘.c’;
break;
default:
MessageBox(0, "Unsupported language extension, edit FlipC2H_v2", "FlipC2H Hint", mb_IconError | mb_TaskModal);
return();
}
int flipped = 1;
if (!SWITCH_FILE(NewFile1)) {
if (!SWITCH_FILE(NewFile2)) {
flipped = 0;
}
}
if (flipped == 0) {
if(File_Exists(NewFile1)) {
Return_Str = NewFile1;
RM(’LdFiles /LC=1’);
if(Error_Level != 0) {
if (File_Exists(NewFile2)) {
Return_Str = NewFile2;
RM(’LdFiles /LC=1’);
if(Error_Level != 0) {
RM(’MEERROR’);
}
}
}
}
else if (File_Exists(NewFile2)) {
Return_Str = NewFile2;
RM(’LdFiles /LC=1’);
if(Error_Level != 0) {
if (File_Exists(NewFile1)) {
Return_Str = NewFile1;
RM(’LdFiles /LC=1’);
if(Error_Level != 0) {
RM(’MEERROR’);
}
}
}
}
}
}
[/code:3015th6g]
FlipC2H_v2.s