简体   繁体   中英

Error 25 on startup script Photoshop

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);

最后,您在这里缺少两个圆括号:

orderNumber = Math.floor(Math.random()*1000) + "-" + Math.floor(Math.random()*10000000 + "-" + Math.floor(Math.random()*10000000

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM