English > Scripts and Templates
AllMovie+ script: Including data for custom fields
rick.ca:
No and no. Hopefully, nostra can help.
nostra:
You can use the StringReplace function to replace any type of Line Break tags and characters in proper ones (#13#10)
rick.ca:
You under estimate the degree of my helplessness. :-[
I thought of that, but I can't figure out how to get the string without using TextBetween. If I do, the tags are stripped, and there's nothing to replace. :-\
nostra:
Alright then:
1. Find the position of starting tag using the PosFrom or Pos function and save it to a variable
2. Find the position of ending tag using the PosFrom or Pos function and save it to another variable
3. Use the Copy function to retrieve the text between starting tag and ending tag
4. Use StringReplace function to remove unneeded substrings or replace substrings
rick.ca:
I'm still not getting anywhere. Following is my attempt to do as you suggest...
--- Code: ---procedure ParseReview(HTML : String);
var
curPos, endPos : Integer;
TmpStr, TmpStr1, TmpStr2 : String;
begin
curPos := Pos('<div id="results-table">', HTML);
endPos := curPos
if curPos < 1 then
Exit;
//Review
curPos := PosFrom('<td colspan="2">', HTML, curPos);
endPos := PosFrom('</p></td>', HTML, curPos);
TmpStr := Copy(HTML, curPos, EndPos - curPos);
TmpStr1 := StringReplace(TmpStr, ' -- ', '—', True, True, False);
TmpStr2 := StringReplace(TmpStr1, ' --- ', '—', True, True, False);
TmpStr := StringReplace(TmpStr2, '--', '—', True, True, False);
TmpStr1 := StringReplace(TmpStr, '<br />', #13#10, True, True, False);
TmpStr2 := RemoveTags(TmpStr1, True);
AddCustomFieldValueByName('Review', TmpStr2);
end;
--- End code ---
The TmpStr1 := StringReplace(TmpStr, '<br />', #13#10, True, True, False); line does nothing. It seems the Copy function removes the <br /> tags, so there's nothing to replace. And even if there were something to replace, the #13#10 doesn't seem to be recognized by the function.
The result of the Copy function is a set of four CRLF between paragraphs. This, of course, results in three blank lines instead of one, as desired.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version