There are two ways to refer to a card in a script: by card name or by number:
card "Sample"
refers to the card with the name Sample. Note that in the case of non-unique card names, i.e. if there is more than one card with the name Sample, it is not defined which one will be referenced.
card 3
refers to the 3rd card in the stack, according to the current card order. The first card has the number 1.
You don't have to explicitely specify a card name or a card number in a script in the sense of a constant like "Sample" or 3; you can give an expression with a string or numeric value, i.e. you can "calculate" which card you want to reference.
For example, if you have a variable cardName with the string value "Sample", the following references the card with the name Sample:
card cardName
Note however that the expression must be a simple expression. That means that in more complex cases you have to use parenthesis. If you have a variable cardNumber with a value of 4, and you want to go to card 8 - double the value of cardNumber - you write:
card (cardNumber * 2)
The following would be an attempt to multiply card 4 with 2, which does not make sense and results in an execution error:
card cardNumber * 2