Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 9:02 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Ini-file variable ignores newlines
PostPosted: June 8th, 2007, 11:34 am 
Offline

Joined: July 7th, 2005, 10:44 am
Posts: 16
Because of a multilangual publication I am trying to use an ini-file for all texts, so that I can swap language easily.
In all my textfields I put variables which will be automatically filled.

Now this works great except for one thing:
"This is a test\nwith a newline"
actually will be put into the variable in the textfield as
"This is a test\nwith a newline"

In other words: the newline is ignored by Opus.
Is there a way to avoid this? Or is there another way people would do this multilangual thing? I wouldn't want to make use of the database, because I think it's easier to edit a text-file instead.

Gr,
Paul


Top
 Profile  
 
 Post subject:
PostPosted: June 8th, 2007, 1:43 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
How odd, I'd have thought that it would have keep the paragraph breaks. I would have also hoped that the JS replace command might have solved the problem, but can't make it work in Opus and there doesn't seem to be an OS alternative :-(

You can try using this bit of script instead:

var myCount = 0
//Reads data from INI into a string
var IN = GetINISectionData("C:\\test.ini", "1")

//Splits string data into an array using the pipe for demarking
//NOTE you can't use \n yet
var mySplit = IN.split('|')

//Creates a loop that reads through the array
for (myCount == 0; myCount < mySplit.length; myCount++)
{
//Creates a new string called myINI that inserts the \n for paragraph breaks
myINI = myINI + mySplit[myCount] + '\n\n'
}

Basically, it splits the INI data into paragraphs based on the pipe as a demarker (you can't use \n with the split command) and then rebuilds the string from the split pieces insert a double \n where the pipe (|) symbol was.

Mack

Hope this helps.

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: June 8th, 2007, 3:01 pm 
Offline

Joined: July 7th, 2005, 10:44 am
Posts: 16
Great, thank you :)
This works fine!

We even simplified it by the way:

Code:
function getMultiLine_iniData(iniPath, iniPart, iniVar)
{
   //Reads data from INI into a string
   var IN = GetINIFileData(iniPath, iniPart, iniVar);
   
                //Replace pipe for new-line
   IN = str_replace('|', '\n', IN);
   
   return IN;
}

function str_replace(findThis, replaceWith, str) {
   str = ""+str+""
   return str.split(findThis).join(replaceWith);
}


Top
 Profile  
 
 Post subject:
PostPosted: June 8th, 2007, 3:07 pm 
Offline

Joined: July 7th, 2005, 10:44 am
Posts: 16
Oh btw:
This way we can even use \n in the ini (if we want):

Code:
IN = str_replace('\\n', '\n', IN);


Top
 Profile  
 
 Post subject:
PostPosted: June 8th, 2007, 4:30 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
How, with such a neat solution, did you get stuck in the first place :-)

I'd forgotten about the join command. Most useful.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: June 11th, 2007, 8:20 am 
Offline

Joined: July 7th, 2005, 10:44 am
Posts: 16
Hehe :) Yeah I could probably have thought of that myself. But I didn't :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 26 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group