A89: Re: VAR-LINK


[Prev][Next][Index][Thread]

A89: Re: VAR-LINK




Hi!

> Does anyone know how to bring up the VAR-LINK dialog from C code
> and then get the name of the file that was selected?

AMS 2.03 has such function, but AMS 1.xx has not. So, I will give
to you AMS-independent solution. Bringing up the VAR-LINK dialog 
is quite easy:

EVENT ev;
ev.Type=CM_KEYPRESS;
ev.extra.Key.Code=4141;         // code of VAR-LNK keypress
EV_defaultHandler(&ev);

but getting the name of the file that was selected is a bit harder.
After executing of VAR-LINK dialog, VAR-LINK applet will send the
name of the selected file to the current application via CM_HSTRING
message. This message may be captured by an user event handler.
Here is the demonstration program:

#include <nostub.h>
#include <all.h>

int _ti89;

char VarBuffer[20]="";

void VarLinkHandler(EVENT *ev)
{
  if(ev->Type=CM_HSTRING)
    strcpy(VarBuffer,HeapDeref(ev->extra.hPasteText));
  EV_defaultHandler(ev);
}

void VarLinkDialog(void)
{
  EVENT ev;  
  EVENT_HANDLER OldHandler=EV_captureEvents(VarLinkHandler);
  ev.Type=CM_KEYPRESS;
  ev.extra.Key.Code=4141;         // code of VAR-LNK keypress  
  EV_defaultHandler(&ev);
  EV_captureEvents(OldHandler);
}

void _main(void)
{
  VarLinkDialog();
  printf_xy(0,50,"You picked: %s",VarBuffer);
  ngetchx();
}

I hope that this helps. Read more about events.h header file:
incredible miracles may be produced using event passing technics!

Cheers,

Zeljko Juric



Follow-Ups: