Progress Browser. Arama.
&IF "{&Browse-ad}" EQ "" &THEN
MESSAGE "Browse ismi Gelmedi"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
&ENDIF
&if "{&Browse-ad}" NE "" &THEN
DO:
IF {&browse-ad}:READ-ONLY NE TRUE THEN {&browse-ad}:READ-ONLY = TRUE.
dyn-browse = {&Browse-ad}:HANDLE .
dyn-query = dyn-browse:QUERY.
col-handle = dyn-browse:CURRENT-COLUMN.
{&browse-ad}:SEPARATOR-FGCOLOR = 5.
{&browse-ad}:TITLE = dyn-browse:TABLE.
{&browse-ad}:COLUMN-RESIZABLE = TRUE.
ON START-SEARCH OF {&Browse-ad} DO:
bhdl = {&browse-ad}:CURRENT-COLUMN.
OLD_lab = bhdl:LABEL .
bhdl:LABEL = "".
bhdl:BGCOLOR = 8.
IF bhdl:DATA-TYPE BEGINS "date" THEN
MESSAGE "Lütfen Tarih Formatini 25/03/2001 benzeri şeklinde giriniz.."
VIEW-AS ALERT-BOX INFO BUTTONS OK.
bhdl:LABEL-BGCOLOR=12.
bhdl:LABEL-FGCOLOR=15.
END. /********** start-search *******************/
ON ANY-PRINTABLE OF {&Browse-ad} DO:
IF bhdl:LABEL EQ OLD_lab THEN bhdl:LABEL = "".
bhdl:LABEL = bhdl:LABEL + KEYLABEL(LASTKEY).
IF bhdl:DATA-TYPE BEGINS "char" THEN
query-value = "For each " + bhdl:TABLE + " where " + bhdl:TABLE + "." + bhdl:name + " begins " + '"' + bhdl:LABEL + '"' .
IF bhdl:DATA-TYPE BEGINS "int" THEN
query-value = "For each " + bhdl:TABLE + " where " + bhdl:TABLE + "." + bhdl:name + " eq " + bhdl:LABEL .
IF bhdl:DATA-TYPE BEGINS "dec" THEN
query-value = "For each " + bhdl:TABLE + " where " + bhdl:TABLE + "." + bhdl:name + " eq " + bhdl:LABEL .
IF bhdl:DATA-TYPE BEGINS "date" THEN
IF LENGTH(bhdl:LABEL) EQ 10 THEN DO:
dt = DATE(bhdl:LABEL).
query-value = "For each " + bhdl:TABLE + " where " + bhdl:TABLE + "." + bhdl:name + " eq " + bhdl:LABEL .
dyn-query:query-prepare(query-value).
dyn-query:query-open().
END.
IF bhdl:DATA-TYPE BEGINS "log" THEN DO:
DEFINE VARIABLE tmp AS CHARACTER NO-UNDO.
FIND FIRST _field WHERE _field._field-name EQ bhdl:NAME NO-LOCK NO-ERROR.
IF AVAIL _field AND KEYLABEL(LASTKEY) EQ SUBSTRING(_field._format,1,1) THEN DO:
/* bhdl:LABEL = RIGHT-TRIM(_field._format, (LENGTH(_field._initial) + 1 )). */
query-value = "For each " + bhdl:TABLE + " where " + bhdl:TABLE + "." + bhdl:name + " eq " + " TRUE " .
END.
ELSE DO:
query-value = "For each " + bhdl:TABLE + " where " + bhdl:TABLE + "." + bhdl:name + " eq " + " False" .
bhdl:LABEL = SUBSTRING (_field._format , LENGTH(_field._initial) + 2 , LENGTH(_field._format)).
END.
END.
IF bhdl:DATA-TYPE NE "Date" THEN DO:
dyn-query:query-prepare(query-value).
dyn-query:query-open().
END.
END. /*********************** any-printable *******************/
ON "Backspace" OF {&Browse-ad} DO:
bhdl:LABEL = SUBSTRING(bhdl:LABEL,1,LENGTH(bhdl:LABEL) - 1).
IF bhdl:LABEL EQ "" THEN DO:
query-value = "For each " + bhdl:TABLE .
dyn-query:query-prepare(query-value).
dyn-query:query-open().
RETURN.
END.
IF bhdl:DATA-TYPE BEGINS "ch" THEN
query-value = "For each " + bhdl:TABLE + " where " + bhdl:TABLE + "." + bhdl:name + " begins " + '"' + bhdl:LABEL + '"' .
IF bhdl:DATA-TYPE BEGINS "int" THEN
query-value = "For each " + bhdl:TABLE + " where " + bhdl:TABLE + "." + bhdl:name + " eq " + bhdl:LABEL .
IF bhdl:DATA-TYPE BEGINS "dec" THEN
query-value = "For each " + bhdl:TABLE + " where " + bhdl:TABLE + "." + bhdl:name + " eq " + bhdl:LABEL .
IF bhdl:DATA-TYPE BEGINS "log" THEN DO:
bhdl:LABEL = old_lab.
query-value = "For each " + bhdl:TABLE + " where " + bhdl:TABLE + "." + bhdl:name + " eq " + " TRUE " .
END.
/* dyn-query:query-prepare(query-value). */
/* dyn-query:query-open(). */
END.
ON END-SEARCH OF {&browse-ad} DO:
bhdl:LABEL = OLD_lab.
bhdl:LABEL-BGCOLOR= ?.
bhdl:LABEL-FGCOLOR= ?.
END.
ON "Delete" OF {&browse-ad} DO:
bhdl:LABEL = OLD_lab.
query-value = "For each " + bhdl:TABLE .
dyn-query:query-prepare(query-value).
dyn-query:query-open().
RETURN.
END.
/***** ---------- Report ---------- ************/
ON "CTRL-1" OF {&Browse-ad} DO:
DEFINE VARIABLE str AS CHARACTER NO-UNDO INIT "W".
DEFINE VARIABLE dosya AS CHAR FORMAT "X(50)" .
MESSAGE "Excel?/WordPad?:" UPDATE str.
IF str EQ "W" THEN DO:
OUTPUT TO "c:\ercan.txt".
GET FIRST {&Browse-ad} NO-LOCK.
DO WHILE AVAIL({&TABLES-IN-QUERY-{&BROWSE-ad}}):
PUT {&Fields-IN-QUERY-{&BROWSE-ad}} SKIP.
GET NEXT {&Browse-ad} NO-LOCK.
END.
OUTPUT TO CLOSE.
dosya = "c:\windows\wordpad.exe c:\ercan.txt".
DOS SILENT VALUE(dosya) .
END.
/* Excel transferi için */
IF str EQ "E" THEN DO:
DEFINE VARIABLE chExcel AS COM-HANDLE.
DEFINE VARIABLE chWorkbook AS COM-HANDLE.
DEFINE VARIABLE chWorksheet AS COM-HANDLE.
DEFINE VARIABLE itema AS CHARACTER NO-UNDO.
DEFINE VARIABLE itemb AS CHARACTER NO-UNDO.
DEFINE VARIABLE itemc AS CHARACTER NO-UNDO.
DEF VAR rowi AS INT INIT 1.
DEFINE VARIABLE ch AS CHARACTER EXTENT 3 NO-UNDO.
CREATE "Excel.Application" chExcel.
chExcel:Visible = TRUE.
chWorkbook = chExcel:Workbooks:ADD().
chWorkSheet = chExcel:Sheets:Item(1).
lg = dyn-browse:SELECT-ROW(1).
/* DO WHILE AVAIL({&TABLES-IN-QUERY-{&BROWSE-ad}}):*/
REPEAT WHILE TRUE:
lg = dyn-browse:SELECT-FOCUSED-ROW().
col-handle = dyn-browse:CURRENT-COLUMN.
chWorkSheet:Range("A" + string(rowi)):Value = col-handle:SCREEN-VALUE.
lg = dyn-browse:select-next-row() NO-ERROR.
IF NOT lg THEN LEAVE.
lg = dyn-browse:SELECT-FOCUSED-ROW().
lg = dyn-browse:REFRESH() NO-ERROR.
rowi = rowi + 1.
END.
RELEASE OBJECT chExcel.
RELEASE OBJECT chWorkbook.
RELEASE OBJECT chWorksheet.
END.
END.
/*********------ End of Report ------ *********/
&IF "{&Kayit-Ekle}" EQ "Acik" &THEN
ON ROW-LEAVE OF {&Browse-ad} DO:
/* MESSAGE "{&TABLES-IN-QUERY-{&BROWSE-ad}}"
VIEW-AS ALERT-BOX INFO BUTTONS OK.*/
CREATE {&TABLES-IN-QUERY-{&BROWSE-NAME}} .
/*MESSAGE "{&FIELDS-IN-QUERY-{&BROWSE-ad}}"
VIEW-AS ALERT-BOX INFO BUTTONS OK.*/
ASSIGN BROWSE {&Browse-ad} {&FIELDS-IN-QUERY-{&BROWSE-ad}}.
dyn-browse:CREATE-RESULT-LIST-ENTRY().
END.
&ENDIF
END.
&endif