Browsing Form 2

This code displays how we can create a form that takes data from an in-memory table.

 

This example code is taken from form "Procedure History" (AU_PROOD.FM). The procedures Form_Resize, Form_Start, Panels_Start are standard procedures for AutoPilot code into a form.

 

lib

 

proc Panels_Start()

 

  f = TopForm()

 

  t = TCreateClientStart(f)

  call TAddFld(t,"COL1",9)

  call TAddFld(t,"COL2",1,20)

  call TAddFld(t,"COL3",1,100)

  call TAddFld(t,"COL4",1,100)

  call TAddFld(t,"COL5",1,100)

  call TAddFld(t,"COL6",1,100)

  call TAddFld(t,"COL7",1,100)

  call TCreateClientEnd(t)

 

  start_sql "DAT" "KOSMOS"

      SELECT AU_PROCESS.AU_PROCESS, AU_PROCESS.PARENT_AGENT_ID, AU_PROCESS.AGENT_ID, AU_PROCESS.AGENT_NAME,

      AU_STEP.STEP_DESCR, AU_STEP.FINISHED, AU_STEP.FINISHED_AT_DATE, AU_STEP.FINISHED_AT_TIME, AU_STEP.COMM,

      AU_STEP.UNAME, AU_STEP.RNAME

      FROM AU_PROCESS INNER JOIN AU_STEP ON AU_PROCESS.AU_PROCESS = AU_STEP.AU_PROCESS

      WHERE (((AU_PROCESS.PARENT_AGENT_ID)= :id))

      ORDER BY AU_STEP.FINISHED DESC , AU_STEP.FINISHED_AT_DATE, AU_STEP.FINISHED_AT_TIME

  end_sql

 

  id_a = getfprevfield("PARENT_AGENT_ID")

 

  call RunEmbSQL ("DAT" , id_a )

 

  q  = QueryByName("DAT")

  rcount = TRecordCount(q)

 

  dat0 = ""

 

  call TFirst(q)

  for i = 1 to rcount

 

      if (dat0 <> DAT.FINISHED_AT_DATE) then

 

           call TAppend(t)

           call TSetFld(t,"COL1",DAT.FINISHED_AT_DATE)

           call TSetFld(t,"COL2","")

           call TSetFld(t,"COL3","")

           call TSetFld(t,"COL4","")

           call TSetFld(t,"COL5","")

           call TSetFld(t,"COL6","")

           call TSetFld(t,"COL7","")

           call TPost(t)

 

           dat0 = TGetFld(q,"FINISHED_AT_DATE")

 

      endif

 

      tim = TimeToNum(DAT.FINISHED_AT_TIME)

      call TAppend(t)

      call TSetFld(t,"COL1","")

      call TSetFld(t,"COL2",DAT.FINISHED_AT_TIME)

      call TSetFld(t,"COL3",DAT.STEP_DESCR)

      call TSetFld(t,"COL4",DAT.COMM)

      call TSetFld(t,"COL5",DAT.UNAME)

      call TSetFld(t,"COL6",DAT.RNAME)

      call TSetFld(t,"COL7",DAT.FINISHED)

      call TPost(t)

 

      call TNext(q)

  next

 

  call TSetName(t,"DATA")  

 

  call FreeEmbSQL("DAT")

 

end

 

proc Form_Start()

 

  call DisableLocators()

 

  call SetFixedCols(1)

 

  perigr = getfprevfield("AGENT_NAME")

  capt = strcat("Procedure: ",perigr)

  call SetCaption(capt)

 

end

 

proc Form_Resize()

 

  call SetFixedCols(1)

 

end