package com.goldencode.dataset;

import com.goldencode.p2j.util.*;
import com.goldencode.dataset.ui.*;
import com.goldencode.p2j.ui.*;
import com.goldencode.p2j.persist.*;
import com.goldencode.dataset.dmo.fwd.*;
import com.goldencode.p2j.persist.lock.*;

import static com.goldencode.p2j.util.BlockManager.*;
import static com.goldencode.p2j.util.InternalEntry.Type;
import static com.goldencode.p2j.ui.LogicalTerminal.*;

/**
 * Business logic (converted to Java from the 4GL source code
 * in start.p).
 */
@DatabaseReferences(aliases = 
{
   "fwd"
}, tables = 
{
   "fwd.t1"
})
public class Start
{
   public static final String FMT_STR_1 = "->,>>>,>>9";

   T1.Buf t1Buff = RecordBuffer.define(T1.Buf.class, "fwd", "t1Buff", "t1_buff");

   T1.Buf t1 = RecordBuffer.define(T1.Buf.class, "fwd", "t1", "t1");

   StartInvacc invaccFrame = GenericFrame.createFrame(StartInvacc.class, "invacc");

   @LegacySignature(type = Type.VARIABLE, name = "copy_f1")
   integer copyF1 = TypeFactory.integer((long) 0);

   /**
    * External procedure (converted to Java from the 4GL source code
    * in start.p).
    */
   @LegacySignature(type = Type.MAIN, name = "start.p")
   public void execute()
   {
      externalProcedure(Start.this, new Block((Body) () -> 
      {
         invaccFrame.openScope();
         RecordBuffer.openScope(t1);
         new FindQuery(t1, (String) null, null, "t1.recid asc", LockType.NONE).unique();
         copyF1.assign(t1.getF1());
         message(copyF1);
      }));
   }
}
