PROCEDURE EXPOSE guiwindow odbc_system. odbc_source. odbc_connection. db2.
PARSE ARG option, menu_position .
SELECT
WHEN option = "I" THEN
rc = init_db2_menus()
WHEN option = "C" THEN
rc = change_db2_menu()
OTHERWISE
NOP
END
RETURN 0
change_db2_menu:
IF db2.previous_database <> "" THEN
rc = free_previous_database(db2.previous_database)
default_position = menu_position
IF DATATYPE(menu_position) = "CHAR" THEN
DO
default_position = 1
DO i = 1 TO odbc_system.0
temp = STRIP(TRANSLATE(odbc_system.i," " ,"&"))
y = POS(" ", temp)
IF y <> 0 THEN
temp = LEFT(temp,y-1)||substr(temp,y+1)
IF temp == menu_position THEN
DO
default_position = i
LEAVE
END
END
END
menu_position = default_position
DO i = 1 TO odbc_system.0
guisetmenuopts("ODBC_source."i, '')
END
guisetmenuopts("ODBC_source."menu_position, 'MARK')
guigetmenuopts("ODBC_source."menu_position, , 'selected_database')
selected_database = STRIP(TRANSLATE(selected_database," " ,"&"))
y = POS(" ", selected_database)
IF y <> 0 THEN
selected_database = LEFT(selected_database,y-1)||substr(selected_database,y+1)
status_bar = 'Default DB2 system is 'selected_database
db2.source = selected_database
guisetctlvalue('status_bar', 1)
db2.previous_database = selected_database
RETURN 0
init_db2_menus:
filename = "ODBC_defaults.txt"
DO
STREAM(filename, 'C', 'OPEN READ')
LOADTEXT('sourcecode.', filename,'BLT')
STREAM(filename, 'C', 'CLOSE')
CATCH SYNTAX
err = STREAM(filename, "D")
rc = wdwsay.rex(err, "|STOP")
RETURN 1
END
odbc_system.0 = 0
odbc_connection.0 = 0
user = USERID()
user = TRANSLATE(user)
DO i = 1 TO sourcecode.0
SELECT
WHEN "*" = LEFT(sourcecode.i,1) THEN
NOP
OTHERWISE
DO
odbc_system.0 = odbc_system.0 + 1
odbc_connection.0 = odbc_connection.0 + 1
PARSE VAR sourcecode.i db2 "§" connection_string
connection_string = TRANSLATE(connection_string)
IF POS("&USER", connection_string) <> 0 THEN
connection_string = CHANGESTR("&USER", connection_string, user)
y = POS(" |