'AppendFiles '---------------------------------------------------- ' A p p e n d S c r i p t ' 'This script allows you to merge two or more *.smr 'files into one. The timing axis is continuous from 'the beginning of the first file through the end of 'the second file. You elect to have a separation 'between the files, which might be useful if you want 'to be reminded where the two files are joined. ' 'You are able to merge files with different or missing 'channels, but you are prevented from merging files 'with different microseconds/timeSample. ' '12/18/06 '---------------------------------------------------- const kFalse% := 0, kTrue% := 1; var gMain%, gMainUPT, gMainDur, gMainName$, gAppend%, gAppendUPT, gAppendDur, gAppendName$, gNext%, gNextName$, gSeparation, gDone% := 0, ok%, aResult%; fileClose(-1); 'open the initial *.smr file gMain% := FileOpen("",0,1,"Select the FIRST file for appending"); if (gMain% < 0) then halt; 'Stop if no file endif; gMainDur := MaxTime(); gMainUPT := Binsize()*1e6; gMainName$ := filename$(3) + filename$(4); View(gMain%); Window(0,10, 50, 50); 'display in remaining space ChanShow(-1); 'show all channels Draw(0, MaxTime()); 'show the entire file gSeparation := input("Do you want any time, in seconds, between the files?", 0.0, 0.0, 10.0); 'open and append with as many *.smr files as the user wants repeat gAppend% := FileOpen("",0,1,"Select the NEXT file for appending"); if (gAppend% < 0) then halt 'Stop if no file endif; gAppendDur := MaxTime(); 'have a 1 second gap gAppendUPT := Binsize()*1e6; gAppendName$ := filename$(3) + filename$(4); View(gAppend%); Window(50,10, 100, 50); 'display in remaining space ChanShow(-1); 'show all channels Draw(0, MaxTime()); 'show the entire file if gMainUPT <> gAppendUPT then message("Sampling uS/unit time is different between files."); halt; endif 'Create the NEXT file to hold the MAIN file and the APPEND file gNext% := FileNew(7, 1, gMainUPT, 1, gMainDur+gSeparation+gAppendDur); gNextName$ := gMainName$ + "_" + gAppendName$; 'Copy the data to the NEXT file View(gMain%); ChanSave(-1, -1, gNext%, 0, gMainDur, 0); 'copy the MAIN to the beginning of the file View(gAppend%); ChanSave(-1, -1, gNext%, 0, gAppendDur, gMainDur+gSeparation); 'copy the APPEND file after the MAIN file + a separation View(gNext%); windowTitle$(gNextName$); Window(0,50, 100, 90); 'display in remaining space ChanShow(-1); 'show all channels Draw(0, MaxTime()); 'show the entire file DlgCreate("What do you want to do?"); DlgText("Append more files to this one?",1,1); DlgButton(0,"No"); DlgButton(1,"Yes"); ok% := DlgShow(); if ok% = kFalse% then View(gNext%); filesaveas(gNextName$+".smr"); 'fileclose(-1); message("Done"); halt; else view(gMain%); fileclose(); view(gAppend%); fileclose(); gMain% := gNext%; view(gMain%); gMainName$ := gNextName$; gMainDur := MaxTime(); gMainUPT := Binsize()*1e6; View(gMain%); Window(0,10, 50, 50); 'display in remaining space ChanShow(-1); 'show all channels Draw(0, MaxTime()); 'show the entire file endif until gDone% = kTrue%