Script not returning input when typed

I’m really not sure whats going on here. In a script I’m asking for input. If I swipe my gift card it returns, but if I just type it in “Manual Input” it returns nothing. I’ve tried a few different ways, but nothing seems to work. What am I missing?

function swipe() {

var card = dlg.EditValue("Swipe Gift Card;;;ONC","");
var check = card.substring(2,2);
var card_number = "";

if (check = "B") {
  return card_number = card.substring(card.lastIndexOf("B")+1, card.lastIndexOf("^"));
} else {
  return card;
  }
}

Can you post a raw string of a gift card. I can’t get a screen shot as fast as it disappears.

Also, change if (check = "B") to if (check == "B") = is for assignment and == for comparison.

2 Likes

Not sure how I missed that. Its been a long day. It wasn’t making it into the else statement and the blank was a result of the invalid index since the typed number didn’t contain the proper index characters.

1 Like

I get it all the time. The IDE tells me what the problem is, yet sometimes I stare and can’t see it.

It’s usually this little bastard at the end of a line that is off-screen:

2021-03-04_20;05_1614909942_firefox

2 Likes