EmpTasks Frame
The EmpTasks Frame shown in the following figure demonstrates how you can use 4GL to retrieve, manipulate,
and update data in the database.
The initial menu operation, GetEmployee, queries the database based on values entered into fields by the user and displays a submenu of operations to manipulate the retrieved data.
This is the 4GL source code file for the frame:
/*
* Emptasks.osq
*
* View and Update Employee information and
* Tasks assignments.
*
*/
initialize (resp = c3, curr_field = c32, fnkey=i4)=
begin
mode query;
today = date('now');
callproc timer_on(secs=15);
end
GetEmployee, key frskey4 =
Begin
emptasks = select name, title, manager, hourly_rate
from emp
where qualification(name=name,title=title,
manager=manager, hourly_rate=hourly_rate)
tasktable = select distinct *
from tasks
where name=:name
order by task
begin
initialize =
begin
callproc sum_hours(hourly_rate);
redisplay;
end
field hourly_rate, field tasktable.hours =
begin
callproc sum_hours(hourly_rate);
redisplay;
resume next;
end
'Next', key frskey4 =
begin
message 'Retrieving next Employee.';
next;
callproc sum_hours(hourly_rate);
redisplay;
end
DeleteEmp =
Begin
resp = prompt 'Type "y" to delete '+name+'.'
with style=popup;
if lowercase(left(resp,1)) = 'y' then
callproc del_emp(empname = name);
next;
else
message 'Employee not deleted.';
sleep 2;
endif;
redisplay;
end
RemoveTask =
Begin
inquire_forms field emptasks
(curr_field = name);
if curr_field = 'tasktable' then
callproc rem_task(person = name,
proj = tasktable.project,
job = tasktable.task);
deleterow tasktable;
callproc sum_hours(hourly_rate);
else
message 'Place cursor on task'
+ ' to be deleted'
with style=popup;
endif;
end
UpdateEmp =
Begin
message 'Updating ' + name + ' . . . ';
update emp e set
name = :name,
title = :title,
manager = :manager,
hourly_rate = :hourly_rate
where :name =
any (select name from tasks t
where t.name = e.name);
unloadtable tasktable
begin
update tasks set hours =
:tasktable.hours
where :tasktable.task = task and
:name = name and
:tasktable.project = project;
end;
commit;
end
'Help', key frskey1 =
begin
help_forms (subject = 'EmpTasks Frame',
file = 'USER:[JOE.ABFDEMO]EMPTASKS.HLP');
end
'4GL', key frskey16 =
begin
callproc timer_off();
helpfile 'EmpTasks Frame'
'USER:[JOE.ABFDEMO]EMPTASKS.OSQ';
callproc timer_on(secs=15);
end
'Quit', key frskey3 =
begin
endloop;
end
on timeout =
begin
today = date('now');
end
end;
clear field all;
set_forms field " (blink(tot_hours)=0); /* turn off
blinking */
today = date('now');
redisplay;
end
field 'title', field 'manager' =
begin
if lowercase(title) = 'help' or lowercase(manager) =
'help' then
inquire_forms field "
(curr_field=name);
if curr_field = 'title' then
title = callframe list
(list.info = 'Titles';
list.vals = select distinct val = title
from titles order by val);
else
manager = callframe list
(list.info = 'Managers';
list.vals = select distinct val = manager
from managers order by val);
endif;
endif;
resume next;
end
key frskey2 =
begin
inquire_forms field "
(curr_field=name);
if curr_field = 'title' then
title = callframe list
(list.info = 'Titles';
list.vals = select distinct val = title
from titles order by val);
else
manager = callframe list
(list.info = 'Managers';
list.vals = select distinct val = manager
from managers order by val);
endif;
resume next;
end
'4GL', key frskey16 =
begin
callproc timer_off();
helpfile 'EmpTasks Frame 4GL'
'USER:[JOE.ABFDEMO]EMPTASKS.OSQ';
callproc timer_on(secs=15);
end
'Help', key frskey1 =
begin
help_forms(subject = 'Employee Task Assignments Frame',
file = 'USER:[JOE.ABFDEMO]EMPTASKS.HLP');
end
'Quit', key frskey3 =
begin
callproc timer_on(secs=2);
return;
end
on timeout =
begin
today = date('now');
end
Last modified date: 08/14/2024