On Jan 26, 2018, at 11:04 AM, ernie hilgers wrote:

> Hi Tim Nevels,
> 
> I was trying to make the code work on my mac 10.6 / 10.8 but somehow I am not 
> getting the snapshot on the desktop. (where I want them, for now)
> 
> I changed some of your code  (see below) but I am not sure if I understand if 
> that makes it work.
> I am not interested in a windows solution for now. 
> I have no need for a "GetCurrentScreenNumber" so I removed that.
> the Screen Coordinates is fine
> and the POSIX path name I modified (I think).
> 
> Then for quick results I put this code in a button object, so when clicked it 
> would make a screen snapshot of the active 4D window and put it on the 
> desktop. 
> Unfortunately I don't get a snapshot. 
> 
> If you have some minutes to spare, can you give me some pointers where to 
> look for the missing info to make this work. 

Hi Ernie,

I immediately saw the problem. You replaced my “GetPOSIXfilePath: method with 
the 4D command "Convert path system to POSIX”. You probably did this thinking 
“why would Tim do this, 4D already provides a command to do this. I’ll just use 
what 4D provides.” 

I wrote GetPOSIXfilePath method for the very reason that the 4D command 
"Convert path system to POSIX” does not provide a result that you can use with 
LAUNCH EXTERNAL PROCESS. Here are some examples with real file paths from my 
iMac Pro:

$fileName_t:="Screenshot "+String(Current date;ISO date;Current time)+".png"
$fileName_t:=Replace string($fileName_t;"/";"-")  // replace slashes with 
dashes in file name
$fileName_t:=Replace string($fileName_t;":";".")  // replace colons with 
periods in file name

$filePath_t:=Temporary folder+$fileName_t
$filePath_t = 
Roadrunner:private:var:folders:27:4_88976133nc2kr57yfc0v4r0000gn:T:Cleanup At 
Startup:Screenshot 2018-01-26T14.14.12.png

$myPOSIXFilePath_t:=GetPOSIXfilePath ($filePath_t)
$myPOSIXFilePath_t = 
/private/var/folders/27/4_88976133nc2kr57yfc0v4r0000gn/T/Cleanup\ At\ 
Startup/Screenshot\ 2018-01-26T14.14.12.png


$4DPOSIXFilePath_t:=Convert path system to POSIX($filePath_t)
$4DPOSIXFilePath_t = 
/private/var/folders/27/4_88976133nc2kr57yfc0v4r0000gn/T/Cleanup At 
Startup/Screenshot 2018-01-26T14.14.12.png

Notice the difference between $myPOSIXFilePath_t and $4DPOSIXFilePath_t. The 
space characters are escaped so that the macOS Terminal can handle them. Here 
is the code for GetPOSIXfilePath. 

  // ===========================================
  // PROJECT METHOD: GetPOSIXfilePath

  // PARAMETERS: $0 = POSIX file path
  // $1 = MacOS file path

  // DESCRIPTION: Converts a Mac OS X file path to a POSIX path
  // with spaces escaped.

  // CREATED BY: Tim Nevels, Innovative Solutions ©2009
  // DATE: 4/24/2009
  // LAST MODIFIED: 
  // ============================================

C_TEXT($0;$POSIXfilePath_t)
C_TEXT($1;$filePath_t)
$filePath_t:=$1

$POSIXfilePath_t:=Convert path system to POSIX($filePath_t)

  // escape spaces
$POSIXfilePath_t:=Replace string($POSIXfilePath_t;" ";"\\ ")

$0:=$POSIXfilePath_t

Tim
        
Tim Nevels 
[email protected] <mailto:[email protected]>
Innovative Solutions
785-749-3444


**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to