OpenVMS Source-Code Demos

MYSQL_IMPORT_HELPER_BASIC_TEMPLATE_106_PART2

	!
	! start of template 2/3
	!22222222222222222222222222222222222222222222222222222222222222222222222
	!=======================================================================
	! file   : mysql_import_helper_basic_template_106_part2.bas
	! author : Neil Rieck
	! history:
	! 100 NSR 140708 1. original effort
	! 106 NSR 170314 1. adding true unicode support
	!     NSR 170316 2. more work
	!=======================================================================
	!
	!	rms info (populated by FSP$)
	!
	map(ri)	string	ri_whole	= 16	,	!				&
		string	ri_align	= 0		! enforce layout check
	map(ri)	byte	ri_org		,		! 1=  1				&
		byte	ri_rat		,		!+1=  2				&
		word	ri_mrs		,		!+2=  4				&
		long	ri_alq		,		!+4=  8				&
		word	ri_bks_bls	,		!+2= 10				&
		word	ri_num_keys	,		!+2= 12				&
		long	ri_mrn		,		!+4= 16				&
		string	ri_align	= 0		! must align with previous decl
	!=======================================================================
	!	main
	!=======================================================================
	main:
	when error in							!
	    !
	    !	make sure INPUT is different from OUTPUT
	    !
	    if edit$(fs_i$,32+2) = edit$(fs_o$,32+2) then		!
		print "-e-oops, someone has made a typo (sanity test-1)"!
		cause error 50						!
	    end if							!
	    !
	    !	make sure we are outputing to a file with a CSV extension
	    !
	    if pos( edit$(fs_o$,32+2), ".CSV",1)=0 then			!
		print "-e-oops, someone has made a typo (sanity test-2)"!
		cause error 50						!
	    end if							!
	    !
	    print "-i-opening: "+ fs_i$					!
	    open fs_i$ for input as #100				&
		,access read, allow modify				&
		,recordtype any, organization undefined			!
	    ri_whole = fsp$(100)					! snoop
	    close #100							!
	    !
	    map(xfer) string xfer$ = 4096				!
	    if ri_mrs > 4096 then					!
		print "-e-oops, map(xfer) is too small. Aborting"	!
		cause error 50						!
	    end if							!
	    !
	    open fs_i$ for input as #100				&
		,access read						&
		,allow modify						&
		,recordtype any						&
		,organization undefined					&
		,map xfer						&
		,recordsize ri_mrs					!
	    !
	    open fs_o$ for output as #99				&
		,organization sequential				&
		,recordsize 32767					!
	    !
	    print "-i-start:  "+ date4$(0) +" "+ time$(0)		!
	    while 1							!
		get #100, regardless					!
		count_i% = count_i% + 1					!
		print "-i-records: "+str$(count_i%) if mod(count_i%,10000)=0
	!	print left$(xfer$,ri_mrs)				x debug maximum rec siz
	!22222222222222222222222222222222222222222222222222222222222222222222222
	! end of template 2/3
	!