/*
**  $VER: ÜbernehmeV 4.011 (29 Nov 1998)  **
**           für FIASCO
**        © 1996/98 Gerald Froehlich
**
**  PROGRAMNAME:
**      ÜbernehmeV
**
**  FUNCTION:
**     Übernimmt Daten aus Überweisungsvorlage
**     und setzt sie in die Ü-Maske ein - ohne
**     in die Vorlagenmaske wechseln zu müssen
**      (speziell von und für G. Stummhöfer!;)
**
**  $HISTORY:
**
**  29 Nov 1998 : 004.011 :  unverändert
**  14 Nov 1998 : 003.713 :  dummy neu
**  13 Nov 1998 : 003.712 :  neuer Get/Setfield
**  30 Sep 1998 : 003.711 :  Kontonr. -> KontoNr
**  29 Jun 1998 : 003.710 :  unverändert
**  14 Jan 1997 : 003.101 :  identisch
**   20 Mar 1996 : 0.01 : initial release
*/


Options Results
Address FIASCO

F_SelectProj Vorlagen.fdb  /* diese Zeile wurde neu eingefügt */

F_neu = "6.282"

IF GetClip("F_Version") ~< F_neu THEN DO

  IF ~abbrev(ADDRESS(), "FIASCO.") THEN DO
    /* Get list of all available ports */

    ports = show("Ports")

    /* Search for a port of Fiasco */

    do i = 1 to words(ports)

        portname = word(ports, i)

        if abbrev(portname, "FIASCO.") then
        do
            if datatype(substr(portname, 8), "Numeric") then
            do
                /* A port of Fiasco has been found.
                 * Now query Fiasco to return the port
                 * name of the active database.
                 */

                Address Value portname

                GetAttr Project Name Active ARexx

                /* This command may fail when
                 * no projects are active. This is
                 * for example the case, when all
                 * projects are hidden.
                 */

                if rc == 0 then
                do
                    Address Value Result
                end
                else
                do
                    RequestChoice '"No active project" "Cancel" Title "' || scriptname || '"'

                    call bail_out
                end

                break
            end
        end
    end
  END

  fiasco_port = ADDRESS()

  SIGNAL on Syntax
  SIGNAL on Halt
  SIGNAL on Break_C
  SIGNAL on Failure

  /* This script runs WHILE the user cannot DO anything
   * in Fiasco's GUI
   */
  neu = 1
  LockGUI
  setF = "SetField"
  getF = "GetField"

END

ELSE DO
  ADDRESS FIASCO
  setF = "F_SetFieldCont"
  getF = "F_GetFieldCont"
END


getF "BLZ"
BLZ = Result

getF "KontoNr"
KontoNr = Result

getF "Name"
Nam = RESULT

getF "Mark"
Mark = Result

getF "Pfennige"
Pfennige = Result

getF "Zweck1"
Zweck1 = Result

getF "Zweck2"
Zweck2 = Result

getF "Art"
Art = Result

/* ------------*/


ADDRESS "FIASCO"

F_SelectProj Ueberweisungen.fdb

F_AddRecord

IF getF = "GetField" THEN DO
  ADDRESS VALUE(fiasco_port)
  GetAttr Project Name Active ARexx
  ADDRESS VALUE RESULT
END



setF "BLZ Cont" BLZ

setF "KontoNr Cont" KontoNr

setF "Name Cont" Nam

setF "Mark Cont" Mark

setF "Pfennige Cont" Pfennige

setF "Zweck1 Cont" Zweck1

setF "Zweck2 Cont" Zweck2

setF "Art Cont" Art


ADDRESS "FIASCO"
F_SelectProj Ueberweisungen.fdb

a = SetClip("Virgin","0")

bail_out:
IF neu ~= 1 THEN EXIT

Address Value fiasco_port

UnlockGUI
ResetStatus

exit

syntax:
failure:

if show("Ports", fiasco_port) then
do
    Address Value fiasco_port

    RequestChoice '"Error ' || rc || ' in line ' || sigl || ':*n' || errortext(rc) || '" "Cancel" Title"' || scriptname || '"'
end
else
do
    say "Error" rc "in line" sigl ":" errortext(rc)
    say "Enter to continue"
    pull dummy
end

call bail_out

halt:
break_c:

if show("Ports", fiasco_port) then
do
    Address Value fiasco_port

    RequestChoice '"Script Abort Requested" "Abort Script" Title "' || scriptname || '"'
end
else
do
    say "*** Break"
    say "Enter to continue"
    pull dummy
end

call bail_out


