Extracting informations from Bonelli Editore Italian Comics
- 
				fulvio53s03
 - Posts: 781
 - Joined: 2007-04-28 05:46:43
 - Location: Italy
 
Code: Select all
listaserie := '1  Tex' + crlf + '70 Almanacco del Giallo Julia' + crlf;
         listaserie := listaserie + '2  Almanacco del west' + crlf + '4  Julia' + crlf +   crlf + '2 Julia' + 'Enter comic series:' + crlf;
         Input('www.sergiobonellieditore.it', listaserie, ComicSeries); // Asks for comic series number
I hope I explained myself more clearly.
Thanks
Well you could also use the list like what is used for description selection on imdb, but if you really want a window with an area where the user has to type text, nothing is made for that.
There is a way to create new window through scripting but:
- I am not sure that I enabled that in AMC
- I do not know how to do it without doing some searches first
			
			
									
						
										
						There is a way to create new window through scripting but:
- I am not sure that I enabled that in AMC
- I do not know how to do it without doing some searches first
When you say an easier way, what is easier than using a PickTree - especially for the user ?fulvio53s03 wrote:Good answer about 'picktree' but I would try an easier way: the 'input' panel.
Code: Select all
program NewScript;
var
  ComicSeries: string;
begin
  PickTreeClear;
  PickTreeAdd('Tex Willer', '1');
  PickTreeAdd('Almanacco del West', '2');
  PickTreeAdd('Julia', '4');
  if PickTreeExec(ComicSeries) then
    ShowMessage('Series number is: ' + ComicSeries);
end.- 
				fulvio53s03
 - Posts: 781
 - Joined: 2007-04-28 05:46:43
 - Location: Italy
 
Great solution to use both "Picktree" and "Case" together!.
About HTMLdecode or similar functions: I give you the last version of the script as I don't succeed to delete some "strange" characters I find in the field "Translated Title" if I input "70" in the field "Label" and "1" in the Original Title and execute my script:
What are those strange characters I see? How can I to delete them? Thanks.
			
			
									
						
										
						About HTMLdecode or similar functions: I give you the last version of the script as I don't succeed to delete some "strange" characters I find in the field "Translated Title" if I input "70" in the field "Label" and "1" in the Original Title and execute my script:
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=
Title=sergiobonellieditore.it picktree
Description=
Site=http://www.sergiobonellieditore.it/
Language=IT
Version=v.0.1.0
Requires=3.5.0
Comments=
License=
GetInfo=1
[Options]
***************************************************)
program sergiobonellieditore;
uses
  StringUtils1;   // Script needs external unit StringUtils1.pas in scripts folder !
var
  ComicURL, ComicSeries, ComicNumber, Collana: string;   // Define some script variables
  update: string;
  sw_serie : string;
  numCollana : integer;
  CollanaArray: Array of String;
  i, j: integer;
const
  crlf = #13#10;                        // carriage return/line feed
Procedure alborist;
begin
     ComicURL := 'http://www.sergiobonellieditore.it/auto/alborist?collana=' + ComicSeries + '&numero=' + ComicNumber + '&subnum=0'; // Build item URL
     Setfield(fieldURL, ComicURL);   // Save variable URL to field URL
     AnalyzePageAlborist(ComicURL); // Script hands over item URL and jumps to procedure AnalyzePageAlborist
end;
Procedure albo_speciale;
begin
     ComicURL := 'http://www.sergiobonellieditore.it/auto/scheda_speciale?collana=' + ComicSeries + '&numero=' + ComicNumber + '&subnum=0'; // Build item URL
//   showmessage ('URL ' + ComicURL + ' *');
     Setfield(fieldURL, ComicURL);   // Save variable URL to field URL
     AnalyzePageScheda_speciale(ComicURL); // Script hands over item URL and jumps to procedure AnalyzePageScheda_speciale
end;
// ***** Analyze Item's Page *****
procedure AnalyzePageAlborist(URL: String);   // Variable "URL" is handed over (former variable "ComicURL")
var
  Page, SavePage, Value, saveValue: string;   // Define variables "Page" and "Value"
begin
  Page := GetPage(URL);   // Fetch source code from website and store inside "Page"
  SavePage := Page;
// Serie import
  Value := '';   // Make sure "Value" is empty
  Value := TextBetween(Page, '<title>Archivio arretrati: scheda dell''albo di ', '</title>');   // Extract title part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);   // Clean title from HTML tags (if some exist)
  SetField(fieldMedia, Value);   // Save title to field Label
// Picture import
  Value := '';   // Make sure "Value" is empty
  Value := TextBetween(Page, 'window.open(''', '''');   // Extract the picture URL from "Page"
  if Value = '' then   // If "Value" is still empty ( = no picture URL ) then..
    Value := 'http://www.sergiobonellieditore.it' + TextBetween(Line, '<img src="', '"');   // .. try to extract URL for small picture instead
  if Value <> '' then   // If "Value" now contains picture URL then..
    GetPicture(Value);   // .. download and save picture
// Titolo tradotto
  Value := '';
  Value := TextBetween(Page, '<table border=0 cellspacing=0 cellpadding=0>', '</table>');   // Extract title part from variable "Page"
  Value := TextBetween(Value, '<b>', '</b>');   // Extract exact title from variable "Value" now
//  Value := StringReplace(Value, ''', '''');  // sistema gli apostofi
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);   // Clean title from HTML tags (if some exist)
  Fulltrim(Value);
  SetField(fieldTranslatedTitle, Value);   // Save title to field TranslatedTitle
// Beschreibung / Description / Storia
// struttura dei primi numeri
  Value := '';
  saveValue := '';
// Storia
  Value := TextBetween(Page, '<table width=100% cellspacing=0 cellpadding=0 border=0>', '</DIV>');   // Extract description part from variable "Page"
//  showmessage('value1 ' + Value);
  Value := TextBetween(Value, '<font face="Arial" size=2>', 'In questo numero:');   // Extract exact description from variable "Value" now
//  showmessage('value2 ' + Value);
//  Value := TextBetween(Value, '<font face="Arial" size=2>', '</font>');   // Extract exact description from variable "Value" now
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  saveValue := Value;
// Comments / In questo numero
  Value := TextBetween(Page, '<table width=100% cellspacing=0 cellpadding=0 border=0>', ' </td>'); // Extract description part from "Page"
//  showmessage (Value)
  Value := TextBetween(Value, 'In questo numero:', '</font>');   // Extract exact description from variable "Value" now
//  showmessage (Value)
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  if length(Value) > 0 then
     SetField(fieldComments, ('In questo numero: ' + Value));   // Save description to field Description
// struttura dei numeri successivi (es. 214)
  if length (saveValue) = 0 then
     begin
     Value := TextBetween(page, '<DIV VALIGN=TOP>', ' </td>');   // Extract description part from variable "Page"
//     showmessage('value3 ' + Value);
     Value := TextBetween(value, '<DIV VALIGN=TOP><font face="Arial" size=2>', '</font></DIV>');   // Extract description part from variable "Page"
     HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
     HTMLRemoveTags(Value);
     FullTrim(Value);   // Clean up the description
//     showmessage('value4 ' + Value);
     if length (Value) < 2 then   // 2 as there must be crlf
        showError ('Errore. collana ' + getfield(fieldMedia) + ' n.' + getfield(fieldOriginaltitle) + '. Trama mancante');
     saveValue := Value;
     end
  SetField(fieldDescription, saveValue);   // Save description to field Description
//  showmessage ('descrizione ' + saveValue);
// Comments / In questo numero
  Value := TextBetween(Page, '<table width=100% cellspacing=0 cellpadding=0 border=0>', ' </td>'); // Extract description part from "Page"
//  showmessage (Value)
  Value := TextBetween(Value, 'In questo numero:', '</font>');   // Extract exact description from variable "Value" now
//  showmessage (Value)
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  if length(Value) > 0 then
     SetField(fieldComments, ('In questo numero: ' + Value));   // Save description to field Description
// fieldActors / Autori
  SaveValue := '';
  Value := '';
  Value := TextBetween(Page, 'Soggetto e sceneggiatura: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := 'Soggetto e sceneggiatura: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Disegni e copertina: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := saveValue + 'Disegni e copertina: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Disegni: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := saveValue + 'Disegni: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Copertina: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := saveValue + 'Copertina: ' + Value + crlf;
     end
  SetField(fieldActors, saveValue);   // Save description to field Actors
end; // *********************** End of procedure "AnalyzePageAlborist" *****************************************
procedure AnalyzePageScheda_speciale(URL: String);   // Variable "URL" is handed over (former variable "ComicURL")
var
  CharCut, Charlength: integer;
  Page, SavePage, Value, saveValue: string;   // Define variables "Page" and "Value"
  StartDelimiter, EndDelimiter: String;
begin
  Page := GetPage(ComicURL);   // Fetch source code from website and store inside "Page"
  SavePage := Page;
// Picture import
  Value := '';   // Make sure "Value" is empty
  Value := TextBetween(Page, 'window.open(''', '''');   // Extract the picture URL from "Page"
  if Value = '' then   // If "Value" is still empty ( = no picture URL ) then..
    Value := 'http://www.sergiobonellieditore.it' + TextBetween(Value, '<img src="', '"');   // .. try to extract URL for small picture instead
  if Value <> '' then   // If "Value" now contains picture URL then..
    GetPicture(Value);   // .. download and save picture
// Serie import
  Value := '';   // Make sure "Value" is empty
  Value := TextBetween(Page, '<table border=0 cellspacing=0 cellpadding=0>', '</table');   // Extract serie from variable "Page"
  SaveValue := Value;              // SaveValue contiene tutta la table (meno i delimiters)
  Showmessage ('savevalue1 ' + savevalue + ' ****');
  StartDelimiter := '<font face="Arial" size=2>';
  CharCut := Pos(StartDelimiter, Value);
  EndDelimiter := '</font>';
  Value := TextBetween(Value, StartDelimiter, EndDelimiter);
  CharCut := CharCut + length(StartDelimiter) + length(Value) + length(EndDelimiter);
//  showmessage ('Charcut * ' + IntToStr(CharCut) + ' *');
  Delete(SaveValue, 1, Charcut);    // stringa in cui cercare il prossimo campo
//  Showmessage ('savevalue2 ' + savevalue + ' ****');
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);   // Clean title from HTML tags (if some exist)
  Fulltrim(Value);
  SetField(fieldMedia, Value);   // Save title to field Media
// Titolo tradotto
  Value := SaveValue;
  Value := TextBetween(Value, '<font face="Arial" size=2>', '</font>');   // Extract exact title from variable "SaveValue"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);   // Clean title from HTML tags (if some exist)
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  FullTrim(Value);
  showmessage ('Value titolo *' + Value + '***');
  SetField(fieldTranslatedTitle, Value);   // Save title to field TranslatedTitle
// Beschreibung / Description / Storia
// struttura dei primi numeri
  Value := '';
  saveValue := '';
// Storia
  Value := TextBetween(Page, '<table width=100% cellspacing=0 cellpadding=0 border=0>', '</DIV>');   // Extract description part from variable "Page"
//  showmessage('value1 ' + Value);
  Value := TextBetween(Value, '<font face="Arial" size=2>', 'In questo numero:');   // Extract exact description from variable "Value" now
//  showmessage('value2 ' + Value);
//  Value := TextBetween(Value, '<font face="Arial" size=2>', '</font>');   // Extract exact description from variable "Value" now
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  saveValue := Value;
// Comments / In questo numero
  Value := TextBetween(Page, '<td width="50%" valign="bottom" ><font color="#0080C0" face="Verdana" size=1>', ' </td>'); // Extract description part from "Page"
//  showmessage (Value)
  Value := TextBetween(Value, '<strong>', '</strong>');   // Extract exact description from variable "Value" now
//  showmessage (Value)
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Fulltrim(Value);
  if length(Value) > 0 then
     SetField(fieldComments, ('In questo numero: ' + Value));   // Save description to field Description
// struttura dei numeri successivi (es. 214)
  if length (saveValue) = 0 then
     begin
     Value := TextBetween(page, '<DIV VALIGN=TOP>', ' </td>');   // Extract description part from variable "Page"
//     showmessage('value3 ' + Value);
     Value := TextBetween(value, '<DIV VALIGN=TOP><font face="Arial" size=2>', '</font></DIV>');   // Extract description part from variable "Page"
     HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
     HTMLRemoveTags(Value);
     FullTrim(Value);   // Clean up the description
//     showmessage('value4 ' + Value);
     if length (Value) < 2 then   // 2 as there must be crlf
        showError ('Errore. collana ' + getfield(fieldMedia) + ' n.' + getfield(fieldOriginaltitle) + '. Trama mancante');
     saveValue := Value;
     end
  Fulltrim(Value);
  SetField(fieldDescription, saveValue);   // Save description to field Description
//  showmessage ('descrizione ' + saveValue);
// Comments / In questo numero
  Value := TextBetween(Page, '<table width=100% cellspacing=0 cellpadding=0 border=0>', ' </td>'); // Extract description part from "Page"
//  showmessage (Value)
  Value := TextBetween(Value, 'In questo numero:', '</font>');   // Extract exact description from variable "Value" now
//  showmessage (Value)
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  if length(Value) > 0 then
     SetField(fieldComments, ('In questo numero: ' + Value));   // Save description to field Description
// fieldActors / Autori
  SaveValue := '';
  Value := '';
  Value := TextBetween(Page, 'Soggetto e sceneggiatura: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := 'Soggetto e sceneggiatura: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Soggetto: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := 'Soggetto: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Sceneggiatura: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := 'Sceneggiatura: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Disegni e copertina: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := saveValue + 'Disegni e copertina: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Disegni: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := saveValue + 'Disegni: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Copertina: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  FullTrim(Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := saveValue + 'Copertina: ' + Value + crlf;
     end
  SetField(fieldActors, saveValue);   // Save description to field Actors
end; // *********************** End of procedure "AnalyzeScheda_speciale" *****************************************
Procedure Menu;
begin
      Repeat
      sw_serie := 'OK';
      case ComicSeries of
        'Tex':                          ComicSeries := '1';        '1':  ComicSeries := '1';
        'Almanacco del West':           ComicSeries := '2';        '2':  ComicSeries := '2';
        'Julia':                        ComicSeries := '4';        '4':  ComicSeries := '4';
        'Almanacco del West':           ComicSeries := '7';        '7':  ComicSeries := '7';
        'Martin Mystère':               ComicSeries := '13';       '13': ComicSeries := '13';
        'Nathan Never':                 ComicSeries := '15';       '15': ComicSeries := '15';
        'Dylan Dog':                    ComicSeries := '18';       '18': ComicSeries := '18';
        'Almanacco dell''avventura':    ComicSeries := '25';       '25': ComicSeries := '25';
        'Almanacco della Fantascienza': ComicSeries := '34';       '34': ComicSeries := '34';
        'Almanacco della Paura':        ComicSeries := '36';       '34': ComicSeries := '36';
        'Almanacco dell''avventura':    ComicSeries := '50';       '50': ComicSeries := '50';
        'Almanacco del Giallo':         ComicSeries := '70';       '70': ComicSeries := '70';
      else
         begin
      PickTreeClear;
      PickTreeAdd('  (1) Tex',                                      '1');
      PickTreeAdd('  (2) Almanacco del West',                       '2');
      PickTreeAdd('  (4) Julia',                                    '4');
      PickTreeAdd('  (7) Almanacco del West (Tex)',                 '7');
      PickTreeAdd('(13) Martin Mystère',                            '13');
      PickTreeAdd('(15) Nathan Never',                              '15');
      PickTreeAdd('(18) Dylan Dog',                                 '18');
      PickTreeAdd('(25) Almanacco dell''Avventura (Zagor)',         '25');
      PickTreeAdd('(34) Almanacco della Fantascienza',              '34');
      PickTreeAdd('(36) Almanacco della Paura',                     '36');
      PickTreeAdd('(50) Almanacco dell''Avventura (Mister No)',     '50');
      PickTreeAdd('(70) Almanacco del Giallo (Julia)',              '70');
      if PickTreeExec(ComicSeries) then
         ShowMessage('Series number is: ' + ComicSeries);
         sw_serie := 'error'
         end;
      end;
      until sw_serie = 'OK';
end;
// ***** Beginning of the script *****
begin
  if CheckVersion(3,5,0) then // Checks if Ant Movie Catalog version is 3.5.0 or higher
     begin
//      Input('www.sergiobonellieditore.it', 'Enter comic series:', ComicSeries); // Asks for comic series number
     ComicSeries := GetField(fieldMedia);
     showmessage ('trace1');
//     if ComicSeries = '' then
//     begin
//     showmessage ('trace2');
        menu;
//     end;
     showmessage ('trace3');
     ComicNumber := GetField(fieldOriginalTitle);
     if ComicNumber = '' then
       Input('www.sergiobonellieditore.it', ComicSeries + crlf + 'Enter comic number:', ComicNumber);
     If (ComicSeries = '1') or (comicSeries = '13') or (ComicSeries = '15') then
        begin
        ComicURL := 'http://www.sergiobonellieditore.it/auto/alborist?collana=' + ComicSeries + '&numero=' + ComicNumber + '&subnum=0'; // Build item URL
        Setfield(fieldURL, ComicURL);   // Save variable URL to field URL
        AnalyzePageAlborist(ComicURL); // Script hands over item URL and jumps to procedure AnalyzePageAlborist
        end
     If (ComicSeries = '2') or (comicSeries = '7') or (ComicSeries = '8') or (ComicSeries = '70') then
        begin
        ComicURL := 'http://www.sergiobonellieditore.it/auto/scheda_speciale?collana=' + ComicSeries + '&numero=' + ComicNumber + '&subnum=0'; // Build item URL
//      showmessage ('URL ' + ComicURL + ' *');
        Setfield(fieldURL, ComicURL);   // Save variable URL to field URL
        AnalyzePageScheda_speciale(ComicURL); // Script hands over item URL and jumps to procedure AnalyzePageScheda_speciale
//      Input('www.sergiobonellieditore.it', 'Enter comic number:', ComicNumber); // Asks for comic item number
//      ComicNumber := ComicSeries
        end
  end
  else
     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
    // If Checkversion fails end.
end.
Just for your info :
Instead of
you can use 
About the FullTrim function - simply write your own one 
Something like
should do the job. It deletes all tabs, linebreaks and spaces from the beginning and end of the variable.
Call this function with 
instead of just
@antp: The FullTrim function from StringUtils1.pas only deletes spaces from the beginning and end of a variable, nothing else. You should consider replacing FullTrim with the function from above (and simply rename it) - have a closer look on it, might be not very elegant, but at least it seems correct for me..
			
			
													Instead of
Code: Select all
      case ComicSeries of
        'Tex':                          ComicSeries := '1';        '1':  ComicSeries := '1';
        'Almanacco del West':           ComicSeries := '2';        '2':  ComicSeries := '2';
        'Julia':                        ComicSeries := '4';        '4':  ComicSeries := '4'; Code: Select all
      case ComicSeries of
        'Tex','1':                     ComicSeries := '1';
        'Almanacco del West','2':      ComicSeries := '2';
        'Julia','4':                   ComicSeries := '4';Something like
Code: Select all
function MyTrim(Value: string):string;
begin
  result := '';
  repeat  
    if (copy(Value, 1, 1) = ' ') or (copy(Value, 1, 1) = #10) or (copy(Value, 1, 1) = #13) or (copy(Value, 1, 1) = #9) then
      Value := copy(Value, 2, Length(Value)-1);
  until
    (copy(Value, 1, 1) <> ' ') and (copy(Value, 1, 1) <> #10) and (copy(Value, 1, 1) <> #13) and (copy(Value, 1, 1) <> #9);
  repeat 
    if (copy(Value, Length(Value), 1) = ' ') or (copy(Value, Length(Value), 1) = #10) or (copy(Value, Length(Value), 1) = #13) or (copy(Value, Length(Value), 1) = #9) then
      Value := copy(Value, 1, Length(Value)-2);
  until
    (copy(Value, Length(Value), 1) <> ' ') and (copy(Value, Length(Value), 1) <> #10) and (copy(Value, Length(Value), 1) <> #13) and (copy(Value, Length(Value), 1) <> #9);
  result := Value;
end;Call this function with
Code: Select all
Value := MyTrim(Value);instead of just
Code: Select all
MyTrim(Value);
					Last edited by bad4u on 2008-10-18 11:21:00, edited 1 time in total.
									
			
						
										
						- 
				fulvio53s03
 - Posts: 781
 - Joined: 2007-04-28 05:46:43
 - Location: Italy
 
@antp: This might be a more elegant solution for StringUtils1; it doesn't break on empty strings, too
@fulvio: This code gives the same result as the MyTrim function above.
			
			
									
						
										
						@fulvio: This code gives the same result as the MyTrim function above.
Code: Select all
function MyTrim(Value: string):string;
var
  ExitLoop: Boolean;
begin
  Result := '';
  ExitLoop := False;
  repeat
    case copy(Value, 1, 1) of
      ' ', #9, #10, #13:    Value := copy(Value, 2, Length(Value)-1);
    else
      ExitLoop := True;
    end;
  until ExitLoop;
  ExitLoop := False;
  repeat
    case copy(Value, Length(Value), 1) of
      ' ', #9, #10, #13:    Value := copy(Value, 1, Length(Value)-2);
    else
      ExitLoop := True;
    end;
  until ExitLoop;
  Result := Value;
end;@fulvio: You don't need to change your script for the FullTrim function anymore. Just download latest StringUtils1 version from http://update.antp.be/amc/scripts/StringUtils1.pas and save it to your scripts folder. Then simply use 
			
			
									
						
										
						Code: Select all
Value := Fulltrim(Value);- 
				fulvio53s03
 - Posts: 781
 - Joined: 2007-04-28 05:46:43
 - Location: Italy
 
Thanks for all.
I'm going on with my work and I hope I will get a good point.
I think there may be a little mistake in 'FullTrim' as I get a strange and particular situation.
Look at the messages mesea, meseb, mesec, mesed you can see inputting serie 15, OriginalTitle 3 and, using the script I give you following, you will find a truncation in the result of the function Fulltrim.
Sorry, I need your help as I don't understand very well the function 'FullTrim'.
ciao.
			
			
									
						
										
						I'm going on with my work and I hope I will get a good point.
I think there may be a little mistake in 'FullTrim' as I get a strange and particular situation.
Look at the messages mesea, meseb, mesec, mesed you can see inputting serie 15, OriginalTitle 3 and, using the script I give you following, you will find a truncation in the result of the function Fulltrim.
Sorry, I need your help as I don't understand very well the function 'FullTrim'.
ciao.
Code: Select all
program sergiobonellieditore;
uses
  StringUtils1;   // Script needs external unit StringUtils1.pas in scripts folder !
var
  ComicURL, ComicSeries, ComicNumber, Collana: string;   // Define some script variables
  update: string;
  Titolo_e_Periodicita: string;
  sw_serie, StartDelimiter, endDelimiter : string;
  numCollana : integer;
  CharCut: integer;
  DataPubbl,Mese_Pubblicazione: String;
//  i, j: integer;
const
  crlf = #13#10;                        // carriage return/line feed
Procedure alborist;
begin
     ComicURL := 'http://www.sergiobonellieditore.it/auto/alborist?collana=' + ComicSeries + '&numero=' + ComicNumber + '&subnum=0'; // Build item URL
     Setfield(fieldURL, ComicURL);   // Save variable URL to field URL
     AnalyzePageAlborist(ComicURL); // Script hands over item URL and jumps to procedure AnalyzePageAlborist
end;
Procedure albo_speciale;
begin
     ComicURL := 'http://www.sergiobonellieditore.it/auto/scheda_speciale?collana=' + ComicSeries + '&numero=' + ComicNumber + '&subnum=0'; // Build item URL
//   showmessage ('URL ' + ComicURL + ' *');
     Setfield(fieldURL, ComicURL);   // Save variable URL to field URL
     AnalyzePageScheda_speciale(ComicURL); // Script hands over item URL and jumps to procedure AnalyzePageScheda_speciale
end;
// ***** Analyze Item's Page *****
procedure AnalyzePageAlborist(URL: String);   // Variable "URL" is handed over (former variable "ComicURL")
var
  Page, SavePage, Value, saveValue: string;   // Define variables "Page" and "Value"
begin
  Page := GetPage(URL);   // Fetch source code from website and store inside "Page"
  SavePage := Page;
// Serie import
  Value := '';   // Make sure "Value" is empty
  Value := TextBetween(Page, '<title>Archivio arretrati: scheda dell''albo di ', '</title>');   // Extract title part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);   // Clean title from HTML tags (if some exist)
  Value := FullTrim (Value);
  SetField(fieldSource, Value);   // Save title to field Label
// Picture import
  Value := '';   // Make sure "Value" is empty
  Value := TextBetween(Page, 'window.open(''', '''');   // Extract the picture URL from "Page"
  if Value = '' then   // If "Value" is still empty ( = no picture URL ) then..
    Value := 'http://www.sergiobonellieditore.it' + TextBetween(Line, '<img src="', '"');   // .. try to extract URL for small picture instead
  if Value <> '' then   // If "Value" now contains picture URL then..
    GetPicture(Value);   // .. download and save picture
// Titolo tradotto
  Value := '';
  Value := TextBetween(Page, '<table border=0 cellspacing=0 cellpadding=0>', '</table>');   // Extract title part from variable "Page"
  Titolo_e_Periodicita := Value;
  Value := TextBetween(Value, '<b>', '</b>');   // Extract exact title from variable "Value" now
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);   // Clean title from HTML tags (if some exist)
//  showmessage ('titolo *' + value + '*');
  FullTrim (Value);
//  Value := StringReplace(Value, '’', '''');
  SetField(fieldTranslatedTitle, Value);   // Save title to field TranslatedTitle
// Beschreibung / Description / Storia
// struttura dei primi numeri
  Value := '';
  saveValue := '';
// Storia
  Value := TextBetween(Page, '<table width=100% cellspacing=0 cellpadding=0 border=0>', '</DIV>');   // Extract description part from variable "Page"
//  showmessage('value1 ' + Value);
  Value := TextBetween(Value, '<font face="Arial" size=2>', 'In questo numero:');   // Extract exact description from variable "Value" now
//  showmessage('value2 ' + Value);
//  Value := TextBetween(Value, '<font face="Arial" size=2>', '</font>');   // Extract exact description from variable "Value" now
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  saveValue := Value;
// ***************** inizio periodicità
  StartDelimiter := '<font face="Arial" size=2>';
  CharCut := Pos(StartDelimiter, Value);
  EndDelimiter := '</font>';
  Value := TextBetween(Page, StartDelimiter, EndDelimiter);
//  showmessage ('periodicità estratta * ' + Value + ' *');
  CharCut := CharCut + length(StartDelimiter) + length(Value) + length(EndDelimiter);
//  showmessage ('Charcut * ' + IntToStr(CharCut) + ' *');
  Delete(SaveValue, 1, Charcut);    // stringa in cui cercare il prossimo campo
//  Showmessage ('savevalue2 ' + savevalue + ' ****');
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);   // Clean title from HTML tags (if some exist)
  Value := FullTrim (Value);
//  DataPubbl := Value + '</font>'; //serie 18: contiene titolo + 'mensile' e ripristino fine delimiter
//  showmessage ('DataPubbl *' + DataPubbl + '*');  //OK per serie 18
  Mese_Pubblicazione := '';   // pulisco Mese_Pubblicazione
  Mese_Pubblicazione := TextBetween(Page, '<font face="Verdana" size="1" color="#FFFFFF">', '</font>');
  HTMLDecode(Mese_Pubblicazione);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Mese_Pubblicazione);   // Clean title from HTML tags (if some exist)
  Mese_Pubblicazione := FullTrim (Mese_Pubblicazione);
  Value := Mese_Pubblicazione;
//  showmessage ('lunghezza *' + Mese_Pubblicazione + '*' + Inttostr(Length(Mese_pubblicazione)));
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  if ComicSeries = '18' then
     begin
     Value := TextBetween(Titolo_e_Periodicita, ',', '<br>');
     HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
     HTMLRemoveTags(Value);   // Clean title from HTML tags (if some exist)
     Value := FullTrim (Value);
     if Mese_pubblicazione <> '' then
        Value := Mese_pubblicazione + ' - ' + Value;
     end
  if ComicSeries = '13' then
     begin
     Value := TextBetween(Titolo_e_Periodicita, ',', '<br>');
     HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
     HTMLRemoveTags(Value);   // Clean title from HTML tags (if some exist)
     Value := FullTrim (Value);
     if Mese_pubblicazione <> '' then
        Value := Mese_pubblicazione + ' - ' + Value;
     end
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  SetField(fieldDirector, Value);   // Save data pubblicazione to Field Director
// ***************** fine periodicità
// Comments / In questo numero
  Value := TextBetween(Page, '<table width=100% cellspacing=0 cellpadding=0 border=0>', ' </td>'); // Extract description part from "Page"
//  showmessage (Value)
  Value := TextBetween(Value, 'In questo numero:', '</font>');   // Extract exact description from variable "Value" now
//  showmessage (Value)
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  if length(Value) > 0 then
     SetField(fieldComments, ('In questo numero: ' + Value));   // Save description to field Description
// struttura dei numeri successivi (es. 214)
  if length (saveValue) = 0 then
     begin
     Value := TextBetween(page, '<DIV VALIGN=TOP>', ' </td>');   // Extract description part from variable "Page"
//     showmessage('value3 ' + Value);
     Value := TextBetween(value, '<DIV VALIGN=TOP><font face="Arial" size=2>', '</font></DIV>');   // Extract description part from variable "Page"
     HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
     HTMLRemoveTags(Value);
     Value := FullTrim (Value);   // Clean up the description
//     showmessage('value4 ' + Value);
     if length (Value) < 2 then   // 2 as there must be crlf
        showError ('Errore. collana ' + getfield(fieldMedia) + ' n.' + getfield(fieldOriginaltitle) + '. Trama mancante');
     saveValue := Value;
     end
  SetField(fieldDescription, saveValue);   // Save description to field Description
//  showmessage ('descrizione ' + saveValue);
// Comments / In questo numero
  Value := TextBetween(Page, '<table width=100% cellspacing=0 cellpadding=0 border=0>', ' </td>'); // Extract description part from "Page"
//  showmessage (Value)
  Value := TextBetween(Value, 'In questo numero:', '</font>');   // Extract exact description from variable "Value" now
//  showmessage (Value)
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  if length(Value) > 0 then
     SetField(fieldComments, ('In questo numero: ' + Value));   // Save description to field Description
// fieldActors / Autori
  SaveValue := '';
  Value := '';
  Value := TextBetween(Page, 'Soggetto e sceneggiatura: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := 'Soggetto e sceneggiatura: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Disegni e copertina: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := saveValue + 'Disegni e copertina: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Disegni: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := saveValue + 'Disegni: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Copertina: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := saveValue + 'Copertina: ' + Value + crlf;
     end
  SetField(fieldActors, saveValue);   // Save description to field Actors
end; // *********************** End of procedure "AnalyzePageAlborist" *****************************************
procedure AnalyzePageScheda_speciale(URL: String);   // Variable "URL" is handed over (former variable "ComicURL")
var
  Page, SavePage, Value, saveValue: string;   // Define variables "Page" and "Value"
begin
  Page := GetPage(ComicURL);   // Fetch source code from website and store inside "Page"
  SavePage := Page;
// Picture import
  Value := '';   // Make sure "Value" is empty
  Value := TextBetween(Page, 'window.open(''', '''');   // Extract the picture URL from "Page"
  if Value = '' then   // If "Value" is still empty ( = no picture URL ) then..
    Value := 'http://www.sergiobonellieditore.it' + TextBetween(Value, '<img src="', '"');   // .. try to extract URL for small picture instead
  if Value <> '' then   // If "Value" now contains picture URL then..
    GetPicture(Value);   // .. download and save picture
// Serie import
  Value := '';   // Make sure "Value" is empty
  Value := TextBetween(Page, '<table border=0 cellspacing=0 cellpadding=0>', '</table');   // Extract serie from variable "Page"
  SaveValue := Value;              // SaveValue contiene tutta la table (meno i delimiters)
  Titolo_e_Periodicita := Value;
// ***************** inizio periodicità
  StartDelimiter := '<font face="Arial" size=2>';
  CharCut := Pos(StartDelimiter, Value);
  EndDelimiter := '</font>';
  Value := TextBetween(Value, StartDelimiter, EndDelimiter);
  CharCut := CharCut + length(StartDelimiter) + length(Value) + length(EndDelimiter);
//  showmessage ('Charcut * ' + IntToStr(CharCut) + ' *');
  Delete(SaveValue, 1, Charcut);    // stringa in cui cercare il prossimo campo
//  Showmessage ('savevalue2 ' + savevalue + ' ****');
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);   // Clean title from HTML tags (if some exist)
  Value := FullTrim (Value);
  DataPubbl := Value + '</font>'; //serie 18: contiene titolo + 'periodicità irregolare' e ripristino fine delimiter
//  showmessage ('DataPubbl *' + DataPubbl + '*');  //OK per serie 18
  Mese_Pubblicazione := '';   // pulisco Mese_Pubblicazione
  Mese_Pubblicazione := TextBetween(Page, '<font face="Verdana" size="1" color="#FFFFFF">', '</font></strong>');
  HTMLDecode(Mese_Pubblicazione);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Mese_Pubblicazione);   // Clean title from HTML tags (if some exist)
  Mese_Pubblicazione := FullTrim (Mese_Pubblicazione);
//  showmessage ('lunghezza *' + Mese_Pubblicazione + '*' + Inttostr(Length(Mese_pubblicazione)));
//  if (ComicSeries = '15') then
//     begin
//     CharCut := Pos(' n.', Mese_Pubblicazione);
//     Value := copy(Mese_Pubblicazione, 0, CharCut-1);    // Extract exact periodicity from variable "Value"
//     Value := TextBetween(DataPubbl, ',', '</font>');
//     HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
//     HTMLRemoveTags(Value);   // Clean title from HTML tags (if some exist)
//     Value := FullTrim (Value);
//     showmessage ('Mese *' + Value + '*');
//     if Mese_pubblicazione <> '' then
//        Value := Mese_pubblicazione + ' - ' + Value;
//     end
  if ComicSeries = '15' then
     begin
     Value := TextBetween(Titolo_e_Periodicita, ',</font>', '<br>');
     showmessage ('Titolo e periodicita *' + Titolo_e_Periodicita + '*');
     showmessage ('Mesea *' + Value + '*');
     HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
     showmessage ('Meseb *' + Value + '*');
     HTMLRemoveTags(Value);   // Clean title from HTML tags (if some exist)
     showmessage ('Mesebc*' + Value + '*');
     Value := FullTrim (Value);
     showmessage ('Mesed *' + Value + '*');
     if Value = 'mensil' then
        Value := 'mensile';
     if Mese_pubblicazione <> '' then
        Value := Mese_pubblicazione + ' - ' + Value;
     end
  if (ComicSeries = '28') then
     begin
     Value := 'Maxi Tex';
     SetField(fieldSource, Value);   // Save serie to field Source
     end
  if (ComicSeries = '70') then
     begin
     Value := 'Almanacco del Giallo (Julia)';
     SetField(fieldSource, Value);   // Save serie to field Source
     end
  if (ComicSeries = '28')  or (ComicSeries = '70') then
     begin
     Value := TextBetween(DataPubbl, ',', '</font>');
     HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
     HTMLRemoveTags(Value);   // Clean title from HTML tags (if some exist)
     Value := FullTrim (Value);
//     showmessage ('Mese *' + Value + '*');
     if Mese_pubblicazione <> '' then
        Value := Mese_pubblicazione + ' - ' + Value;
     end
  SetField(fieldDirector, Value);   // Save periodicità to field Director
// ***************** fine periodicità
// Titolo tradotto
  Value := SaveValue;
  Value := TextBetween(Value, '<font face="Arial" size=2>', '</font>');   // Extract exact title from variable "SaveValue"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);   // Clean title from HTML tags (if some exist)
  Value := FullTrim (Value);
//  showmessage ('Value titolo *' + Value + '***');
  SetField(fieldTranslatedTitle, Value);   // Save title to field TranslatedTitle
// Beschreibung / Description / Storia
// struttura dei primi numeri
  Value := '';
  saveValue := '';
// Storia
  Value := TextBetween(Page, '<table width=100% cellspacing=0 cellpadding=0 border=0>', '</DIV>');   // Extract description part from variable "Page"
//  showmessage('value1 ' + Value);
  Value := TextBetween(Value, '<font face="Arial" size=2>', 'In questo numero:');   // Extract exact description from variable "Value" now
//  showmessage('value2 ' + Value);
//  Value := TextBetween(Value, '<font face="Arial" size=2>', '</font>');   // Extract exact description from variable "Value" now
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  saveValue := Value;
// Comments / In questo numero
  Value := TextBetween(Page, '<td width="50%" valign="bottom" ><font color="#0080C0" face="Verdana" size=1>', ' </td>'); // Extract description part from "Page"
//  showmessage (Value)
  Value := TextBetween(Value, '<strong>', '</strong>');   // Extract exact description from variable "Value" now
//  showmessage (Value)
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);
  if length(Value) > 0 then
     SetField(fieldComments, ('In questo numero: ' + Value));   // Save description to field Description
// struttura dei numeri successivi (es. 214)
  if length (saveValue) = 0 then
     begin
     Value := TextBetween(page, '<DIV VALIGN=TOP>', ' </td>');   // Extract description part from variable "Page"
//     showmessage('value3 ' + Value);
     Value := TextBetween(value, '<DIV VALIGN=TOP><font face="Arial" size=2>', '</font></DIV>');   // Extract description part from variable "Page"
     HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
     HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
//     showmessage('value4 ' + Value);
     if length (Value) < 2 then   // 2 as there must be crlf
        showError ('Errore. collana ' + getfield(fieldMedia) + ' n.' + getfield(fieldOriginaltitle) + '. Trama mancante');
     saveValue := Value;
     end
  Value := FullTrim (Value);
  SetField(fieldDescription, saveValue);   // Save description to field Description
//  showmessage ('descrizione ' + saveValue);
// Comments / In questo numero
  Value := TextBetween(Page, '<table width=100% cellspacing=0 cellpadding=0 border=0>', ' </td>'); // Extract description part from "Page"
//  showmessage (Value)
  Value := TextBetween(Value, 'In questo numero:', '</font>');   // Extract exact description from variable "Value" now
//  showmessage (Value)
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  if length(Value) > 0 then
     SetField(fieldComments, ('In questo numero: ' + Value));   // Save description to field Description
// fieldActors / Autori
  SaveValue := '';
  Value := '';
  Value := TextBetween(Page, 'Soggetto e sceneggiatura: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := 'Soggetto e sceneggiatura: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Soggetto: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := 'Soggetto: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Sceneggiatura: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := 'Sceneggiatura: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Disegni e copertina: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := saveValue + 'Disegni e copertina: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Disegni: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := saveValue + 'Disegni: ' + Value + crlf;
     end
  Value := '';
  Value := TextBetween(Page, 'Copertina: <b>', '</b>');   // Extract part from variable "Page"
  HTMLDecode(Value);   // Clean description from HTML codes (if some exist)
  HTMLRemoveTags(Value);
  Value := FullTrim (Value);   // Clean up the description
  if length(Value) > 0 then
     begin
     saveValue := saveValue + 'Copertina: ' + Value + crlf;
     end
  SetField(fieldActors, saveValue);   // Save description to field Actors
end; // *********************** End of procedure "AnalyzeScheda_speciale" *****************************************
Procedure Menu;
begin
      Repeat
      sw_serie := 'OK';
      case ComicSeries of
        'Tex',                           '1': ComicSeries :=  '1';
        'Almanacco del West',            '2': ComicSeries := '2';
        'Julia',                         '4': ComicSeries := '4';
        'Almanacco del West',            '7': ComicSeries := '7';
        'Zagor',                        '10': ComicSeries := '10';
        'Martin Mystère',               '13': ComicSeries := '13';
        'Nathan Never',                 '15': ComicSeries := '15';
        'Dylan Dog',                    '18': ComicSeries := '18';
        'Almanacco dell''avventura',    '25': ComicSeries := '25';
        'Maxi Tex',                     '28': ComicSeries := '28';
        'Almanacco della Fantascienza', '34': ComicSeries := '34';
        'Almanacco della Paura',        '36': ComicSeries := '36';
        'Almanacco dell''avventura',    '50': ComicSeries := '50';
        'Almanacco del Giallo',         '70': ComicSeries := '70';
      else
         begin
      PickTreeClear;
      PickTreeAdd('  (1) Tex',                                      '1');
      PickTreeAdd('  (2) Almanacco del West',                       '2');
      PickTreeAdd('  (4) Julia',                                    '4');
      PickTreeAdd('  (7) Almanacco del West (Tex)',                 '7');
      PickTreeAdd('(10) Zagor',                                     '10');
      PickTreeAdd('(13) Martin Mystère',                            '13');
      PickTreeAdd('(15) Nathan Never',                              '15');
      PickTreeAdd('(18) Dylan Dog',                                 '18');
      PickTreeAdd('(25) Almanacco dell''Avventura (Zagor)',         '25');
      PickTreeAdd('(28) Maxi Tex',                                  '28');
      PickTreeAdd('(34) Almanacco della Fantascienza',              '34');
      PickTreeAdd('(36) Almanacco della Paura',                     '36');
      PickTreeAdd('(50) Almanacco dell''Avventura (Mister No)',     '50');
      PickTreeAdd('(70) Almanacco del Giallo (Julia)',              '70');
      if PickTreeExec(ComicSeries) then
         ShowMessage('Series number is: ' + ComicSeries);
         sw_serie := 'error'
         end;
      end;
      until sw_serie = 'OK';
end;
// ***** Beginning of the script *****
begin
  if CheckVersion(3,5,0) then // Checks if Ant Movie Catalog version is 3.5.0 or higher
     begin
//      Input('www.sergiobonellieditore.it', 'Enter comic series:', ComicSeries); // Asks for comic series number
     ComicSeries := GetField(fieldMedia);
//     if ComicSeries = '' then
//     begin
//     showmessage ('trace2');
        menu;
//     end;
     ComicNumber := GetField(fieldOriginalTitle);
     if ComicNumber = '' then
       Input('www.sergiobonellieditore.it', ComicSeries + crlf + 'Enter comic number:', ComicNumber);
     If (ComicSeries = '1') or (ComicSeries = '10')or (comicSeries = '13') or (ComicSeries = '18')
     then
        begin
        ComicURL := 'http://www.sergiobonellieditore.it/auto/alborist?collana=' + ComicSeries + '&numero=' + ComicNumber + '&subnum=0'; // Build item URL
        Setfield(fieldURL, ComicURL);   // Save variable URL to field URL
        AnalyzePageAlborist(ComicURL); // Script hands over item URL and jumps to procedure AnalyzePageAlborist
        end
     If (ComicSeries = '2') or (comicSeries = '7') or (ComicSeries = '8') or (ComicSeries = '15') or (ComicSeries = '70')
        or (ComicSeries = '28') then
        begin
        ComicURL := 'http://www.sergiobonellieditore.it/auto/scheda_speciale?collana=' + ComicSeries + '&numero=' + ComicNumber + '&subnum=0'; // Build item URL
//      showmessage ('URL ' + ComicURL + ' *');
        Setfield(fieldURL, ComicURL);   // Save variable URL to field URL
        AnalyzePageScheda_speciale(ComicURL); // Script hands over item URL and jumps to procedure AnalyzePageScheda_speciale
//      Input('www.sergiobonellieditore.it', 'Enter comic number:', ComicNumber); // Asks for comic item number
//      ComicNumber := ComicSeries
        end
  end
  else
     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
    // If Checkversion fails end.
end.
Well, I'm not really sure what you are talking about. If I have a look on mesea, meseb, etc with series 15 / title 3 they don't contain any value, as variable value is empty.. 
This doesn't give any result as there is no ',</font>' on variable Titolo_e_Periodicita - but maybe you meant ';</font>' 
			
			
									
						
										
						Code: Select all
Value := TextBetween(Titolo_e_Periodicita, ',</font>', '<br>');FullTrim simply reads first character of a variable and checks if it is space (' '), tab (#9), or linebreak (#13#10) - as long as it finds one, it deletes this character. Same for the last character of the variable.fulvio53s03 wrote:Sorry, I need your help as I don't understand very well the function 'FullTrim'.
- 
				fulvio53s03
 - Posts: 781
 - Joined: 2007-04-28 05:46:43
 - Location: Italy
 
@Bad4U: sorry for the mistake. The right code was the one you suggested.
If I use:
Value := Fulltrim(Value);
I obtain to have the result 'mensile' trucated to 'mensil' (in total 6 chars).
If I use:
Fulltrim(Value);
I obtain 'mensile ' with a lot of special characters (in total 87 chars) at the end of the field.
To try what I'm saying, you can use:
instead of:
What is the difference in using:
Value := FullTrim(Value)
instead of:
Fulltrim(Value)
?
Can you suggest me a way to see the ascii (or ansi?) code of special characters extracted?
Thanks again.
			
			
									
						
										
						If I use:
Value := Fulltrim(Value);
I obtain to have the result 'mensile' trucated to 'mensil' (in total 6 chars).
If I use:
Fulltrim(Value);
I obtain 'mensile ' with a lot of special characters (in total 87 chars) at the end of the field.
To try what I'm saying, you can use:
Code: Select all
     showmessage ('Mesebc*' + Value + '*');
     FullTrim (Value);
     showmessage ('Mesed *' + Value + '*');
     showmessage ('length Mesed *' + IntToStr(Length(Value)) + '*');
     Value := FullTrim (Value);
     showmessage ('Mesee *' + Value + '*');
     showmessage ('length Mesee *' + IntToStr(Length(Value)) + '*');
Code: Select all
     showmessage ('Mesebc*' + Value + '*');
     Value := FullTrim (Value);
     showmessage ('Mesed *' + Value + '*');
Value := FullTrim(Value)
instead of:
Fulltrim(Value)
?
Can you suggest me a way to see the ascii (or ansi?) code of special characters extracted?
Thanks again.
FullTrim(Value) always does the same - it calls the external function FullTrim from StringUtils1.pas and hands over variable Value. Now the function deletes the spaces, tabs and linebreaks and writes the result to variable Result (still within StringUtils1). After that you need to hand over the result (= variable Result) back to your variable Value ( Value := FullTrim(Value); ).. else the changes from FullTrim just get lost again ( FullTrim(Value); ).fulvio53s03 wrote:What is the difference in using:
Value := FullTrim(Value)
instead of:
Fulltrim(Value)
?
Can you suggest me a way to see the ascii (or ansi?) code of special characters extracted?
On your second question - I don't think it's possible.
But you are always using ShowMessage to stop the script and check for variables, while it's a lot easier to use breakpoints and variable watchlist. Maybe I'm wrong, but is it possible you don't know about that yet ? When you are on AMC script editor, you can click on the left side of every line, so that the line is marked red, now e.g. mark
Code: Select all
     showmessage ('Mesebc*' + Value + '*');
     FullTrim (Value);
     showmessage ('Mesed *' + Value + '*');
     showmessage ('length Mesed *' + IntToStr(Length(Value)) + '*');
     Value := FullTrim (Value);
     showmessage ('Mesee *' + Value + '*');
     showmessage ('length Mesee *' + IntToStr(Length(Value)) + '*'); this part of the code red (or hit F5 on every line). Then set mousecursor on the variable (= the word) "Value", and click on the icon "Add variable watch" (or Ctrl+F5). A watchlist opens with this variable inside and now you can easily see how the variable changes when you run the script from editor. You can add more variables to the watchlist and you might want to drag and drop the watchlist to the bottom of the screen, so that you can better see long variables. When the script stops at a breakpoint you can rightclick on every variable and choose "Evaluate" to see full content.
Sorry if I should be wrong and you should have known about that before. Maybe then it's useful for someone else
- 
				fulvio53s03
 - Posts: 781
 - Joined: 2007-04-28 05:46:43
 - Location: Italy
 
@Bad4U: don't worry about every suggestion: I'm really a beginner and I ignore a lot of things: every information is good for me (and maybe for others)!
Reading your answer I understand my wrong use of 'FullTrim' with no result destination.
About the second question: sorry but I'm (almost)sure!
... very strange...
I hope you will ry if you have a few free moments, please.
ciao.
			
			
									
						
										
						Reading your answer I understand my wrong use of 'FullTrim' with no result destination.
About the second question: sorry but I'm (almost)sure!
... very strange...
I hope you will ry if you have a few free moments, please.
ciao.
To see the code of a character :
ShowMessage(IntToStr(Ord(C)));
where C is the Char variable.
or
ShowMessage(IntToStr(Ord(StrGet(S, N))));
to see N-th character of S string.
			
			
													ShowMessage(IntToStr(Ord(C)));
where C is the Char variable.
or
ShowMessage(IntToStr(Ord(StrGet(S, N))));
to see N-th character of S string.
					Last edited by antp on 2008-10-22 12:31:47, edited 1 time in total.