OpenVMS Source Code Demos

basic_calling_c_demo3

1000	!=================================================================================================
	! title  : basic_calling_c_demo3.bas
	! author : Neil Rieck	(https://neilrieck.net) (mailto:n.rieck@bell.net)
	! what   : passing data from BASIC to C (and back again)
	! build  : bas  basic_calling_c_demo3
	!	 : cc   basic_calling_c_demo3_part2
	!	 : link basic_calling_c_demo3,		-
	!		basic_calling_c_demo3_part2
	! history:
	! ver who when   what
	! --- --- ------ ---------------------------------------------------------------------------------
	! 100 NSR 141112 original effort
	!=================================================================================================
	option type=explicit							!
	!
	external long function basic_calling_c_demo_c8()			!
	!
	!	The following structure contains variables which are shared between BASIC + C
	!	In some applications this method is more efficient since we are not
	!		allocating/releasing storage in C
	!	Strings in a "map" or "common" do not employ a VMS-descriptor
	!
	common (abc)	long	gCmn_sanity		,				&
			long	gCmnArraySize		,				&
			long	gCmnStrLen(40)		,	! 41 (0-40) items	&
			string	gCmnString$(40) = 99	,	! 41 (0-40) strings	&
			long	gCmn_last			!
	!
	!	global variables (BASIC only)
	!
	declare long	rc				,&
		long	i%				,&
		string	junk$
	!=======================================================
	!	main
	!=======================================================
	main:
	gCmn_last	= 0					! init
	gCmnArraySize	= 40					! tell c about last array subscript
	gCmn_sanity	= loc(gCmn_last)-loc(gCmn_sanity)+4	! save the total byte-count
	print "-i-sanity:",gCmn_sanity				!
	!
	print "-i-calling function c8"				!
	rc = basic_calling_c_demo_c8
	print "-i-rc:",rc
	if (rc>0) then
	    for i% = 0 to rc-1
		print using "<0>## ";i%;
		print left$( gCmnString$(i%), gCmnStrLen(i%))
	    next i%
	end if
	!
	print "-i-exiting"
	end

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