'DESCRIPTION: X: Include: XML Hilfsroutinen
'USEDBY: Always

'dim erg as long

'Formatierungen
function fxmltext( text as string, laenge as long) as string
dim i as long
dim laenge2 as long
dim text2 as string
dim ch as string
  text = ltrim$(rtrim$(text))
  if laenge > 0 then
    text = mid$( text, 1, laenge)
  end if
 
  text2 = ""
  laenge2 = len(text)
  for i = 1 to laenge2
    ch = mid$(text, i, 1)
    if ch = "¢" then ch = chr$(162)
    if ch = "£" then ch = chr$(163)
    if ch = "§" then ch = chr$(167)
    if ch = "Ä" then ch = "Ae"
    if ch = "Ö" then ch = "Oe"
    if ch = "Ü" then ch = "Ue"
    if ch = "ß" then ch = "ss"
    if ch = "ä" then ch = "ae"
    if ch = "ö" then ch = "oe"
    if ch = "ü" then ch = "ue"
    if ch = "<" then ch = "&lt;"
    if ch = ">" then ch = "&gt;"
    if ch = "&" then ch = "&amp;"
    if ch = chr$(34) then ch = "&quot;"
    if ch = "'" then ch = "&apos;"
    if (asc(ch) < 32) or (asc(ch) > 127) then ch = " "
    text2 = text2 + ch
  next
  if laenge > 0 then
    text2 = mid$( text2, 1, laenge)
  end if

  fxmltext = text2
end function

'Format Dezimalzahl 2 Nachkommastellen
function fxmldez( dez as double) as string
dim text as string
  text = str$( dez, 0, 2)
  findreplace( text, ",", ".", 0, 0)
  fxmldez = text
  if dez <= 0 then erg = messagebox("Dezimalzahl darf nicht kleiner oder gleich 0 sein", 0)
end function

'Format CCYY-MM-DDTHH:MM:SS
function fxmldatumzeit( datum as long, zeit as long) as string
  fxmldatumzeit = mid$(str$(datum), 1, 4) + "-" + mid$(str$(datum), 5, 2) + "-" + mid$(str$(datum), 7, 2) + "T" + mid$(str$(zeit), 1, 2) + ":" + mid$(str$(datum), 3, 2) + ":" + mid$(str$(datum), 5, 2)
  if datum < 1011000 then erg = messagebox("Datum darf nicht kleiner als 1.1.1000 sein", 0)
  if zeit = 0 then erg = messagebox("Zeit darf nicht 0 sein", 0)
end function

'Format CCYY-MM-DD
function fxmldatum( datum as long) as string
  fxmldatum = mid$(str$(datum), 1, 4) + "-" + mid$(str$(datum), 5, 2) + "-" + mid$(str$(datum), 7, 2)
  if datum < 1011000 then erg = messagebox("Datum darf nicht kleiner als 1.1.1000 sein", 0)
end function
