カテゴリー別アーカイブ: delphi

文字列がファイル名として使用可能かをチェックする

//=============================================================================
// 文字列がファイル名として使用可能かをチェックする
// uses System.IOUtils が必要
//=============================================================================
function TfrmPlayerAppend.IsValidFilename(aFileName: String): boolean;
begin

if aFileName = ” then
begin
Result := false;
exit;
end;

Result := TPath.HasValidFileNameChars(aFileName, false);

end;

静的クラスメソッド

クラス名から直接呼び出せる関数

宣言

class function Count: Integer; static;

実装


class function TTimeStep.Count: Integer;
var
tmpInfo :PTypeInfo;
tmpData :PTypeData;
begin
tmpInfo :=TypeInfo(TTimeStepEnum);
tmpData :=GetTypeData(tmpInfo);
Result := tmpData.MaxValue – tmpData.MinValue + 1;
end;

Delphi XE7 で iOS 8.1.3 に対応

XE7 Update 1 をダウンロード、インストール

http://cc.embarcadero.com/reg/delphi

以下を確認

[配布用証明書]
Mac 上で[キーチェーン アクセス]を開き、Developer(Distributionでない方)の方をダブルクリック。
部署の部分が配布用証明書になる。

[モバイル プロビジョン プロファイル]
[アプリ識別子]
Mac にiPhone 構成ユーティリティ をインストールする。(ネットで検索、ダウンロード)iPhone 構成ユーティリティを起動、対象とするプロビジョニングプロファイル(ad-hocとStoreは別)を選択、下にあらわれるプロファイル識別子とアプリ識別子をメモ
/Users/(ユーザー名)/Library/MobileDevice/Provisioning Profiles/(プロファイル識別子のメモの内容).mobileprovision
がモバイル プロビジョン プロファイルとなる。
アプリ識別子はそのままアプリ識別子となる

プロジェクト>オプション>プロビジョニング

ツール>オプション>プロビジョニング
に[配布用証明書]と[モバイル プロビジョン プロファイル]を入力。タイプ、モードが複数あるのですべてに設定。

delphiからファイル>開く、%AppData%と入力してEnterキーを押す。
Embarcadero\BDS\15.0\Entitlement.TemplateiOS
を選択。

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
<%getTaskAllowKey%>
<%applicationIdentifier%>
<%pushNotificationKey%>
<%keychainAccessGroups%>
</dict>
</plist>

に二行を挿入
<key>application-identifier</key>
<string>35XXXXXXXXX.com.rigXXXXX.XXXXXX</string>
[配布用証明書].[アプリ識別子]

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
<%getTaskAllowKey%>
<key>application-identifier</key>
<string>XXXXXXXXXX.com.XXXXXXXXX.XXXXXXXXX</string>
<%applicationIdentifier%>
<%pushNotificationKey%>
<%keychainAccessGroups%>
</dict>
</plist>

注意:
このファイルの行送りは、LF+CR でなくLFでなくてはいけないらしい。
結局TERA PADで読み込み改行コードをLFに変更した。

注意:
目的フォルダ(release, debug)には、プロジェクトフォルダにある
Entitlement.TemplateiOS
をテンプレートにして、Entitlement.TemplateiOSが作成される。
%AppData%下にあるEmbarcadero\BDS\15.0\Entitlement.TemplateiOS がプロジェクトフォルダにコピーされるのは初回起動時?のみ。よって、Entitlement.TemplateiOSを検証するには、毎回、プロジェクトフォルダにある
Entitlement.TemplateiOS
を削除する必要がある。

注意:
アプリごとに[配布用証明書].[アプリ識別子]は違うが、上記の理由で、プロジェクトフォルダにあるEntitlement.TemplateiOS を個々に書き換えることで対応できる。

インストールはMACからスクラッチディレクトリ
/Users/yourname/RADPAServer/scratch-dir
を開いて。そこにある、ipa ファイルを XCODE organizer の目的機種のApplication にドラッグアンドドロップする。

参考: http://blogs.embarcadero.com/sarinadupont/2015/01/29/ios-813-app-deployment-steps-for-xe7

パッケージをインストールできません

実機テスト デバッグ

パッケージをインストールできません(e8008016)

> With UPD 1 installed,  NONE of them work,
>
> Installed the version without the update, and now  Debug is working, and not getting the errors with
> Adhoc/Appstore/Debug  either  (error e8008016  and e8008015)

I’m not sure why Update 1 wouldn’t be working, however error E8008016 is usually a problem with the entitlements file, and E8008015 is commonly a problem with incorrect details in the Provisioning options. For the E8008016 error you could

try deleting the .entitlements file and doing a build (which recreates it).

 

線分と点の距離

type
TGridLine = Record

private
FPositionS: TPoint;
FPositionE: TPoint;

public
procedure Assign(aGridLine: TGridLine);

property PointS: TPoint read FPositionS write FPositionS;
property PointE: TPoint read FPositionE write FPositionE;
end;

function TSessionScratchBoard.Distance(aPoint: TPointF; aGridLine: TGridLine): Single;
var
rx,ry,dx,dy,qx,qy,L2,W:double;
x0, y0, x1, y1: Single;
px, py: Single;
tmpPoint0, tmpPoint1: TPointF;
begin
tmpPoint0 := PositionToPoint(aGridLine.PointS.X, aGridLine.PointS.Y);
tmpPoint1 := PositionToPoint(aGridLine.PointE.X, aGridLine.PointE.Y);

px := aPoint.X;
py := aPoint.Y;
x0 := tmpPoint0.X;
y0 := tmpPoint0.Y;
x1 := tmpPoint1.X;
y1 := tmpPoint1.Y;

dx := x1 – x0;
dy := y1 – y0;
L2 := dx * dx + dy * dy;
rx := px – x0;
ry := py – y0;
W := rx * dx + ry * dy;
if L2 < W then
begin
rx := x1 - px;
ry := y1 - py;
W := rx * dx + ry * dy;
end;
if W < 0 then
result := sqrt(rx * rx + ry * ry)
else
result := abs(rx * dy - ry * dx)/sqrt(L2);
end;

多次元動的配列

Map: array of array of TMapElementEnum;


// 初期化
SetLength(Map, XBlock);
for i:=0 to Length(Map)-1 do
SetLength(Map[i], YBlock);
for i := 0 to XBlock - 1 do
for j := 0 to YBlock - 1 do
begin
//        ShowMessage(IntToStr(i) + ' - ' + IntToStr(j));
Map[i][j] := meNone;
end;



 

XE7 Jetスタイルでメモリーリーク

解決

http://www.freeml.com/delphi-users/3949/latest

FMX.Styles.Objects内の
TSystemButtonObjectクラスで
FInactiveAnimationを解放してないのが原因みたいです。

上記ファイルを自分のプロジェクトフォルダにコピーして
destructor TSystemButtonObject.Destroy;
begin
FInactiveLink.Free;
//// 追加
FInactiveAnimation.Free;
//// 追加終わり
inherited;
end;