Problem with linebreak

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
Post Reply
allright
Posts: 4
Joined: 2007-11-10 14:22:20

Problem with linebreak

Post by allright »

Hey

I'm trying to import a description from a web page, that is a little trikcy.

The web page code look like this:
--
Efter befrielsen må Danmark nødtvungent vælge side i en ny
verdensorden. Frihed med rationering, lynchstemning og et besat Bornholm.
Kongen er død – kongen leve. SAS, sortbørs og stof i lange baner.
Marshallhjælp og ministermøder. Påskekrise, kvinder med pibekrave og en kriminel edderkop.--

It translate into: Efter befrielsen må Danmark nødtvungent vælge side i en nyverdensorden. Frihed med rationering, lynchstemning og et besat Bornholm.Kongen er død – kongen leve. SAS, sortbørs og stof i lange baner.Marshallhjælp og ministermøder. Påskekrise, kvinder med pibekrave og en kriminel edderkop.--


As you can see I need a "space" after verdensorden, after Bornholm, and after baner.

I've tried with this code, but without luck:
Value := StringReplace(Value, #13#10, ' ');

Can anybody direct me ind the right direction?


CU
JJ
Last edited by allright on 2007-12-26 23:03:41, edited 1 time in total.
bad4u
Posts: 1148
Joined: 2006-12-11 22:54:46

Post by bad4u »

Could you please give a link to the page ?
allright
Posts: 4
Joined: 2007-11-10 14:22:20

Post by allright »

Yes, sorry I didn't include it in the first letter.

http://www.dvdoo.dk/dvd-film/danmarks-h ... _16513.php


CU
JJ
bad4u
Posts: 1148
Joined: 2006-12-11 22:54:46

Post by bad4u »

I did a short test with this code and it works for me (to test it, just copy it into a new script):

Code: Select all

program test;

const
  CRLF = #13#10;
uses
  StringUtils1;
var
  Value: String;

begin
  Value := GetPage(URLEncode('http://www.dvdoo.dk/dvd-film/danmarks-historie-1946-949-nye-forbindelser_16513.php'));
  Value := TextBetween(Value, '1946-1949: Efter', '<br><br>');
  Value := StringReplace(Value, #13#10, ' ');
  setField(fieldDescription, Value);
end.
(imported text will be saved to description field, first word Efter is missing to keep it simple..)

You can pause the script and evaluate the variable Value, so you will see that the linebreaks are changed to spaces. If you cannot find what's going wrong, you should post your script here (or maybe send it via private message).
allright
Posts: 4
Joined: 2007-11-10 14:22:20

Post by allright »

Hey

Ohh, me bad, and you're absolutly right, its working now, thank you very much.


CU
JJ
Post Reply