Unfortunately Magnetic encoding is switched on or off and not easily controllable by a script, but you can switch magnetic encoding off and create a text object that contains the macro commands and data when needed.
The below example should do what you need:
def track1 (Type):
if Type != "NC":
return "~1%" + MemberNo + "?"
Just link this to a text field on the card, you will need to change the macro commands depending on the printer model.
Hope that helps,
CardExchange Solutions Support Team
"If you define the problem correctly, you almost have the solution." (Steve Jobs)
I used my function. Added a "page 2" layout and put a mag stripe on page 2. I also made the page "not printable" and marked as "backside."
I did not have to put the stop and start escape codes in as they are part of the printer settings.
I use a Fargo 4500e. If there is mag data to put on the track then the printer will say "Encoding Magstripe" (or something like that) If the function returns "None" then the printer does not even attempt to encode the stripe.
We verified the results with our separate encoder.