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!
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
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 )
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
Thanks eDave! I don't do enough coding to be elegant...