DecodeDate raise an variant error

edited 10:00AM in FastScript
Hi !

I receive an "Invalid variant type conversion", when I call the "EncodeDate" method.

FastScript example:
var
aDate: TDateTime;
begin
aDate := EncodeDate(2004,10,01)


Regards
Christian

Comments

  • edited 10:00AM
    Works well for me. What Delphi version do you use?
  • edited 10:00AM
    Delphi 6

    Result from debugger:

    function TfsMethodHelper.GetValue: Variant;
    var
    v: Variant;
    i: Integer;
    s: String;
    Instance: TObject;
    begin
    if Assigned(FOnCall) then
    begin
    v := VarArrayCreate([0, Count - 1], varVariant);
    for i := 0 to Count - 1 do
    v := Params.Value; <<< Here

    VALUES:
    count = 2
    i = 1
    Params[0] = 2004
    Params[1] = 10
    Params[2] = 1

    It happens in the second loop (i=1)
    I tried it in the FastScript demo program, and I get the same error.

    Christian

  • edited 10:00AM
    I've some more information.

    This example works:
    decodeDate(date,y,m,d);
    da := encodeDate(y,m,d);

    - but this don't:
    d := 1;
    m := 1;
    da := encodeDate(y,m,d);

    I debugged the TfsMethodHelper.GetValue function, and notify that the parameter variant type is "varInteger" in the first example and is "varInt64" in the last example, for ???day???, ???month??? and ???year???.

    The error happens when the parameter variant type is varInt64

    Please help
    Christian
  • edited 10:00AM
    Delphi6 must be updated with update packs 1 and 2.
  • edited 10:00AM
    My delphi is updated with sp 1+2
    I got the problem after I updated to FastScript 1,7

    I've 2 solutions:

    1)
    Go back to FastScript 1,6

    2)
    Modify the code in unit fs_iinterpreter
    if Assigned(FOnCall) then
    begin
    v := VarArrayCreate([0, Count - 1], varVariant);
    // Modified >>
    for i := 0 to Count - 1 do begin
    if varType(Params.Value) <> varInt64 then
    v := Params.Value
    else
    v := Integer(Params.Value);
    end;
    // << Modified

    What do you prefer?

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.