system "Reversed_D'Alembert_System"

{Reversed D'Alembert System
is one of the oldest money management plans there are, for "even chances"
betting, all having in common that you add and subtract a fixed
amount to your bet, after a loss or win.

Same as D'Alembert except you Up as you Win and Subtract as you Loss.
}
method "main"
begin
    While Starting a New Session
    begin
        Clear All Records;
        Clear Record "Initial Bet" data;
        Clear Record "Current Layout to Bet" data;
        Put 5  on Record "Initial Bet" data;
        Call "Setup Layout";
        call "Make Bets";
        Exit;
    end


    While Record "Current Layout to Bet" layout has lost each time
    begin
        Subtract 1 on Record "Initial Bet" data;
    end
    
    While Record "Current Layout to Bet" layout has won each time
    begin
        Add 1 on Record "Initial Bet" data;
    end
    
    While Record "Initial Bet" data = 0
    begin
        Put 5 on Record "Initial Bet" data;
    end
    
    Call "Make Bets";
end

method "Make Bets"
begin
    Put 100 % of Record "Initial Bet" data on Record "Current Layout to Bet" layout;
end

method "Setup Layout"
begin
    Input Dropdown "Make a Layout Selection

              1:=Even
              2:=Odd
              3:=Red
              4:=Black
              5:=High (19-36)
              6:=Low (0-18)" to Record "Layout Selection" data;

    If Record "Layout Selection" data = 1
    begin
        Copy Even to the Record "Current Layout to Bet" layout;
    end
    Else
    begin
        If Record "Layout Selection" data = 2
        begin
            Copy Odd to the Record "Current Layout to Bet" layout;
        end
        Else
        begin
            If Record "Layout Selection" data = 3
            begin
                Copy Red to the Record "Current Layout to Bet" layout;
            end
            Else
            begin
                If Record "Layout Selection" data = 4
                begin
                    Copy Black to the Record "Current Layout to Bet" layout;
                end
                Else
                begin
                    If Record "Layout Selection" data = 5
                    begin
                        Copy High to the Record "Current Layout to Bet" layout;
                    end
                    Else
                    begin
                        If Record "Layout Selection" data = 6
                        begin
                            Copy Low to the Record "Current Layout to Bet" layout;
                        end
                    end
                end
            end
        end
    end
end
