2018年1月19日金曜日

PowerShell から FileMaker ODBC 経由で編集 。|FileMaker ODBC|UPDATE|PowerShell

FileMaker xDBC クライアントドライバ が必要。

[void][System.Reflection.Assembly]::LoadWithPartialName("System.Data")
$connectionString = 'driver={FileMaker ODBC};server=localhost;database={FileMaker_FileName};uid=admin;pwd=;';
#$connectionString = "driver={FileMaker ODBC};HST=localhost;PRT=2399;SDSN=Post_CURL;uid=admin;pwd=;"
$cmd = "UPDATE `"{TableName}`" SET `"{FieldName}`" ='こんにちわ' WHERE `"key`"='1'"
$odbc_con = New-Object System.Data.Odbc.OdbcConnection($connectionString)
$odbc_con.Open()
$odbc_cmd = New-Object System.Data.Odbc.OdbcCommand
$odbc_cmd.Connection = $odbc_con
$odbc_cmd.CommandText = $cmd
$odbcReader = $odbc_cmd.ExecuteNonQuery()
$odbcReader;
$odbc_cmd.Dispose()
$odbcReader.Dispose()
$odbc_con.Close()
$odbc_con.Dispose()



2018年1月18日木曜日

FileMaker 外部アプリケーションを実行し戻り値を取得。

FileMaker から外部アプリケーションを実行し戻り値を取得。
戻り値が文字化けする場合に有効。

OS:Windows
plugin:ScriptMakerPS
https://sites.google.com/site/scriptmakerps/

例:
Node.js を実行
フィールド:Script

$Arguments = "-e `"console.log('Hello, こんにちは?');`"";
$pinfo = New-Object System.Diagnostics.ProcessStartInfo;
$pinfo.FileName = 'C:\node\node.exe';
$pinfo.RedirectStandardError = $true;
$pinfo.RedirectStandardOutput = $true;
$pinfo.CreateNoWindow = $true;
$pinfo.UseShellExecute = $false;
$pinfo.Arguments = $Arguments;
$pinfo.StandardOutputEncoding=[system.Text.Encoding]::UTF8;
$p = New-Object System.Diagnostics.Process;
$p.StartInfo = $pinfo;
$p.Start() | Out-Null;
$Result=$p.StandardOutput.ReadToEnd();
$er=$p.WaitForExit(1000*30);<#タイムアウト ミリ秒#>
$Result;

変数を設定 [$Result;値: SMPS_Exe( Script  ) ]

スクリプト内でPowerShellを記述する場合、「"」ダブルクォーテーションをエスケイプする。
変数を設定 [$Script;値:
"$Arguments = \"-e `\"console.log('Hello, こんにちは?');`\"\";
$pinfo = New-Object System.Diagnostics.ProcessStartInfo;
$pinfo.FileName = 'C:\node\node.exe';
$pinfo.RedirectStandardError = $true;
$pinfo.RedirectStandardOutput = $true;
$pinfo.CreateNoWindow = $true;
$pinfo.UseShellExecute = $false;
$pinfo.Arguments = $Arguments;
$pinfo.StandardOutputEncoding=[system.Text.Encoding]::UTF8;
$p = New-Object System.Diagnostics.Process;
$p.StartInfo = $pinfo;
$p.Start() | Out-Null;
$Result=$p.StandardOutput.ReadToEnd();
$er=$p.WaitForExit(1000*30);<#タイムアウト ミリ秒#>
$Result;"]

変数を設定 [$Result;値: SMPS_Exe( $Script  ) ]

2018年1月5日金曜日

FileMaker Pro 16 HexEncode の代がえ

FileMaker Pro 16
HexEncode の代がえ
HexEncode : http://www.filemaker.com/help/16/fmp/ja/#page/FMP_Help%2Fhexencode.html%23

OS:Windows

プラグイン使用(FileMaker16, 15以下でも動作可能)
ScriptMakerPS | FileMaker Plugin for Windows
https://sites.google.com/site/scriptmakerps/

フィールド:Value [値:FileMaker]
スクリプト:
変数を設定 [$PS; 値:Let([
PS=" $ByteData = [System.Text.Encoding]::UTF8.GetBytes(\"{Value}\");
$Result=$ByteData | FOREACH { [System.Convert]::tostring($_,16) };
[string]::Join(\"\", $Result);"
];
Substitute ( PS ;
  ["{Value}" ; Substitute ( TableName::Value ; "\"" ; "`\"" )]
 )
)]
フィールド設定 [JSON::Result; SMPS_Exe( $PS )]

戻り値:46696c654d616b6572


[System.Text.Encoding]::UTF8
上記を書き換えれば、UTF-8以外でもエンコード可能。