<p>All work and no play makes Jack a dull boy</p> !(=^..^=)!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: <p>All work and no play makes Jack a dull boy</p> !(=^..
The "fast LC 6"-version (from above) works of course also with LC 7/8.
[But LC 7/8 needs up to 50% more time than LC 6.]
I hope that you will show us your artwork when finished.
[But LC 7/8 needs up to 50% more time than LC 6.]
I hope that you will show us your artwork when finished.
shiftLock happens
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: <p>All work and no play makes Jack a dull boy</p> !(=^..
With both methods here taking only microseconds the speed difference hardly matters much, but FWIW exploring other ways to solve this lends itself to a very lazy option:
Code: Select all
on mouseUp
put fld 1 into tHtml
put 1000 into n
--
put the millisecs into t
repeat n
put ReformatHtml1(tHtml) into r1
end repeat
put the millisecs - t into t1
--
put the millisecs into t
repeat n
put ReformatHtml2(tHtml) into r2
end repeat
put the millisecs - t into t2
--
put "Method 1: "& (t1/n)&" ms" &cr \
& "Method 2: "& (t2/n) &" ms" &cr \
& "Same result?: "& (r1=r2)
end mouseUp
function ReformatHtml1 pHtml
put the num of lines of pHtml into n1
put numToChar(1) into c1
put numToChar(2) into c2
replace "<p>" with c1 in pHTml
replace "</p>" with c2 in pHtml
set linedel to c1; set itemdel to c2
put line 1 of pHtml into txt2 --> we start AFTER first "<p>"
repeat for each line L in (line 2 to -1 of pHtml)
replace cr with space in item 1 of L
replace c2 with "</p>" in L
put "<p>" & L after txt2
end repeat
if last char of txt2 = cr then delete last char of txt2
return txt2
end ReformatHtml1
function ReformatHtml2 pHtml
replace cr with space in pHtml
replace "> <" with ">"&cr&"<" in pHtml
if last char of pHtml = space then delete last char of pHtml
return pHTml
end ReformatHtml2
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: <p>All work and no play makes Jack a dull boy</p> !(=^..
Your code does the same for MariaSole's very special sample input.
But you overlooked the more general objective:
Replace cr by space between each opening "<p>" and closing "</p>".
Nowhere else, everything else should remain the same no matter the chars.
So simply insert a single return around the midth of the first line and/or the last line of her sample input to see your code fail. You don't know where the return you replaced by space was located ...
But you overlooked the more general objective:
Replace cr by space between each opening "<p>" and closing "</p>".
Nowhere else, everything else should remain the same no matter the chars.
So simply insert a single return around the midth of the first line and/or the last line of her sample input to see your code fail. You don't know where the return you replaced by space was located ...
shiftLock happens
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: <p>All work and no play makes Jack a dull boy</p> !(=^..
Thanks. Seems I missed a later post; my understand of the desired output was based on her "What I'd like to see" block here:
http://forums.livecode.com/viewtopic.ph ... 79#p144411
Either way, at a few microseconds per run just about any working method discussed in this thread seems quite good.
http://forums.livecode.com/viewtopic.ph ... 79#p144411
Either way, at a few microseconds per run just about any working method discussed in this thread seems quite good.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: <p>All work and no play makes Jack a dull boy</p> !(=^..
Hi Mariasole,Mariasole wrote:Grazie [-hh]!![]()
Coming a bit late to the party, being busy on another planet...
Concerning your regex, you jumped into 2 holes:
1) copy/paste a regex from a website to LC won't work all the time.
There are few things to consider doing this...
2) Considering 1) is resolved, then you hit a LC bug.
Anyway, you had your hero ( Hermann) who came to the rescue.
Good luck with your porject,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: <p>All work and no play makes Jack a dull boy</p> !(=^..
Hi Thierry!
Merci pour ton épiphanie, je pense que le X sur la fenêtre avec la lumière ne fonctionne plus!
While you were on the road for some kind of planets, fortunately the brave Hermann came to save me!
How would I do without you, my knights!
Thank you for signing remembered and ... if you revise the X on the window, you think I'm calling you (if you want, instead of X, I will write the string (?:^((?:X))))
Un bacio!
Mariasole
(=^..^=)
Merci pour ton épiphanie, je pense que le X sur la fenêtre avec la lumière ne fonctionne plus!
While you were on the road for some kind of planets, fortunately the brave Hermann came to save me!
How would I do without you, my knights!

Thank you for signing remembered and ... if you revise the X on the window, you think I'm calling you (if you want, instead of X, I will write the string (?:^((?:X))))

Un bacio!
Mariasole
(=^..^=)
"I'm back" - The Cyberdyne Systems Model 101 Series 800 Terminator