You are not logged in.
I'm trying to build a custom format for LiveBindings to display ISO8601 (Don't know if it's needed, but good exercise)
It is basically a package that you need to compile/install into IDE, but I get error in subject when I try to compile.
Some reading suggest a rebuild with {$G+} or {$IMPORTEDDATA ON} but it does not work.
Thanks
unit ISO8601ToStrMethod;
interface
implementation
{$IMPORTEDDATA ON}
uses System.Bindings.Methods, System.SysUtils, MethodUtils,SynCommons,DateUtils;
const
sIDIso8601ToStr = 'Iso8601ToStr';
sIDStrToIso8601 = 'StrToIso8601';
procedure RegisterMethods;
begin
TMethodUtils.RegisterMethod<Iso8601,string>(sIDIso8601ToStr,
function(AValue: Iso8601): string
begin
Result := DateTimeToStr(AValue.ToDateTime);
end);
TMethodUtils.RegisterMethod<string,Iso8601>(sIDStrToIso8601,
function(AValue: string): ISO8601
var D : TDateTime;
I : Iso8601;
begin
try
D := StrToDateTime(AValue);
PIso8601(@I)^.From(D);
Result:=I;
finally
Result.Value:=0;
end;
end);
end;
procedure UnregisterMethods;
begin
TBindingMethodsFactory.UnRegisterMethod(sIDIso8601ToStr);
TBindingMethodsFactory.UnRegisterMethod(sIDStrToIso8601);
end;
initialization
RegisterMethods;
finalization
UnregisterMethods;
end.
Offline
I might add that it is done with a simple package that can be found on this aritcle:
http://www.malcolmgroves.com/blog/?p=1226
But here is a direct link:
https://github.com/malcolmgroves/delphi-samples.git/
Here is a simple working folder/project that can just be extracted/compiled to see error:
ftp://ftp.true.co.za/CustomFormats.zip
Last edited by AntonE (2013-03-04 11:09:33)
Offline
Did you try define USEPACKAGES conditional to help compiling the unit within packages, as defined in SynCommons.ini ?
You can set this conditional at the package project level.
Offline
Thank you i tried to add to project but did not work, so I just put it in SynCommons to get it compiled and it worked.
If this is what you meant:
package MGCustomLiveBindingMethods;
{$R *.res}
{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION OFF}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO ON}
{$SAFEDIVIDE OFF}
{$STACKFRAMES ON}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$DEFINE DEBUG}
{$ENDIF IMPLICITBUILDING}
{$IMPLICITBUILD ON}
{$DEFINE USEPACKAGES}
requires
rtl,
bindengine;
contains
ISO8601ToStrMethod in 'ISO8601ToStrMethod.pas',
MethodUtils in 'MethodUtils.pas',
SynCommons in '..\..\..\..\SynCommons.pas';
Offline