Page 1 of 1

Some issues with filter and replace

Posted: Fri May 23, 2014 8:06 am
by [-hh]
Presumably a lot of 'problems' will arise from changed text handling, so may I start with this simple filtering and replacement? I canĀ“t locate the critical point more closely. Here is an until (including) 6.7 dp4 working and easy to read script:

Code: Select all

on mouseUp
  put url("http://www.wallpaperdownloader.com/bing-wallpaper/archive/all/all/1/datedes/") into u
  filter u with ("*<img class=" &quote& "thumbnail" &quote& " src=*")
  replace "<img class=" &quote& "thumbnail" &quote& " src=" &quote with empty in u
  replace quote& " alt=" &quote& "Bing Images - " with "=" in u
  replace quote& " />"&numTochar(13) with empty in u
  replace tab with empty in u
  repeat while CR&CR is in u
    replace CR&CR with CR in u
  end repeat
  put u after s
  if char 1 of s is CR then delete char 1 of s
  replace "http://www.bing.com/az/hprichbg/rb/" with empty in s
  replace "_1366x768.jpg" with ".JPG" in s
  put 0 into j; set itemDelimiter to "="
  repeat for each line l in s
    add 1 to j
    put CR & j && (item 2 of l) &"="& (item 1 of l) after t
  end repeat
  set itemDelimiter to comma
  if char 1 of t is CR then delete char 1 of t
  put t into fld "Bing"
end mouseUp
This yields up to 6.7 (dp4) currently exactly these 11 lines:

1 Angel Oak=AngelOak_EN-AU8619425077.JPG
2 King Penguin And Antarctic Seal=KingPenguinAndAntarcticSeal_ZH-CN9407874973.JPG
3 Petra Jordan=PetraJordan_DE-DE9641813596.JPG
4 London Eye=LondonEye_EN-AU9512752066.JPG
5 Seal Pup And Mother=SealPupAndMother_ZH-CN9609234410.JPG
6 Frauenchiemsee=Frauenchiemsee_DE-DE9233413833.JPG
7 Iled Olonne=IledOlonne_FR-FR9677259144.JPG
8 Opium Poppy=OpiumPoppy_ZH-CN8625759628.JPG
9 Sask Moon=SaskMoon_EN-CA13461630647.JPG
10 Tiger Eye=TigerEye_EN-AU11507535552.JPG
11 Herzliya Israel=HerzliyaIsrael_ZH-CN12724786713.JPG

With LC 7.0 dp3 this gives 355 lines (see yourself).

Yes there is "numTo..." in, but I tried also numToByte, numToNativeChar, and tried 10 as arg instead of 13. No success.

Re: Some issues with filter and replace

Posted: Fri May 23, 2014 8:45 am
by Simon
Yes, 7.0 dp3 is returning a different page from
http://www.wallpaperdownloader.com/bing ... 1/datedes/

6 returns 1094 lines
7 returns 692 lines
Is the user agent different between them?

Simon
Edit; Nope user agent is the same from both.
Edit2; Because we are talking about unicode this I guess is something
First different line of lc 6/7
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> (LC6)
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252 (LC7)
Oh yeah.. testing on Win 7 machine.

Re: Some issues with filter and replace

Posted: Fri May 23, 2014 9:01 am
by [-hh]
Hi Simon,
the url, put into variable u yields for me still the same with 6.7 and 7.0. The problem will probably arise with filter/replace.

I have to add, that I used for testing the first url variable Mac/Safari. You are probably using Win7/IE ?

Hermann

I tested this script essentially on different platforms (Mac-Linux-Win) with different LC versions. See runInfo for the latest stack (#17) of the RaspberryPi collection and in this stack the button "GetCurrPODList". It works, but NOT with LC 7.0 ...

Re: Some issues with filter and replace

Posted: Fri May 23, 2014 9:24 am
by Simon
hmmm... using just IE, Chrome, FireFox browsers I get 592 lines.
LiveCode gives me the different number of lines in u.

Simon

Re: Some issues with filter and replace

Posted: Fri May 23, 2014 9:46 am
by [-hh]
Simon,

you are right with insisting on that. What I really have in a variable and what I see in a field, especially now in 7.0, may be different. I should first check for this.

And: What happens, if one copies text from LC 6.7 and earlier to LC 7.0?
And: What happens, if one copies a text field, filled up with html code, from LC 6.7 and earlier to LC 7.0?

And: What happens in the opposite directions? Are there replacements that aren't described in detail until now?

Hermann

Re: Some issues with filter and replace

Posted: Fri May 23, 2014 11:40 am
by benjibeaumont
This is an excellent report. I've created a bug report in the quality control center here:

http://quality.runrev.com/show_bug.cgi?id=12489

Warm regards and thanks for your help in creating a recipe.

Ben

Re: Some issues with filter and replace

Posted: Fri May 23, 2014 12:01 pm
by livecodeali
Thanks for this report. It was due to an slight oversight in an optimisation of the filter command for native strings in 7.0, but is now fixed.

Kind Regards,
Ali