RTC Forums
May 09, 2024, 11:30:40 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: RtcScript - accessing array value with expression  (Read 4338 times)
Theprasit
RTC License++
*****
Posts: 42


« on: November 19, 2014, 08:14:12 PM »

Hi,

According to RtcScript document, using accessing fields in an array using "( expression )". When using SESSION variable is working fine but using script variable return nothing.

Code:
<?
  session.lines:= new array;
  session.lines:= ('ABC', 'DEF');
  for $i:= 0 to session.lines.count- 1 do
  begin
    session.lines.0;
    session.lines($i);
  end;
?>
This working fine but

Code:
<?
  $lines:= new array;
  $lines:= ('ABC', 'DEF');
  for $i:= 0 to $lines.count- 1 do
  begin
    $lines.0;     -> working fine
    $lines($i);   -> return nothing
  end;
?>

These happen with Record and DataSet (under script) too.

Could you give me any advise?

Thank you and Regards,

Theprasit

P.S. I'm using RTC 6.20
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: November 19, 2014, 08:33:49 PM »

With the latest RTC SDK version (v6.44), the following script works just fine:
<?
  $lines:= new array;
  $lines:= ('ABC', 'DEF');
  for $i:= 0 to $lines.count- 1 do
  begin  
    $lines($i);  
  end;
?>
... it returns "ABCDEF" in Delphi 7 as well as Delphi XE7.

You can find a simple Project for testing RTC Scripts in the "QuickStart\rtcScript" folder.

Check your script code again to make sure you do not have a syntax error.
If your script code is correct, then post an example which reproduces the problem.

Best Regards,
Danijel Tkalcec
Logged
Theprasit
RTC License++
*****
Posts: 42


« Reply #2 on: November 20, 2014, 08:13:49 AM »

Hi Danijel,

Sorry to mentioned that I used RTC script to generate dynamic content to access via web browser.

I did further testing with "QuickStart\rtcScript" demo, both of the code are working fine (seem that using Win32 client is fine).

My project used RTC_WebPackaging as a guide line so, I did modify RTC_WebPackaging demo for tesing as

Code:
function TCommandsDispatcher.DoIndexPage(msg: string): string;
var
  Page : TRtcParse;
  Script: TRtcScriptEngine;
  FuncGrp: TRtcFunctionGroup;
begin
  FuncGrp:= TRtcFunctionGroup.Create(nil);
  Script:= TRtcScriptEngine.Create(nil);
  Script.FunctionGroup:= FuncGrp;

  Page := TRtcParse.Create(TemplatePath + 'index.htm');
  try
    ShowPageMessage(Page);
    Result:= Script.Execute(Srv, Script.Compile(Page.Output)).asText;
//    Result := Page.Output;
  finally
    Page.Free;
    Script.Free;
    FuncGrp.Free;
  end;
end;

and modify an Index.html template by insert the script code, the result is the same as my project return as

  $lines.0 -> return array element value, working
  $lines($i) -> return nothing

I did on both RTC 620 and 642 (Delphi XE) with the same result.

Best Regards,

Theprasit
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: November 20, 2014, 09:14:35 AM »

The Script you have provided as an example works, so the problem is somewhere else. To investigate further, I need the exact contents of your modified "index.htm" file for testing. You can send me the file by E-Mail to:


Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #4 on: November 20, 2014, 02:44:08 PM »

Thank you for the Example Project. I've found the cause of this problem. It was a local boolean variable which has not been initialized to FALSE before use, which sometimes resulted in strange behavior or Access Violations. The problem should now be fixed. Please, download the latest RTC SDK update (v6.45) and let me know if you are still experiencing issues with the RTC Scripting Engine.

Best Regards,
Danijel Tkalcec
Logged
Theprasit
RTC License++
*****
Posts: 42


« Reply #5 on: November 20, 2014, 04:32:03 PM »

Hi Danijel,

Just testing with RTC SDK 6.45 and it's work as expect.

Regarding of single element array, it's also working just fine.

RTC SDK is great., and your kind support is very much appreciate.

Best Regards,

Theprasit



Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #6 on: November 20, 2014, 04:34:20 PM »

Thank you for your feedback.

Best Regards,
Danijel Tkalcec
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.026 seconds with 17 queries.