Recent

Author Topic: [SOLVED] SIGSEGV on web form processing  (Read 3034 times)

lennit

  • Jr. Member
  • **
  • Posts: 63
  • Aquila non capit muscas.
[SOLVED] SIGSEGV on web form processing
« on: December 09, 2015, 02:47:37 pm »
Hello,
I am playing around with Benibella's Internet tools to retrieve data from a web form. In order to learn how to use it, I started with a simple HTML I made and the the source code I apply. Somehow though it gives me a SIGSEGV error when I try to use another template, other than the one pointing to the first element on the page.

Code: Pascal  [Select][+][-]
  1.  const
  2.    EXAMPLE_TEMPLATE :string='<table name="tabdata"><tr><td>{.}</td><td>{.}</td></tr>*</table>';
  3.    temp1:string='<input name=e1>{e1:=@value}</input>';
  4.    temp2:string='<input name=e2>{e2:=@value}</input>';
  5. var
  6.   Form1: TForm1;
  7.   content:string;
  8.   m:integer;
  9. implementation
  10.  
  11. {$R *.lfm}
  12.  
  13. { TForm1 }
  14.  
  15. procedure TForm1.retrieveDataClick(Sender: TObject);
  16. begin
  17.   m:=strtointdef(indexOfItem.Text,0);
  18.   content:=retrieve(address.Text);
  19.   case m of
  20.    0:process(content, temp1);
  21.    1:process(content, temp2);
  22.    2:process(content, EXAMPLE_TEMPLATE);
  23.    3:process(content, EXAMPLE_TEMPLATE);
  24.   end;
  25.   responseEdit.Text:=processedVariables.get(m).toString;
  26.   content:='';
  27.   processedVariables.Free;
  28. end;                                    
  29.  

This is the index.html against which I am testing it.
Code: Pascal  [Select][+][-]
  1. <!doctype html>
  2. <html>
  3. <title>Untitled Page</title>
  4. <body>
  5. <input name=e1 value="300"></input>
  6. <input name=e2 value="500"></input>
  7. <table name=tabdata>
  8. <tr><td>20</td><td>30</td></tr>
  9. </body>
  10. </html>
  11.  

It only works for the first template, in other words for the first input box in the web page. For any other index it gives me SIGSEGV. What am I doing wrong? Am I trying to overstep the possibilities which Internet Tools offer?
« Last Edit: December 09, 2015, 04:45:53 pm by lennit »
Win 7 32/64
Win 10 64bit
Lazarus 1.4.4
Firebird 2.5.3 (x64)

lennit

  • Jr. Member
  • **
  • Posts: 63
  • Aquila non capit muscas.
Re: SIGSEGV on web form processing
« Reply #1 on: December 09, 2015, 03:13:31 pm »
I got this  :D
Instead of
Code: Pascal  [Select][+][-]
  1. processedVariables.Free;
I should have used
Code: Pascal  [Select][+][-]
  1. processedVariables.Clear;
Modifying the template to this
Code: Pascal  [Select][+][-]
  1. const
  2.    EXAMPLE_TEMPLATE :string='<table name="tabdata"><tr><td>{.}</td><td>{.}</td><td>{.}</td><td>{.}</td></tr>*</table>';
  3.    temp1:string='<input name=e1>{e1:=@value}</input><input name=e2>{e2:=@value}</input>';
  4.    temp2:string='<input name=e2>{e2:=@value}</input>';
  5. var
  6.   Form1: TForm1;
  7.   content,con1,con2,con3:string;
  8.   m:integer;
  9. implementation
  10.  
  11. {$R *.lfm}
  12.  
  13. { TForm1 }
  14.  
  15. procedure TForm1.retrieveDataClick(Sender: TObject);
  16. begin
  17.   m:=strtointdef(indexOfItem.Text,0);
  18.   content:=retrieve(address.Text);
  19.   case m of
  20.    0:process(content, temp1);
  21.    1:process(content, temp1);
  22.    2:process(content, EXAMPLE_TEMPLATE);
  23.    3:process(content, EXAMPLE_TEMPLATE);
  24.   end;
  25.   responseEdit.Text:=processedVariables.get(m).toString;
  26.   content:='';
  27.   processedVariables.clear;
  28. end;                                            
  29.  
got me out of one more SIGSEGV.
I hope that helps someone to skip the struggle implementing Internet Tools.
« Last Edit: December 09, 2015, 03:17:46 pm by lennit »
Win 7 32/64
Win 10 64bit
Lazarus 1.4.4
Firebird 2.5.3 (x64)

BeniBela

  • Hero Member
  • *****
  • Posts: 958
    • homepage
Re: [SOLVED] SIGSEGV on web form processing
« Reply #2 on: December 09, 2015, 05:34:30 pm »
yeah, never call free directly, if you did not call create
« Last Edit: December 09, 2015, 05:44:03 pm by BeniBela »

lennit

  • Jr. Member
  • **
  • Posts: 63
  • Aquila non capit muscas.
Re: [SOLVED] SIGSEGV on web form processing
« Reply #3 on: December 09, 2015, 08:22:33 pm »
Thank you, Benibella :) Your tool helped me a lot with my current project.
Win 7 32/64
Win 10 64bit
Lazarus 1.4.4
Firebird 2.5.3 (x64)

 

TinyPortal © 2005-2018