/*****************************************
 ** VNC C Demo				**
 ** for Lattice/S.A.S compiler		**
 ** © 1993 THOR-Software		**
 **					**
 ** to compile use			**
 **	lc -v -rr VNCDemo		**
 ** link with				**
 **	blink lib:c.o VNCDemo.o 	**
 **	 LIB LIB:vnc_stub.rr.base 	**
 **	     LIB:lcr.lib		**
 *****************************************/
 
#include "stdio.h"
#include "proto/exec.h"
#include "proto/dos.h"
#include "proto/vnc.h"

void main(int argc,char **argv)
{
struct VNCWindow *mywin;
struct List list;
struct VNCLine *thisline;

	/* first open the library */
	if (VNCBase=(struct VNCBase *)OpenLibrary("vnc.library",37L)) {
		/* now find our window */
		if (mywin=FindCNWindow(Output())) {
			/* give stub routines the main pointer */
			SetCNWindow(mywin);
			
			/* To access the window, first lock it */
			LockWindow();
			/* We now initialize a list with VNC */
			VNCNewList(&list);
			
			/* now we get a new line, enough space to hold	*/
			/* 20 bytes -> that are not 20 characters !	*/
			thisline=(struct VNCLine *)AllocLine(20);
			
			/* this line may travel thru memory, so insert	*/
			/* it into a list of your choice		*/
			
			AddHead(&list,(struct Node *)thisline);
			
			/* now its save to call VNC, for example scroll	*/
			/* the window					*/
			
			ScrollNUp(5);
			
			/* the thisline pointer may now be invalid, cause*/
			/* the memory might have moved. Restore the	*/
			/* pointer reading from the list		*/
			
			thisline=(struct VNCLine *)list.lh_Head;
			
			/* We can do what we want with this line, for	*/
			/* this example we just free it again		*/
			
			FreeLine((struct VNCMemHdr *)thisline);
			
			/* we're done with this window, we can now unlock*/
			/* it						*/
			UnLockWindow();
			
			/* Do not use this window anymore		*/
			SetCNWindow(NULL);
		}
		
		/* close the library	*/
		CloseLibrary((void *)VNCBase);
	}
}
	
