> For the complete documentation index, see [llms.txt](https://helpcenter.etron.info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://helpcenter.etron.info/onretail-wiki/sonstiges/ean13-generieren.md).

# EAN13 generieren

<img src="/files/I5VyNdft7c6Ybv7XBezw" alt="" data-size="original">

### Online Prüfung

Kann zB mittels Website geschehen: <https://www.getnewidentity.com/validate-ean.php>\
Oder Sie verwenden die Javascript Tools aus dem nächsten Abschnitt

### Generieren von EAN 13 Barcodes (und Prüfen)

In Javascript. Das kann über jede Browser Konsole geschehen.\
ZB in Google Chrome via F12 oder das Menu die Entwickler Tools öffnen, dann "Console" anwählen und nachstehend Code hineinkopieren und ENTER.\
Danach können die Funktionen laut Beschreibung aufgerufen werden.

```
/**
    EAN13 Hilfsfunktionen
    (copyright) 2022 ETRON Software

Verwendung:

Liste von EANs generieren, Startwert und Anzahl:
> generateEans(100000000000, 5)
-> ['1000000000009', '1000000000016', '1000000000023', '1000000000030']


Liste von EANs im CSV Format ausgeben. 
Der String kann direkt nach Excel kopiert, bzw in .csv Datei abgespeichert werden
> generateEanCsv(100000000000, 5)


Prüfen eines EAN13:
> isEanOK('1000000000009')
-> True
> isEanOK('1000000000007')
-> False


Einzelne Prüfzahl generieren:
> addCheckDigit(10000000000)
-> '1000000000009'

*/


function addCheckDigit(ean) {
    ean = `${ean}`
    if (ean.length != 12) { 
        throw('Bitte EAN13 ohne Prüfziffer angeben, 12 Stellen erwartet!') 
    }
    let checkDigit = (10 - `${ean}0`.split('').reduce(reduceHelper, 0) % 10) % 10
    return `${ean}${checkDigit}`
}

function isEanOK(ean) {
    ean = `${ean}`
    return  ean.split('').reduce(reduceHelper, 0) % 10 == 0 && 
            ean.length == 13
}

function generateEans(start, count) {
    let eans = []
    for (let i=0; i<count; i++) {
        eans.push(addCheckDigit(start+i))
    }
    return eans
}

function generateEanCsv(start, count) {
    let csv = `"${generateEans(start, count).join('";\n"')}";\n`
    copy(csv)
    console.log(csv)
    console.log("CSV String erstellt, in Zwischenablage kopiert")
    return csv
}

function reduceHelper(p,v,i) {
    return i % 2 == 0 ? p + 1 * v : p + 3 * v
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://helpcenter.etron.info/onretail-wiki/sonstiges/ean13-generieren.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
