Reputation:
So I want to code a script changing text based on what we entered but I have an error 25 when lauching the script.
The error appears on line 33 (changeTextLayerContent(Invoice1, 'Date 1', date)), thank you in advance guys !
function changeTextLayerContent(doc, layerName, newTextString) {
for (var i = 0, max = doc.layers.length; i < max; i++) {
var layerRef = doc.layers[i];
if (layerRef.typename === "ArtLayer") {
if (layerRef.name === layerName && layerRef.kind === LayerKind.TEXT) {
layerRef.textItem.contents = newTextString;
}
} else {
changeTextLayerContent(layerRef, layerName, newTextString);
}
}
}
name1 = prompt("Entre le nom 'Michel Dupont'", "")
adressStreet = prompt("Entre l'adresse '1 rue de la Paix'", "")
adressCP = prompt("Entre le code postal", "")
adressCity = prompt("Entre la ville", "")
adressCountry = prompt("Entre le code du Pays 'FR'", "")
date = prompt("Entre la date de la commande (sans l'année) '1 janvier'", "")
year = prompt("entre l'année", "")
price = parseInt(prompt("Entre le prix (avec une virgule '149,99')", ""))
objectName = prompt("Entre le nom complet de l'objet", "")
ASIN = prompt("Entre l'ASIN (à trouver sur la page Amazon)", "")
adressFull = name1 + "\
" + adressStreet + "\
" + adressCity +", " + adressCP + "\
" + adressCountry
date = date + " " + year
invoiceNumber = "AEU-INV-FT-" + year + "-" + Math.floor(Math.random()*100000000)
orderNumber = Math.floor(Math.random()*1000) + "-" + Math.floor(Math.random()*10000000 + "-" + Math.floor(Math.random()*10000000
changeTextLayerContent(Invoice1, 'Date 1', date);
changeTextLayerContent(Invoice1, 'Date 2', date);
changeTextLayerContent(Invoice1, 'Number 1', invoiceNumber);
changeTextLayerContent(Invoice1, 'Number 2', orderNumber);
changeTextLayerContent(Invoice1, 'Price 1', price + " €");
changeTextLayerContent(Invoice1, 'Adress 1', adressFull);
changeTextLayerContent(Invoice1, 'Adress 2', adressFull);
changeTextLayerContent(Invoice1, 'Adress 3', adressFull);
Upvotes: 0
Views: 280
Reputation: 2269
You're missing two round parenthesis here in the end:
orderNumber = Math.floor(Math.random()*1000) + "-" + Math.floor(Math.random()*10000000 + "-" + Math.floor(Math.random()*10000000
Upvotes: 1
Reputation: 116
From my experience with Adobe Scripting it doesn't like it when you reassign a value to itself. Your are doing this on 29 when you do the following (date = date + " " + year).
Try assigning that to a new variable and using it 33 and 34.
Upvotes: 0