Guidance
指路人
g.yi.org
Upload / Forum Attachment / Reginald Rexx Programming Language Compiler User Forum Attachments and Pictures / 12578-GENERATE_DB2_SOURCE_MENU.REX

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
/*

	Can be called from any window that will use ODBC to access any database.
	This program will perform the following steps:-

	1		Attempt to read a file called ODBC_connect_strings.txt
	2		Assuming this is found, it will extract the potential
			database names from this file and add these as menu options
			(as the first menu heading) to the curent window	
	3		....


	Arguments:-



	Results:-

	RC = -1 if ODBC_connect_strings.txt couldn't be found
			 otherwise, it will be the menu ITEM number for the 
			 last item added







*/

USE ARG databases., guiwindow

PARSE SOURCE . . script_name
full_path = FILESPEC('D', script_name) || FILESPEC('P', script_name)
/* Look in the CURRENT directory (ie, where the current exe is being run from) */
filein = full_path"ODBC_connect_strings.txt"

rc = STATE(filein)
IF rc <> 0 THEN
	RETURN -1					/* Not there */

STREAM(filein, 'C', 'OPEN READ')
LOADTEXT('DB.', filein)
STREAM(filein, 'C', 'CLOSE')

sw_heading = 0  /* Have we added the heading - default is no */
menu_item = 1
databases.0 = 0 

DO i = 1 TO db.0
	db.i = STRIP(db.i)
	SELECT
		WHEN LEFT(db.i,1) = '*' THEN
			NOP						/* Comment */
		WHEN db.i == '' THEN
			NOP						/* Nothig there */			
		OTHERWISE
			DO
				databases.0 = databases.0 + 1
				databases.[databases.0] = db.i
				PARSE VAR db.i . '=' next_db':' .
				IF sw_heading = 0 THEN
					DO
						err = guiaddmenu('DB2 Source', 'HEADING', 1)
						sw_heading = 1		/* Set switch */
					END
				err = guiaddmenu(next_db, 'ITEM', 1 menu_item)		
				menu_item = menu_item + 1
			END
	END			
END

menu_item = menu_item - 1
RETURN menu_item
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-10-12  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2008-12-19 17:54:08