Hi,
The error that you getting S is undefined because S should be used inside the quotes "" like "S"
And for you latest requirement please try following snippet
function main() {
var doc = app.activeDocument;
artBoards = doc.artboards;
var count = 1;
for (var i = 1; i <= artBoards.length; i++) {
var a = artBoards[i - 1];
if (i % 2 == 0) { // even number
a.name = "S" + (count) + "B";
count++;
}
else { // odd number
a.name = "S" + (count) + "F";
}
// Adding textframes
artBoards.setActiveArtboardIndex(i - 1);
var _textFrame = doc.textFrames.add();
_textFrame.contents = a.name;
_textFrame.top = a.artboardRect[1] - 10;
_textFrame.left = a.artboardRect[0] + 10;
}
}
main();
Let us know if it resolves your problem.
EDIT : Edit script to incorporate to show textframes for printing purpose with name of the artboard.