Different Processing of Escape Characters in Mod Harbour

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!

Different Processing of Escape Characters in Mod Harbour

Postby Otto » Wed Jan 31, 2024 4:10 am

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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Different Processing of Escape Characters in Mod Harbour

Postby Antonio Linares » Wed Jan 31, 2024 5:59 am

Dear Otto,

Could you please provide a small code example to review it ?

thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Different Processing of Escape Characters in Mod Harbour

Postby Otto » Wed Jan 31, 2024 8:46 am

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


Code: Select all  Expand view

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
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Different Processing of Escape Characters in Mod Harbour

Postby Ruth » Wed Jan 31, 2024 1:38 pm

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
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm

Re: Different Processing of Escape Characters in Mod Harbour

Postby Otto » Wed Jan 31, 2024 4:55 pm

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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Different Processing of Escape Characters in Mod Harbour

Postby Ruth » Wed Jan 31, 2024 6:43 pm

...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
User avatar
Ruth
 
Posts: 169
Joined: Fri Dec 07, 2007 1:26 pm


Return to mod_harbour

Who is online

Users browsing this forum: No registered users and 6 guests