OpenVMS Source Code Demos

basic_calling_c_demo2

1000	!=================================================================================================
	! title  : basic_calling_c_demo2.bas
	! author : Neil Rieck	(https://neilrieck.net) (mailto:n.rieck@bell.net)
	! what   : passing an array of strings from BASIC to C
	! build  : bas	basic_calling_c_demo2
	!	 : cc	basic_calling_c_demo2_part2
	!	 : link	basic_calling_c_demo2,		-
	!		basic_calling_c_demo2_part2
	! history:
	! ver who when   what
	! --- --- ------ ---------------------------------------------------------------------------------
	! 100 NSR 141110 original effort
	!=================================================================================================
	option type=explicit							!
	!
	external long function basic_calling_c_demo_c5(	long by ref,		&
							string dim() by ref	)
	!
	external long function basic_calling_c_demo_c6(	string by desc,		&
							string by desc,		&
							long by ref,		&
							string dim() by ref,	&
							long dim() by ref	)
	!
	external long function basic_calling_c_demo_c7(	string by desc,		&
							string by desc,		&
							long by ref,		&
							string dim() by ref	)
	declare	long	junk%			,&
		long	array_size%		,&
		long	responses%		,&
		string	fqdn$			,&
		string	query$
	!
	array_size%	= 20					! prep for run-time allocation
	dim string resp$(array_size%)				!
	dim long   resp%(array_size%)				!
	!
	!=======================================================
	!	main
	!=======================================================
	main:
	!
	!	prep for test #5
	!
	resp$(0) = "a"
	resp$(1) = "bc"
	resp$(2) = "def"
	resp$(3) = "ghij"
	resp$(4) = "klmno"
	resp$(5) = "pqrstu"
	resp$(6) = "vwxwz01"
	resp$(7) = "23456789"
	resp$(8) = ""						! a blank string
	!
	print "-i-calling function c5"				!
	responses%	= basic_calling_c_demo_c5(		!		&
				9			,	! 9 items (0-8)	&
				resp$()			)	!
	print "-i- back in main"				!
	!
	!	prep for test #6
	!
	for junk% = 0 to array_size%				!
	    resp$(junk%) = space$(10)				! pre-extend these strings
	next junk%						!
	mat resp% 	= zer					! zap array
	resp%(0)	= 0					! don't forget subscript 0
	fqdn$     	= "google.com"				!
	query$    	= "mx"					!
	print "-i-calling function c6"				!
	responses%	= basic_calling_c_demo_c6(		!&
				fqdn$			,	!&
				query$			,	!&
				array_size%		,	!&
				resp$()			,	!&
				resp%()			)	!
	print "-i- back in main"				!
	for junk% = 0 to 9					!
	    print "-i-junk ",junk%;				!
	    print " -i-data ";left$(resp$(junk%),resp%(junk%))	!
	next junk%						!
	!
	!	prep for test #7
	!
	mat resp$ 	= nul$					! zap array
	resp$(0)	= ""					! don't forget subscript 0
	fqdn$     	= "google.com"				!
	query$    	= "mx"					!
	print "-i-calling function c7"				!
	responses%	= basic_calling_c_demo_c7(		!&
				fqdn$			,	!&
				query$			,	!&
				array_size%		,	!&
				resp$()			)	!
	print "-i- back in main"				!
	for junk% = 0 to 9
		print "-i-junk ",junk%
		print "-i-data ";
		print resp$(junk%)
	next junk%
	!
	print "-i-exiting"
	end

home Back to Home
Neil Rieck
Waterloo, Ontario, Canada.