Home > Community > Forums > PCB SKILL > PCB Skill variable saved to Windows clipboard

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 PCB Skill variable saved to Windows clipboard 

Last post Mon, Nov 26 2012 2:33 PM by labGeoff. 4 replies.
Started by labGeoff 31 Oct 2012 05:43 PM. Topic has 4 replies and 1175 views
Page 1 of 1 (5 items)
Sort Posts:
  • Wed, Oct 31 2012 5:43 PM

    • labGeoff
    • Not Ranked
    • Joined on Thu, Oct 16 2008
    • Posts 2
    • Points 25
    PCB Skill variable saved to Windows clipboard Reply

    I am currently running Allegro on a windows 7 machine.  Does anyone know of a way to save a skill variable to the windows clipboard?  thanks!

    • Post Points: 20
  • Mon, Nov 26 2012 10:03 AM

    • Brian Collins
    • Not Ranked
    • Joined on Fri, Jan 28 2011
    • Calgary, Alberta
    • Posts 7
    • Points 95
    Re: PCB Skill variable saved to Windows clipboard Reply

     First you will need a Windows program that takes a string and puts it into the Windows clipboard. You could write one yourself or use an existing one such as: clip.exe that comes with Windows Server 2003or nircmd.exe.

    I chose the clip.exe method. I downloaded clip.exe and put it in the C:\windows directory, but anywhere in the path would probably work. Attached is a skill file that does what you require. The checking is not very good, but perhaps one of the skill gurus on this forum can fix that up. I have tried this on Windows XP SP3, but not on Win 7.

     /* envvar2clp.il - writes an environment variable to the Windows clipboard
       Written by: Brian Collins 2012 11 23
       You need to download the "clip.exe" file from Win Server 2K3 and put it in C:\windows
    */

    axlCmdRegister( "envvar2clp" 'envvar2clp )

    defun( envvar2clp ( var_Name )

    var_Text = axlGetVariable( var_Name )
    if(var_Text == nil then
       sprintf(err_Msg "%s env var does not exist!" var_Name)
       axlUIConfirm(err_Msg)
    else
       sprintf( var_FileName "tmp_%s.txt" var_Name)
       var_Port = axlDMOpenFile( "temp" var_FileName "w" )
       fprintf( var_Port "%s\n" var_Text )
       axlDMClose(var_Port)

       sys_CallString=strcat("clip " "< " var_FileName) ;<- This assumes that you have the "clip.exe" file in the path.
       result_SystemCall=system(sys_CallString)

       deleteFile(var_FileName)
       ) ;end if

    ) ; end defun envvar2clp

    • Post Points: 20
  • Mon, Nov 26 2012 12:49 PM

    • eDave
    • Top 10 Contributor
    • Joined on Sun, Jul 13 2008
    • Christchurch, 00-NZ
    • Posts 744
    • Points 16,115
    Re: PCB Skill variable saved to Windows clipboard Reply

    That's a great find!

    In Windows 7 clip.exe is already there so no download is needed.

    You can try this slightly simpler code:

    defun( envvar2clp ( var_Name )

    if(axlGetVariable(var_Name)

    then system(sprintf(nil, "echo %%%s%% | clip", var_Name))

    else axlUIConfirm(sprintf(nil "%s env var does not exist!", var_Name))

    ) ;end if

    ) ; end defun envvar2clp

    Dave Elder, Tait Communications
    • Post Points: 20
  • Mon, Nov 26 2012 1:52 PM

    • Brian Collins
    • Not Ranked
    • Joined on Fri, Jan 28 2011
    • Calgary, Alberta
    • Posts 7
    • Points 95
    Re: PCB Skill variable saved to Windows clipboard Reply

     Thanks eDave! I don't do enough coding to be elegant...

     Brian

    • Post Points: 5
  • Mon, Nov 26 2012 2:33 PM

    • labGeoff
    • Not Ranked
    • Joined on Thu, Oct 16 2008
    • Posts 2
    • Points 25
    RE: PCB Skill variable saved to Windows clipboard Reply
    Thanks all!  Works great!

    Geoff Roth
    • Post Points: 5
Page 1 of 1 (5 items)
Sort Posts:
Started by labGeoff at 31 Oct 2012 05:43 PM. Topic has 4 replies.