Hello everyone,
I am working with Mod Harbour and have noticed that in my JavaScript code \\n causes a line break,
while \n leads to an error. Is this a known behavior in Mod Harbour, or could there be another reason for it?
Has anyone had similar experiences or can give me a tip on how to handle this?
Best regards,
Otto
Different Processing of Escape Characters in Mod Harbour
Different Processing of Escape Characters in Mod Harbour
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
- Antonio Linares
- Site Admin
- Posts: 42268
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Different Processing of Escape Characters in Mod Harbour
Dear Otto,
Could you please provide a small code example to review it ?
thanks
Could you please provide a small code example to review it ?
thanks
Re: Different Processing of Escape Characters in Mod Harbour
Dear Antonio,
"\n" -> "\\n" OK
Here is my test code. If I change the line to:
keysString += key + ": " + value + "\\n";
it works fine.
If I run it with keysString += key + ": " + value + "\n"; in HTML, all works fine.
Best regards,
Otto
"\n" -> "\\n" OK
Here is my test code. If I change the line to:
keysString += key + ": " + value + "\\n";
it works fine.
If I run it with keysString += key + ": " + value + "\n"; in HTML, all works fine.
Best regards,
Otto
Code: Select all | Expand
REQUEST DBFCDX
REQUEST DBFFPT
function main
TEMPLATE
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Key Anzeiger</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<div class="container mt-5">
<h2>oRequest Schlüssel Anzeiger</h2>
<button id="showKeysBtn" class="btn btn-primary">Schlüssel anzeigen</button>
<ul id="keysList" class="list-group mt-3">
</ul>
</div>
<script>
$(document).ready(function() {
var oRequest = {
"FILEXPLORE": "Wert1",
"ANOTHERKEY": "Wert2",
"YETANOTHERKEY": "Wert3"
// Weitere Schlüssel...
};
$('#showKeysBtn').click(function() {
var keysString = "";
$.each(oRequest, function(key, value) {
keysString += key + ": " + value + "\n";
});
alert(keysString);
});
});
</script>
</body>
</html>
ENDTEXT
return
INIT PROCEDURE PrgInit
SET CENTURY ON
SET EPOCH TO YEAR(DATE())-98
SET DELETED ON
SET EXCLUSIVE OFF
REQUEST HB_Lang_DE
HB_LangSelect("DE")
SET DATE TO GERMAN
rddsetdefault( "DBFCDX" )
EXTERN DESCEND
RETURN
//----------------------------------------------------------------------------//
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
Re: Different Processing of Escape Characters in Mod Harbour
Dear Otto,
I think \n leads to an error because the backslash is an escape character in javascript.
according to chatgpt ... when used in a string, the \ expects to be followed by another character to form the escape sequence.
So \\n is needed in this case I suppose.
kind regards
ruth
I think \n leads to an error because the backslash is an escape character in javascript.
according to chatgpt ... when used in a string, the \ expects to be followed by another character to form the escape sequence.
So \\n is needed in this case I suppose.
kind regards
ruth
Re: Different Processing of Escape Characters in Mod Harbour
Dear Ruth,
the problem is that \n in JS works in a html file but not in a mod harblur prg file.
Please copy the HTML part into a HTML file and test.
Best regards,
Otto
the problem is that \n in JS works in a html file but not in a mod harblur prg file.
Please copy the HTML part into a HTML file and test.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
Re: Different Processing of Escape Characters in Mod Harbour
...oh...yes...I see and I can confirm this...
next time I will also read the heading of the forum-post -> sorry
kind regards
ruth
next time I will also read the heading of the forum-post -> sorry
kind regards
ruth