Using a Javascript on .lasso page

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Using a Javascript on .lasso page

Duane Hannan
I’m designing a new web page (and learning html/css) and I want to include an images slide show on the page.  The code, which includes some Javascript, comes from a copy/paste from w3schools.com <http://w3schools.com/>.  Their code works fine on a simple .html page, but when I add some simple lasso search-a-database-and-show-the-results code and switch the page’s suffix to .lasso, the slide show images disappear.

Sorry about my novice-ness, but does anyone have any suggestions?  It’s pretty clear that lasso doesn’t want to process the java code on the page.  I’ve tried putting the slide show <script> stuff in the body at the bottom, which w3schools.com <http://w3schools.com/> suggests, in the head, and in the .css file.  All no go.  I’ve tried changing <script> to <script type="text/JavaScript”> and putting it in the head and where w3schools.com <http://w3schools.com/> suggest (at the end of the body).  All no go.

Below is the page’s code.lasso

Much appreciated,

Duane Hannan
WWG Schools

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {box-sizing: border-box;}
body {font-family: Verdana, sans-serif;}
.mySlides {display: none;}
img {vertical-align: middle;}

/* Slideshow container */
.slideshow-container {
  max-width: 1000px;
  position: relative;
  margin: auto;
}

/* Caption text */
.text {
  color: #f2f2f2;
  font-size: 15px;
  padding: 8px 12px;
  position: absolute;
  bottom: 8px;
  width: 100%;
  text-align: center;
}

/* Number text (1/3 etc) */
.numbertext {
  color: #f2f2f2;
  font-size: 12px;
  padding: 8px 12px;
  position: absolute;
  top: 0;
}

/* The dots/bullets/indicators */
.dot {
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}

.active {
  background-color: #717171;
}

/* Fading animation */
.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 1.5s;
  animation-name: fade;
  animation-duration: 1.5s;
}

@-webkit-keyframes fade {
  from {opacity: .4}
  to {opacity: 1}
}

@keyframes fade {
  from {opacity: .4}
  to {opacity: 1}
}

/* On smaller screens, decrease text size */
@media only screen and (max-width: 300px) {
  .text {font-size: 11px}
}
</style>
</head>
<body>

<h2>Automatic Slideshow</h2>
<p>Change image every 2 seconds:</p>

<div class="slideshow-container">

<div class="mySlides fade">
  <div class="numbertext">1 / 3</div>
  <img src="images/MenuBand.jpg" style="width:100%">
  <div class="text">Caption Text</div>
</div>

<div class="mySlides fade">
  <div class="numbertext">2 / 3</div>
  <img src="images/MenuBand.jpg" style="width:100%">
  <div class="text">Caption Two</div>
</div>

<div class="mySlides fade">
  <div class="numbertext">3 / 3</div>
  <img src="images/MenuBand.jpg" style="width:100%">
  <div class="text">Caption Three</div>
</div>

</div>
<br>

<div style="text-align:center">
  <span class="dot"></span>
  <span class="dot"></span>
  <span class="dot"></span>
</div>

<script>
var slideIndex = 0;
showSlides();

function showSlides() {
    var i;
    var slides = document.getElementsByClassName("mySlides");
    var dots = document.getElementsByClassName("dot");
    for (i = 0; i < slides.length; i++) {
       slides[i].style.display = "none";  
    }
    slideIndex++;
    if (slideIndex > slides.length) {slideIndex = 1}    
    for (i = 0; i < dots.length; i++) {
        dots[i].className = dots[i].className.replace(" active", "");
    }
    slides[slideIndex-1].style.display = "block";  
    dots[slideIndex-1].className += " active";
    setTimeout(showSlides, 2000); // Change image every 2 seconds
}
</script>

[inline:-search, -database='xxxxxxx', -table='xxxxxxxx', -sortfield='EventDate', -sortorder='descending', -maxrecords=3]
                [records]
                        [field:'Event'] [field:'School']<br>
                [/records]
        [/inline]

</body>
</html>




#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Using a Javascript on .lasso page

Jolle Carlestam-2

>
> [slideIndex-1]

This piece, and all other places with square brackets are interpreted as Lasso code. You need to protect that from happening.
The technique to accomplish that varies. Is this Lasso 8.x or 9.x?

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Using a Javascript on .lasso page

John Morris-3
In reply to this post by Duane Hannan
[] in java is an array, and in lasso [] is a processing block.

I woudl move your javascript code to a seperate file and include it in the html.

- John Morris
[hidden email]
On Jul 23, 2018, 12:20 PM -0500, Duane Hannan <[hidden email]>, wrote:

> I’m designing a new web page (and learning html/css) and I want to include an images slide show on the page. The code, which includes some Javascript, comes from a copy/paste from w3schools.com <http://w3schools.com/>. Their code works fine on a simple .html page, but when I add some simple lasso search-a-database-and-show-the-results code and switch the page’s suffix to .lasso, the slide show images disappear.
>
> Sorry about my novice-ness, but does anyone have any suggestions? It’s pretty clear that lasso doesn’t want to process the java code on the page. I’ve tried putting the slide show <script> stuff in the body at the bottom, which w3schools.com <http://w3schools.com/> suggests, in the head, and in the .css file. All no go. I’ve tried changing <script> to <script type="text/JavaScript”> and putting it in the head and where w3schools.com <http://w3schools.com/> suggest (at the end of the body). All no go.
>
> Below is the page’s code.lasso
>
> Much appreciated,
>
> Duane Hannan
> WWG Schools
>
> <!DOCTYPE html>
> <html>
> <head>
> <meta name="viewport" content="width=device-width, initial-scale=1">
> <style>
> * {box-sizing: border-box;}
> body {font-family: Verdana, sans-serif;}
> .mySlides {display: none;}
> img {vertical-align: middle;}
>
> /* Slideshow container */
> .slideshow-container {
> max-width: 1000px;
> position: relative;
> margin: auto;
> }
>
> /* Caption text */
> .text {
> color: #f2f2f2;
> font-size: 15px;
> padding: 8px 12px;
> position: absolute;
> bottom: 8px;
> width: 100%;
> text-align: center;
> }
>
> /* Number text (1/3 etc) */
> .numbertext {
> color: #f2f2f2;
> font-size: 12px;
> padding: 8px 12px;
> position: absolute;
> top: 0;
> }
>
> /* The dots/bullets/indicators */
> .dot {
> height: 15px;
> width: 15px;
> margin: 0 2px;
> background-color: #bbb;
> border-radius: 50%;
> display: inline-block;
> transition: background-color 0.6s ease;
> }
>
> .active {
> background-color: #717171;
> }
>
> /* Fading animation */
> .fade {
> -webkit-animation-name: fade;
> -webkit-animation-duration: 1.5s;
> animation-name: fade;
> animation-duration: 1.5s;
> }
>
> @-webkit-keyframes fade {
> from {opacity: .4}
> to {opacity: 1}
> }
>
> @keyframes fade {
> from {opacity: .4}
> to {opacity: 1}
> }
>
> /* On smaller screens, decrease text size */
> @media only screen and (max-width: 300px) {
> .text {font-size: 11px}
> }
> </style>
> </head>
> <body>
>
> <h2>Automatic Slideshow</h2>
> <p>Change image every 2 seconds:</p>
>
> <div class="slideshow-container">
>
> <div class="mySlides fade">
> <div class="numbertext">1 / 3</div>
> <img src="images/MenuBand.jpg" style="width:100%">
> <div class="text">Caption Text</div>
> </div>
>
> <div class="mySlides fade">
> <div class="numbertext">2 / 3</div>
> <img src="images/MenuBand.jpg" style="width:100%">
> <div class="text">Caption Two</div>
> </div>
>
> <div class="mySlides fade">
> <div class="numbertext">3 / 3</div>
> <img src="images/MenuBand.jpg" style="width:100%">
> <div class="text">Caption Three</div>
> </div>
>
> </div>
> <br>
>
> <div style="text-align:center">
> <span class="dot"></span>
> <span class="dot"></span>
> <span class="dot"></span>
> </div>
>
> <script>
> var slideIndex = 0;
> showSlides();
>
> function showSlides() {
> var i;
> var slides = document.getElementsByClassName("mySlides");
> var dots = document.getElementsByClassName("dot");
> for (i = 0; i < slides.length; i++) {
> slides[i].style.display = "none";
> }
> slideIndex++;
> if (slideIndex > slides.length) {slideIndex = 1}
> for (i = 0; i < dots.length; i++) {
> dots[i].className = dots[i].className.replace(" active", "");
> }
> slides[slideIndex-1].style.display = "block";
> dots[slideIndex-1].className += " active";
> setTimeout(showSlides, 2000); // Change image every 2 seconds
> }
> </script>
>
> [inline:-search, -database='xxxxxxx', -table='xxxxxxxx', -sortfield='EventDate', -sortorder='descending', -maxrecords=3]
> [records]
> [field:'Event'] [field:'School']<br>
> [/records]
> [/inline]
>
> </body>
> </html>
>
>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
> the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to <[hidden email]>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Using a Javascript on .lasso page

Jolle Carlestam-2
In reply to this post by Jolle Carlestam-2

> 23 juli 2018 kl. 19:26 skrev Jolle Carlestam <[hidden email]>:
>
>
>>
>> [slideIndex-1]
>
> This piece, and all other places with square brackets are interpreted as Lasso code. You need to protect that from happening.
> The technique to accomplish that varies. Is this Lasso 8.x or 9.x?

One way, make into a string.

['[slideIndex-1]']
If you use this method make sure you escape any single quotes inside the string.

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Using a Javascript on .lasso page

Duane Hannan
In reply to this post by Jolle Carlestam-2
Thanks for you response.  --Lasso 8.6.3.

Duane



> On Jul 23, 2018, at 12:26 PM, Jolle Carlestam <[hidden email]> wrote:
>
>
>>
>> [slideIndex-1]
>
> This piece, and all other places with square brackets are interpreted as Lasso code. You need to protect that from happening.
> The technique to accomplish that varies. Is this Lasso 8.x or 9.x?
>
> HDB
> Jolle
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Using a Javascript on .lasso page

Steffan A. Cline
In reply to this post by Duane Hannan
If you wrap your JS code in <!— and —> Lasso will not execute your code inside it.

<script type=“text/javascript”><!—
Your JS using [ ] will be ignored by Lasso
—></script>


Thanks,
Steffan Cline
[hidden email]
602-793-0014

> On Jul 23, 2018, at 10:20 AM, Duane Hannan <[hidden email]> wrote:
>
> I’m designing a new web page (and learning html/css) and I want to include an images slide show on the page.  The code, which includes some Javascript, comes from a copy/paste from w3schools.com <http://w3schools.com/>.  Their code works fine on a simple .html page, but when I add some simple lasso search-a-database-and-show-the-results code and switch the page’s suffix to .lasso, the slide show images disappear.
>
> Sorry about my novice-ness, but does anyone have any suggestions?  It’s pretty clear that lasso doesn’t want to process the java code on the page.  I’ve tried putting the slide show <script> stuff in the body at the bottom, which w3schools.com <http://w3schools.com/> suggests, in the head, and in the .css file.  All no go.  I’ve tried changing <script> to <script type="text/JavaScript”> and putting it in the head and where w3schools.com <http://w3schools.com/> suggest (at the end of the body).  All no go.
>
> Below is the page’s code.lasso
>
> Much appreciated,
>
> Duane Hannan
> WWG Schools
>
> <!DOCTYPE html>
> <html>
> <head>
> <meta name="viewport" content="width=device-width, initial-scale=1">
> <style>
> * {box-sizing: border-box;}
> body {font-family: Verdana, sans-serif;}
> .mySlides {display: none;}
> img {vertical-align: middle;}
>
> /* Slideshow container */
> .slideshow-container {
>  max-width: 1000px;
>  position: relative;
>  margin: auto;
> }
>
> /* Caption text */
> .text {
>  color: #f2f2f2;
>  font-size: 15px;
>  padding: 8px 12px;
>  position: absolute;
>  bottom: 8px;
>  width: 100%;
>  text-align: center;
> }
>
> /* Number text (1/3 etc) */
> .numbertext {
>  color: #f2f2f2;
>  font-size: 12px;
>  padding: 8px 12px;
>  position: absolute;
>  top: 0;
> }
>
> /* The dots/bullets/indicators */
> .dot {
>  height: 15px;
>  width: 15px;
>  margin: 0 2px;
>  background-color: #bbb;
>  border-radius: 50%;
>  display: inline-block;
>  transition: background-color 0.6s ease;
> }
>
> .active {
>  background-color: #717171;
> }
>
> /* Fading animation */
> .fade {
>  -webkit-animation-name: fade;
>  -webkit-animation-duration: 1.5s;
>  animation-name: fade;
>  animation-duration: 1.5s;
> }
>
> @-webkit-keyframes fade {
>  from {opacity: .4}
>  to {opacity: 1}
> }
>
> @keyframes fade {
>  from {opacity: .4}
>  to {opacity: 1}
> }
>
> /* On smaller screens, decrease text size */
> @media only screen and (max-width: 300px) {
>  .text {font-size: 11px}
> }
> </style>
> </head>
> <body>
>
> <h2>Automatic Slideshow</h2>
> <p>Change image every 2 seconds:</p>
>
> <div class="slideshow-container">
>
> <div class="mySlides fade">
>  <div class="numbertext">1 / 3</div>
>  <img src="images/MenuBand.jpg" style="width:100%">
>  <div class="text">Caption Text</div>
> </div>
>
> <div class="mySlides fade">
>  <div class="numbertext">2 / 3</div>
>  <img src="images/MenuBand.jpg" style="width:100%">
>  <div class="text">Caption Two</div>
> </div>
>
> <div class="mySlides fade">
>  <div class="numbertext">3 / 3</div>
>  <img src="images/MenuBand.jpg" style="width:100%">
>  <div class="text">Caption Three</div>
> </div>
>
> </div>
> <br>
>
> <div style="text-align:center">
>  <span class="dot"></span>
>  <span class="dot"></span>
>  <span class="dot"></span>
> </div>
>
> <script>
> var slideIndex = 0;
> showSlides();
>
> function showSlides() {
>    var i;
>    var slides = document.getElementsByClassName("mySlides");
>    var dots = document.getElementsByClassName("dot");
>    for (i = 0; i < slides.length; i++) {
>       slides[i].style.display = "none";  
>    }
>    slideIndex++;
>    if (slideIndex > slides.length) {slideIndex = 1}    
>    for (i = 0; i < dots.length; i++) {
>        dots[i].className = dots[i].className.replace(" active", "");
>    }
>    slides[slideIndex-1].style.display = "block";  
>    dots[slideIndex-1].className += " active";
>    setTimeout(showSlides, 2000); // Change image every 2 seconds
> }
> </script>
>
> [inline:-search, -database='xxxxxxx', -table='xxxxxxxx', -sortfield='EventDate', -sortorder='descending', -maxrecords=3]
>        [records]
>            [field:'Event'] [field:'School']<br>
>        [/records]
>    [/inline]
>
> </body>
> </html>
>
>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Using a Javascript on .lasso page

Andreas Steinmann-2
In reply to this post by Duane Hannan
You can wrap all stuff, Lasso should not process with:

[NoProcess]
… your javascript...
[/NoProcess]

Mange hilsner,
Andreas



Andreas Steinmann‌
-------------------------------
Egebjerghuse 2
DK 2750 Ballerup
Denmark

Quartier Meran
F 06540 Saorge
France
-------------------------------
[hidden email] <mailto:[hidden email]>
+45 28117505

> On 23 Jul 2018, at 19:41, Duane Hannan <[hidden email] <mailto:[hidden email]>> wrote:
>
> Thanks for you response.  --Lasso 8.6.3.
>
> Duane
>
>
>
>> On Jul 23, 2018, at 12:26 PM, Jolle Carlestam <[hidden email] <mailto:[hidden email]>> wrote:
>>
>>
>>>
>>> [slideIndex-1]
>>
>> This piece, and all other places with square brackets are interpreted as Lasso code. You need to protect that from happening.
>> The technique to accomplish that varies. Is this Lasso 8.x or 9.x?
>>
>> HDB
>> Jolle
>>
>> #############################################################
>>
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email] <mailto:[hidden email]>
>> Official list archives available at http://www.lassotalk.com <http://www.lassotalk.com/>
>> To unsubscribe, E-mail to: <[hidden email] <mailto:[hidden email]>>
>> Send administrative queries to  <[hidden email] <mailto:[hidden email]>>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email] <mailto:[hidden email]>
> Official list archives available at http://www.lassotalk.com <http://www.lassotalk.com/>
> To unsubscribe, E-mail to: <[hidden email] <mailto:[hidden email]>>
> Send administrative queries to  <[hidden email] <mailto:[hidden email]>>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Using a Javascript on .lasso page

Duane Hannan
In reply to this post by Steffan A. Cline
All good.  Thanks ever so much.

Duane Hannan
WWG Schools

> On Jul 23, 2018, at 12:47 PM, Steffan Cline <[hidden email]> wrote:
>
> If you wrap your JS code in <!— and —> Lasso will not execute your code inside it.
>
> <script type=“text/javascript”><!—
> Your JS using [ ] will be ignored by Lasso
> —></script>
>
>
> Thanks,
> Steffan Cline
> [hidden email] <mailto:[hidden email]>
> 602-793-0014
>
>> On Jul 23, 2018, at 10:20 AM, Duane Hannan <[hidden email] <mailto:[hidden email]>> wrote:
>>
>> I’m designing a new web page (and learning html/css) and I want to include an images slide show on the page.  The code, which includes some Javascript, comes from a copy/paste from w3schools.com <http://w3schools.com/> <http://w3schools.com/ <http://w3schools.com/>>. Their code works fine on a simple .html page, but when I add some simple lasso search-a-database-and-show-the-results code and switch the page’s suffix to .lasso, the slide show images disappear.
>>
>> Sorry about my novice-ness, but does anyone have any suggestions?  It’s pretty clear that lasso doesn’t want to process the java code on the page.  I’ve tried putting the slide show <script> stuff in the body at the bottom, which w3schools.com <http://w3schools.com/> <http://w3schools.com/ <http://w3schools.com/>> suggests, in the head, and in the .css file.  All no go.  I’ve tried changing <script> to <script type="text/JavaScript”> and putting it in the head and where w3schools.com <http://w3schools.com/><http://w3schools.com/ <http://w3schools.com/>> suggest (at the end of the body).  All no go.
>>
>> Below is the page’s code.lasso
>>
>> Much appreciated,
>>
>> Duane Hannan
>> WWG Schools
>>
>> <!DOCTYPE html>
>> <html>
>> <head>
>> <meta name="viewport" content="width=device-width, initial-scale=1">
>> <style>
>> * {box-sizing: border-box;}
>> body {font-family: Verdana, sans-serif;}
>> .mySlides {display: none;}
>> img {vertical-align: middle;}
>>
>> /* Slideshow container */
>> .slideshow-container {
>> max-width: 1000px;
>> position: relative;
>> margin: auto;
>> }
>>
>> /* Caption text */
>> .text {
>> color: #f2f2f2;
>> font-size: 15px;
>> padding: 8px 12px;
>> position: absolute;
>> bottom: 8px;
>> width: 100%;
>> text-align: center;
>> }
>>
>> /* Number text (1/3 etc) */
>> .numbertext {
>> color: #f2f2f2;
>> font-size: 12px;
>> padding: 8px 12px;
>> position: absolute;
>> top: 0;
>> }
>>
>> /* The dots/bullets/indicators */
>> .dot {
>> height: 15px;
>> width: 15px;
>> margin: 0 2px;
>> background-color: #bbb;
>> border-radius: 50%;
>> display: inline-block;
>> transition: background-color 0.6s ease;
>> }
>>
>> .active {
>> background-color: #717171;
>> }
>>
>> /* Fading animation */
>> .fade {
>> -webkit-animation-name: fade;
>> -webkit-animation-duration: 1.5s;
>> animation-name: fade;
>> animation-duration: 1.5s;
>> }
>>
>> @-webkit-keyframes fade {
>> from {opacity: .4}
>> to {opacity: 1}
>> }
>>
>> @keyframes fade {
>> from {opacity: .4}
>> to {opacity: 1}
>> }
>>
>> /* On smaller screens, decrease text size */
>> @media only screen and (max-width: 300px) {
>> .text {font-size: 11px}
>> }
>> </style>
>> </head>
>> <body>
>>
>> <h2>Automatic Slideshow</h2>
>> <p>Change image every 2 seconds:</p>
>>
>> <div class="slideshow-container">
>>
>> <div class="mySlides fade">
>> <div class="numbertext">1 / 3</div>
>> <img src="images/MenuBand.jpg" style="width:100%">
>> <div class="text">Caption Text</div>
>> </div>
>>
>> <div class="mySlides fade">
>> <div class="numbertext">2 / 3</div>
>> <img src="images/MenuBand.jpg" style="width:100%">
>> <div class="text">Caption Two</div>
>> </div>
>>
>> <div class="mySlides fade">
>> <div class="numbertext">3 / 3</div>
>> <img src="images/MenuBand.jpg" style="width:100%">
>> <div class="text">Caption Three</div>
>> </div>
>>
>> </div>
>> <br>
>>
>> <div style="text-align:center">
>> <span class="dot"></span>
>> <span class="dot"></span>
>> <span class="dot"></span>
>> </div>
>>
>> <script>
>> var slideIndex = 0;
>> showSlides();
>>
>> function showSlides() {
>>   var i;
>>   var slides = document.getElementsByClassName("mySlides");
>>   var dots = document.getElementsByClassName("dot");
>>   for (i = 0; i < slides.length; i++) {
>>      slides[i].style.display = "none";  
>>   }
>>   slideIndex++;
>>   if (slideIndex > slides.length) {slideIndex = 1}    
>>   for (i = 0; i < dots.length; i++) {
>>       dots[i].className = dots[i].className.replace(" active", "");
>>   }
>>   slides[slideIndex-1].style.display = "block";  
>>   dots[slideIndex-1].className += " active";
>>   setTimeout(showSlides, 2000); // Change image every 2 seconds
>> }
>> </script>
>>
>> [inline:-search, -database='xxxxxxx', -table='xxxxxxxx', -sortfield='EventDate', -sortorder='descending', -maxrecords=3]
>>       [records]
>>           [field:'Event'] [field:'School']<br>
>>       [/records]
>>   [/inline]
>>
>> </body>
>> </html>
>>
>>
>>
>>
>> #############################################################
>>
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email] <mailto:[hidden email]>
>> Official list archives available at http://www.lassotalk.com <http://www.lassotalk.com/>
>> To unsubscribe, E-mail to: <[hidden email] <mailto:[hidden email]>>
>> Send administrative queries to  <[hidden email] <mailto:[hidden email]>>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email] <mailto:[hidden email]>
> Official list archives available at http://www.lassotalk.com <http://www.lassotalk.com/>
> To unsubscribe, E-mail to: <[hidden email] <mailto:[hidden email]>>
> Send administrative queries to  <[hidden email] <mailto:[hidden email]>>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Using a Javascript on .lasso page

Kevin Bice
In reply to this post by Andreas Steinmann-2
That is what I do these days. It allows clients to upload any Javascript to their site where it is placed between the [noprocess] tags to avoid Lasso issues.

I have done what Steffan suggested for years, but I find the [noprocess] tag helps me give the client more control of their site.
……………...
Kevin Bice
512.879.1653



> On Jul 23, 2018, at 1:10 PM, Andreas Steinmann <[hidden email] <mailto:[hidden email]>> wrote:
>
> You can wrap all stuff, Lasso should not process with:
>
> [NoProcess]
> … your javascript...
> [/NoProcess]
>
> Mange hilsner,
> Andreas
>
>
>
> Andreas Steinmann‌
> -------------------------------
> Egebjerghuse 2
> DK 2750 Ballerup
> Denmark
>
> Quartier Meran
> F 06540 Saorge
> France
> -------------------------------
> [hidden email] <mailto:[hidden email]> <mailto:[hidden email] <mailto:[hidden email]>>
> +45 28117505
>
>> On 23 Jul 2018, at 19:41, Duane Hannan <[hidden email] <mailto:[hidden email]> <mailto:[hidden email] <mailto:[hidden email]>>> wrote:
>>
>> Thanks for you response.  --Lasso 8.6.3.
>>
>> Duane
>>
>>
>>
>>> On Jul 23, 2018, at 12:26 PM, Jolle Carlestam <[hidden email] <mailto:[hidden email]> <mailto:[hidden email] <mailto:[hidden email]>>> wrote:
>>>
>>>
>>>>
>>>> [slideIndex-1]
>>>
>>> This piece, and all other places with square brackets are interpreted as Lasso code. You need to protect that from happening.
>>> The technique to accomplish that varies. Is this Lasso 8.x or 9.x?
>>>
>>> HDB
>>> Jolle
>>>
>>> #############################################################
>>>
>>> This message is sent to you because you are subscribed to
>>> the mailing list Lasso [hidden email] <mailto:[hidden email]> <mailto:[hidden email] <mailto:[hidden email]>>
>>> Official list archives available at http://www.lassotalk.com <http://www.lassotalk.com/> <http://www.lassotalk.com/ <http://www.lassotalk.com/>>
>>> To unsubscribe, E-mail to: <[hidden email] <mailto:[hidden email]> <mailto:[hidden email] <mailto:[hidden email]>>>
>>> Send administrative queries to  <[hidden email] <mailto:[hidden email]> <mailto:[hidden email] <mailto:[hidden email]>>>
>>
>>
>> #############################################################
>>
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email] <mailto:[hidden email]> <mailto:[hidden email] <mailto:[hidden email]>>
>> Official list archives available at http://www.lassotalk.com <http://www.lassotalk.com/> <http://www.lassotalk.com/ <http://www.lassotalk.com/>>
>> To unsubscribe, E-mail to: <[hidden email] <mailto:[hidden email]> <mailto:[hidden email] <mailto:[hidden email]>>>
>> Send administrative queries to  <[hidden email] <mailto:[hidden email]> <mailto:[hidden email] <mailto:[hidden email]>>>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email] <mailto:[hidden email]>
> Official list archives available at http://www.lassotalk.com <http://www.lassotalk.com/>
> To unsubscribe, E-mail to: <[hidden email] <mailto:[hidden email]>>
> Send administrative queries to  <[hidden email] <mailto:[hidden email]>>



……………...
Kevin Bice
512.879.1653
www.lassospace.com





#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Replace non-standard characters?

Brett Harvey
What’s the best way to replace non-standard characters in a file name?
Characters like ä, ü, é, ç, ô  ?


#string->(replace('ä','a'));  Doesn’t seem to work…

Having a foggy brain day - seems like it should be simple.

Thanks!

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Replace non-standard characters?

Jolle Carlestam-2

> 9 aug. 2018 kl. 16:34 skrev Brett Harvey <[hidden email]>:
>
> What’s the best way to replace non-standard characters in a file name?
> Characters like ä, ü, é, ç, ô  ?
>
>
> #string->(replace('ä','a'));  Doesn’t seem to work…
>
> Having a foggy brain day - seems like it should be simple.

I would use regex for this. Here’s an example for filenames.

#string->replace(regexp(`([^0-9a-zA-Z-.,_])`), '_’)

The above will replace any char not in the approved range with underscore. it’s better than nto look for specific chars, since that path is an endless mess of fighting creative users.

NB, this is for Lasso 9.

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Replace non-standard characters?

Bil Corry-3
Here's a tag I wrote a long time ago to do this, maybe it can be adapted...


- Bil


define_tag:'lp_string_extendedToPlain',
-description='Converts extended characters in UTF-8 to their plain ASCII
equivalents.',
-priority='replace',
-required='string',-copy;

local:'return' = string;
local:'letter' = string;

local:'zap' = true;
if: params->(find:'-nozap')->size;
#zap = false;
/if;

// first, make sure to convert screwy MS Word chars to standard UTF-8 (like
"smart" quotes)
#string = lp_string_CP1252toUTF8: (string: #string);

// process one letter at a time
iterate: #string, local:'s';
// is it plain ascii already?
if: #s->integer <= 127;
#return += #s;
loop_continue;
/if;

// convert foreign letters to plain letters
if: (lp_logical_in: #s->chartype, (array:
'LOWERCASE_LETTER','UPPERCASE_LETTER'));
#letter = (string_findregexp: #s->charname, -find='\\b[A-Z]\\b',
-ignorecase);
if: #letter->size;
if: #s->chartype == 'LOWERCASE_LETTER';
#return += string_lowercase: (#letter->(get:1));
else: #s->chartype == 'UPPERCASE_LETTER';
#return += string_uppercase: (#letter->(get:1));
/if;
loop_continue;
/if;
/if;


// convert foreign punctuation to plain punctuation
if: (lp_logical_in: #s->integer, (: 160, 12288));  // 00A0, 3000
  #return += ' ';
loop_continue;
else: (lp_logical_in: #s->integer, (: 451, 10082));  // 01C3, 2762
#return += '!';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8252));  // 203C
  #return += '!!';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8253, 8264));  // 203D, 2048
  #return += '?!';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8265));  // 2049
  #return += '!?';
loop_continue;
    else: (lp_logical_in: #s->integer, (: 698, 8243, 12291, 8220, 8221,
8222, 8223, 8246));  // 02BA, 2033, 3003, 201C, 201D, 201E, 201F, 2036
  #return += '"';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 9839));  // 266F
  #return += '#';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 1642));  // 066A
  #return += '%';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8216, 8217, 697, 700, 712, 8242,
8245, 8218, 8219));  // 2018, 2019, 02B9, 02BC, 02C8, 2032, 2035, 201A, 201B
  #return += "'";
loop_continue;
  else: (lp_logical_in: #s->integer, (: 1645, 8270, 8727, 10033, 183, 903,
8226, 8227, 8228, 8231, 8729, 8901, 12539, 9688, 9702, 8718, 9656));  //
066D, 204E, 2217, 2731, 00B7, 0387, 2022, 2023, 2024, 2027, 2219, 22C5,
30FB, 25D8, 25E6, 220E, 25B8
  #return += '*';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 1548, 12289));  // 060C, 3001
  #return += ',';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8208, 8209, 8722));  // 2010, 2011,
2212
  #return += '-';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8210, 8211));  // 2012, 2013
  #return += '--';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8212, 8213));  // 2014, 2015
  #return += '---';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 212, 12290));  // 00D4, 3002
  #return += '.';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8229));  // 2025
  #return += '..';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8230));  // 2026
  #return += '...';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8260, 8725, 247));  // 2044, 2215,
00F7
  #return += '/';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8758));  // 2236
  #return += ':';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 1563, 8271));  // 061B, 204F
  #return += ';';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 9001, 10216, 12296));  // 2329,
27E8, 3008
  #return += '<';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 9002, 10217, 12297));  // 232A,
27E9, 3009
  #return += '>';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8800 ));  // 2260
  #return += '<>';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 894, 1567));  // 037E, 061F
  #return += '?';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8726));  // 2216
  #return += '\\';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 708, 710, 8963));  // 02C4, 02C6,
2303
  #return += '^';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 717, 8215));  // 02CD, 2017
  #return += '_';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 715, 8245));  // 02CB, 2035
  #return += '`';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 448, 8739, 10072));  // 01C0, 2223,
2758
  #return += '|';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 732, 8275, 8764, 65374));  // 02DC,
2053, 223C, FF5E
  #return += '~';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 169));  // 00A9
  #return += '(c)';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 174));  // 00AE
  #return += '(R)';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 177));  // 00B1
  #return += '+/-';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 185));  // 00B9
  #return += '1';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 178));  // 00B2
  #return += '2';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 179));  // 00B3
  #return += '3';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 188));  // 00BC
  #return += '1/4';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8531));  // 2153
  #return += '1/3';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8532));  // 2154
  #return += '2/3';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8539));  // 215B
  #return += '1/8';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8540));  // 215C
  #return += '3/8';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8541));  // 215D
  #return += '5/8';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8542));  // 215E
  #return += '7/8';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 189));  // 00BD
  #return += '1/2';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 190));  // 00BE
  #return += '3/4';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 215));  // 00D7
  #return += 'x';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8482));  // 2122
  #return += 'TM';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8470));  // 2116
  #return += 'No.';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8804));  // 2264
  #return += '<=';
loop_continue;
  else: (lp_logical_in: #s->integer, (: 8805));  // 2265
  #return += '>=';
loop_continue;
/if;
//return: (x: '2025, 2026');
// not a char we can convert
#return += #s;
/iterate;
if: #zap;
#return = (lp_string_zap: #return);
/if;
// return modified string
return: #return;

//lp_string_extendedtoplain:'abcd ABCD räksmörgås / RÄKSMÖRGÅS / € ‚ ƒ „ …
† ‡ ˆ ‰ Š ‹ Œ Ž ‘ ’ “ ” • – — ˜ ™ š › œ ž Ÿ';
//'<br>';
//lp_string_extendedtoplain:'abcd ABCD räksmörgås / RÄKSMÖRGÅS / € ‚ ƒ „ …
† ‡ ˆ ‰ Š ‹ Œ Ž ‘ ’ “ ” • – — ˜ ™ š › œ ž Ÿ',-nozap;
/define_tag;



On Thu, Aug 9, 2018 at 8:13 AM, Jolle Carlestam <[hidden email]> wrote:

>
> > 9 aug. 2018 kl. 16:34 skrev Brett Harvey <[hidden email]>:
> >
> > What’s the best way to replace non-standard characters in a file name?
> > Characters like ä, ü, é, ç, ô  ?
> >
> >
> > #string->(replace('ä','a'));  Doesn’t seem to work…
> >
> > Having a foggy brain day - seems like it should be simple.
>
> I would use regex for this. Here’s an example for filenames.
>
> #string->replace(regexp(`([^0-9a-zA-Z-.,_])`), '_’)
>
> The above will replace any char not in the approved range with underscore.
> it’s better than nto look for specific chars, since that path is an endless
> mess of fighting creative users.
>
> NB, this is for Lasso 9.
>
> HDB
> Jolle
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>   the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Replace non-standard characters?

Jolle Carlestam-2
Wow, a pretty long replacement for a one line regex. :-)

And, Bil, you’d have to dig some more. I see at least two other of your tags referred to in the code.

I still think you should go the regex route.
String_ReplaceRegExp would probably fix it for you even in Lasso 8:
http://www.lassosoft.com/lassoDocs/languageReference/obj/String_ReplaceRegExp

HDB
Jolle

> 9 aug. 2018 kl. 18:23 skrev Bil Corry <[hidden email]>:
>
> Here's a tag I wrote a long time ago to do this, maybe it can be adapted...
>
>
> - Bil
>
>
> define_tag:'lp_string_extendedToPlain',
> -description='Converts extended characters in UTF-8 to their plain ASCII
> equivalents.',
> -priority='replace',
> -required='string',-copy;
>
> local:'return' = string;
> local:'letter' = string;
>
> local:'zap' = true;
> if: params->(find:'-nozap')->size;
> #zap = false;
> /if;
>
> // first, make sure to convert screwy MS Word chars to standard UTF-8 (like
> "smart" quotes)
> #string = lp_string_CP1252toUTF8: (string: #string);
>
> // process one letter at a time
> iterate: #string, local:'s';
> // is it plain ascii already?
> if: #s->integer <= 127;
> #return += #s;
> loop_continue;
> /if;
>
> // convert foreign letters to plain letters
> if: (lp_logical_in: #s->chartype, (array:
> 'LOWERCASE_LETTER','UPPERCASE_LETTER'));
> #letter = (string_findregexp: #s->charname, -find='\\b[A-Z]\\b',
> -ignorecase);
> if: #letter->size;
> if: #s->chartype == 'LOWERCASE_LETTER';
> #return += string_lowercase: (#letter->(get:1));
> else: #s->chartype == 'UPPERCASE_LETTER';
> #return += string_uppercase: (#letter->(get:1));
> /if;
> loop_continue;
> /if;
> /if;
>
>
> // convert foreign punctuation to plain punctuation
> if: (lp_logical_in: #s->integer, (: 160, 12288));  // 00A0, 3000
>  #return += ' ';
> loop_continue;
> else: (lp_logical_in: #s->integer, (: 451, 10082));  // 01C3, 2762
> #return += '!';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8252));  // 203C
>  #return += '!!';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8253, 8264));  // 203D, 2048
>  #return += '?!';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8265));  // 2049
>  #return += '!?';
> loop_continue;
>    else: (lp_logical_in: #s->integer, (: 698, 8243, 12291, 8220, 8221,
> 8222, 8223, 8246));  // 02BA, 2033, 3003, 201C, 201D, 201E, 201F, 2036
>  #return += '"';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 9839));  // 266F
>  #return += '#';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 1642));  // 066A
>  #return += '%';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8216, 8217, 697, 700, 712, 8242,
> 8245, 8218, 8219));  // 2018, 2019, 02B9, 02BC, 02C8, 2032, 2035, 201A, 201B
>  #return += "'";
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 1645, 8270, 8727, 10033, 183, 903,
> 8226, 8227, 8228, 8231, 8729, 8901, 12539, 9688, 9702, 8718, 9656));  //
> 066D, 204E, 2217, 2731, 00B7, 0387, 2022, 2023, 2024, 2027, 2219, 22C5,
> 30FB, 25D8, 25E6, 220E, 25B8
>  #return += '*';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 1548, 12289));  // 060C, 3001
>  #return += ',';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8208, 8209, 8722));  // 2010, 2011,
> 2212
>  #return += '-';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8210, 8211));  // 2012, 2013
>  #return += '--';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8212, 8213));  // 2014, 2015
>  #return += '---';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 212, 12290));  // 00D4, 3002
>  #return += '.';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8229));  // 2025
>  #return += '..';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8230));  // 2026
>  #return += '...';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8260, 8725, 247));  // 2044, 2215,
> 00F7
>  #return += '/';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8758));  // 2236
>  #return += ':';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 1563, 8271));  // 061B, 204F
>  #return += ';';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 9001, 10216, 12296));  // 2329,
> 27E8, 3008
>  #return += '<';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 9002, 10217, 12297));  // 232A,
> 27E9, 3009
>  #return += '>';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8800 ));  // 2260
>  #return += '<>';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 894, 1567));  // 037E, 061F
>  #return += '?';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8726));  // 2216
>  #return += '\\';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 708, 710, 8963));  // 02C4, 02C6,
> 2303
>  #return += '^';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 717, 8215));  // 02CD, 2017
>  #return += '_';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 715, 8245));  // 02CB, 2035
>  #return += '`';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 448, 8739, 10072));  // 01C0, 2223,
> 2758
>  #return += '|';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 732, 8275, 8764, 65374));  // 02DC,
> 2053, 223C, FF5E
>  #return += '~';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 169));  // 00A9
>  #return += '(c)';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 174));  // 00AE
>  #return += '(R)';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 177));  // 00B1
>  #return += '+/-';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 185));  // 00B9
>  #return += '1';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 178));  // 00B2
>  #return += '2';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 179));  // 00B3
>  #return += '3';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 188));  // 00BC
>  #return += '1/4';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8531));  // 2153
>  #return += '1/3';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8532));  // 2154
>  #return += '2/3';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8539));  // 215B
>  #return += '1/8';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8540));  // 215C
>  #return += '3/8';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8541));  // 215D
>  #return += '5/8';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8542));  // 215E
>  #return += '7/8';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 189));  // 00BD
>  #return += '1/2';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 190));  // 00BE
>  #return += '3/4';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 215));  // 00D7
>  #return += 'x';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8482));  // 2122
>  #return += 'TM';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8470));  // 2116
>  #return += 'No.';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8804));  // 2264
>  #return += '<=';
> loop_continue;
>  else: (lp_logical_in: #s->integer, (: 8805));  // 2265
>  #return += '>=';
> loop_continue;
> /if;
> //return: (x: '2025, 2026');
> // not a char we can convert
> #return += #s;
> /iterate;
> if: #zap;
> #return = (lp_string_zap: #return);
> /if;
> // return modified string
> return: #return;
>
> //lp_string_extendedtoplain:'abcd ABCD räksmörgås / RÄKSMÖRGÅS / € ‚ ƒ „ …
> † ‡ ˆ ‰ Š ‹ Œ Ž ‘ ’ “ ” • – — ˜ ™ š › œ ž Ÿ';
> //'<br>';
> //lp_string_extendedtoplain:'abcd ABCD räksmörgås / RÄKSMÖRGÅS / € ‚ ƒ „ …
> † ‡ ˆ ‰ Š ‹ Œ Ž ‘ ’ “ ” • – — ˜ ™ š › œ ž Ÿ',-nozap;
> /define_tag;
>
>
>
> On Thu, Aug 9, 2018 at 8:13 AM, Jolle Carlestam <[hidden email]> wrote:
>
>>
>>> 9 aug. 2018 kl. 16:34 skrev Brett Harvey <[hidden email]>:
>>>
>>> What’s the best way to replace non-standard characters in a file name?
>>> Characters like ä, ü, é, ç, ô  ?
>>>
>>>
>>> #string->(replace('ä','a'));  Doesn’t seem to work…
>>>
>>> Having a foggy brain day - seems like it should be simple.
>>
>> I would use regex for this. Here’s an example for filenames.
>>
>> #string->replace(regexp(`([^0-9a-zA-Z-.,_])`), '_’)
>>
>> The above will replace any char not in the approved range with underscore.
>> it’s better than nto look for specific chars, since that path is an endless
>> mess of fighting creative users.
>>
>> NB, this is for Lasso 9.
>>
>> HDB
>> Jolle
>>
>> #############################################################
>>
>> This message is sent to you because you are subscribed to
>>  the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Replace non-standard characters?

Bil Corry-3
Yes, I have a tag for that too.  The default is to remove any non-ascii
text, but you can specify an underline, or other character.

- Bil


[

define_tag:'lp_string_zap',
-description='Returns a string with all non-plain-ascii characters
removed.',
-priority='replace',
-required='text_to_zap',
-optional='replacement_text';

if: !(local_defined:'replacement_text');
local:'replacement_text' = '';
/if;

return: (string_replaceregexp: #text_to_zap,
-find='[^\\x20-\\x7E\\x09\\x0A\\x0D]', -replace=#replacement_text);
/define_tag;

/* Example

[var:'teststring' = 'test test 123\t123' + (decode_url:'%80') +
(decode_url:'%81')]
<pre>
Test String: (<b>[$teststring]</b>)<br>
Zap (remove bad chars): (<b>[lp_string_zap: $teststring]</b>)<br>
Zap (replace bad chars with *): (<b>[lp_string_zap: $teststring,
'*']</b>)<br>
</pre>

*/

]


On Thu, Aug 9, 2018 at 9:35 PM, Jolle Carlestam <[hidden email]> wrote:

> Wow, a pretty long replacement for a one line regex. :-)
>
> And, Bil, you’d have to dig some more. I see at least two other of your
> tags referred to in the code.
>
> I still think you should go the regex route.
> String_ReplaceRegExp would probably fix it for you even in Lasso 8:
> http://www.lassosoft.com/lassoDocs/languageReference/
> obj/String_ReplaceRegExp
>
> HDB
> Jolle
>
> > 9 aug. 2018 kl. 18:23 skrev Bil Corry <[hidden email]>:
> >
> > Here's a tag I wrote a long time ago to do this, maybe it can be
> adapted...
> >
> >
> > - Bil
> >
> >
> > define_tag:'lp_string_extendedToPlain',
> > -description='Converts extended characters in UTF-8 to their plain ASCII
> > equivalents.',
> > -priority='replace',
> > -required='string',-copy;
> >
> > local:'return' = string;
> > local:'letter' = string;
> >
> > local:'zap' = true;
> > if: params->(find:'-nozap')->size;
> > #zap = false;
> > /if;
> >
> > // first, make sure to convert screwy MS Word chars to standard UTF-8
> (like
> > "smart" quotes)
> > #string = lp_string_CP1252toUTF8: (string: #string);
> >
> > // process one letter at a time
> > iterate: #string, local:'s';
> > // is it plain ascii already?
> > if: #s->integer <= 127;
> > #return += #s;
> > loop_continue;
> > /if;
> >
> > // convert foreign letters to plain letters
> > if: (lp_logical_in: #s->chartype, (array:
> > 'LOWERCASE_LETTER','UPPERCASE_LETTER'));
> > #letter = (string_findregexp: #s->charname, -find='\\b[A-Z]\\b',
> > -ignorecase);
> > if: #letter->size;
> > if: #s->chartype == 'LOWERCASE_LETTER';
> > #return += string_lowercase: (#letter->(get:1));
> > else: #s->chartype == 'UPPERCASE_LETTER';
> > #return += string_uppercase: (#letter->(get:1));
> > /if;
> > loop_continue;
> > /if;
> > /if;
> >
> >
> > // convert foreign punctuation to plain punctuation
> > if: (lp_logical_in: #s->integer, (: 160, 12288));  // 00A0, 3000
> >  #return += ' ';
> > loop_continue;
> > else: (lp_logical_in: #s->integer, (: 451, 10082));  // 01C3, 2762
> > #return += '!';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8252));  // 203C
> >  #return += '!!';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8253, 8264));  // 203D, 2048
> >  #return += '?!';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8265));  // 2049
> >  #return += '!?';
> > loop_continue;
> >    else: (lp_logical_in: #s->integer, (: 698, 8243, 12291, 8220, 8221,
> > 8222, 8223, 8246));  // 02BA, 2033, 3003, 201C, 201D, 201E, 201F, 2036
> >  #return += '"';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 9839));  // 266F
> >  #return += '#';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 1642));  // 066A
> >  #return += '%';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8216, 8217, 697, 700, 712, 8242,
> > 8245, 8218, 8219));  // 2018, 2019, 02B9, 02BC, 02C8, 2032, 2035, 201A,
> 201B
> >  #return += "'";
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 1645, 8270, 8727, 10033, 183, 903,
> > 8226, 8227, 8228, 8231, 8729, 8901, 12539, 9688, 9702, 8718, 9656));  //
> > 066D, 204E, 2217, 2731, 00B7, 0387, 2022, 2023, 2024, 2027, 2219, 22C5,
> > 30FB, 25D8, 25E6, 220E, 25B8
> >  #return += '*';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 1548, 12289));  // 060C, 3001
> >  #return += ',';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8208, 8209, 8722));  // 2010,
> 2011,
> > 2212
> >  #return += '-';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8210, 8211));  // 2012, 2013
> >  #return += '--';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8212, 8213));  // 2014, 2015
> >  #return += '---';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 212, 12290));  // 00D4, 3002
> >  #return += '.';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8229));  // 2025
> >  #return += '..';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8230));  // 2026
> >  #return += '...';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8260, 8725, 247));  // 2044, 2215,
> > 00F7
> >  #return += '/';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8758));  // 2236
> >  #return += ':';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 1563, 8271));  // 061B, 204F
> >  #return += ';';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 9001, 10216, 12296));  // 2329,
> > 27E8, 3008
> >  #return += '<';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 9002, 10217, 12297));  // 232A,
> > 27E9, 3009
> >  #return += '>';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8800 ));  // 2260
> >  #return += '<>';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 894, 1567));  // 037E, 061F
> >  #return += '?';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8726));  // 2216
> >  #return += '\\';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 708, 710, 8963));  // 02C4, 02C6,
> > 2303
> >  #return += '^';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 717, 8215));  // 02CD, 2017
> >  #return += '_';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 715, 8245));  // 02CB, 2035
> >  #return += '`';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 448, 8739, 10072));  // 01C0,
> 2223,
> > 2758
> >  #return += '|';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 732, 8275, 8764, 65374));  //
> 02DC,
> > 2053, 223C, FF5E
> >  #return += '~';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 169));  // 00A9
> >  #return += '(c)';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 174));  // 00AE
> >  #return += '(R)';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 177));  // 00B1
> >  #return += '+/-';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 185));  // 00B9
> >  #return += '1';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 178));  // 00B2
> >  #return += '2';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 179));  // 00B3
> >  #return += '3';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 188));  // 00BC
> >  #return += '1/4';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8531));  // 2153
> >  #return += '1/3';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8532));  // 2154
> >  #return += '2/3';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8539));  // 215B
> >  #return += '1/8';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8540));  // 215C
> >  #return += '3/8';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8541));  // 215D
> >  #return += '5/8';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8542));  // 215E
> >  #return += '7/8';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 189));  // 00BD
> >  #return += '1/2';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 190));  // 00BE
> >  #return += '3/4';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 215));  // 00D7
> >  #return += 'x';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8482));  // 2122
> >  #return += 'TM';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8470));  // 2116
> >  #return += 'No.';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8804));  // 2264
> >  #return += '<=';
> > loop_continue;
> >  else: (lp_logical_in: #s->integer, (: 8805));  // 2265
> >  #return += '>=';
> > loop_continue;
> > /if;
> > //return: (x: '2025, 2026');
> > // not a char we can convert
> > #return += #s;
> > /iterate;
> > if: #zap;
> > #return = (lp_string_zap: #return);
> > /if;
> > // return modified string
> > return: #return;
> >
> > //lp_string_extendedtoplain:'abcd ABCD räksmörgås / RÄKSMÖRGÅS / € ‚ ƒ
> „ …
> > † ‡ ˆ ‰ Š ‹ Œ Ž ‘ ’ “ ” • – — ˜ ™ š › œ ž Ÿ';
> > //'<br>';
> > //lp_string_extendedtoplain:'abcd ABCD räksmörgås / RÄKSMÖRGÅS / € ‚ ƒ
> „ …
> > † ‡ ˆ ‰ Š ‹ Œ Ž ‘ ’ “ ” • – — ˜ ™ š › œ ž Ÿ',-nozap;
> > /define_tag;
> >
> >
> >
> > On Thu, Aug 9, 2018 at 8:13 AM, Jolle Carlestam <[hidden email]>
> wrote:
> >
> >>
> >>> 9 aug. 2018 kl. 16:34 skrev Brett Harvey <[hidden email]>:
> >>>
> >>> What’s the best way to replace non-standard characters in a file name?
> >>> Characters like ä, ü, é, ç, ô  ?
> >>>
> >>>
> >>> #string->(replace('ä','a'));  Doesn’t seem to work…
> >>>
> >>> Having a foggy brain day - seems like it should be simple.
> >>
> >> I would use regex for this. Here’s an example for filenames.
> >>
> >> #string->replace(regexp(`([^0-9a-zA-Z-.,_])`), '_’)
> >>
> >> The above will replace any char not in the approved range with
> underscore.
> >> it’s better than nto look for specific chars, since that path is an
> endless
> >> mess of fighting creative users.
> >>
> >> NB, this is for Lasso 9.
> >>
> >> HDB
> >> Jolle
> >>
> >> #############################################################
> >>
> >> This message is sent to you because you are subscribed to
> >>  the mailing list Lasso [hidden email]
> >> Official list archives available at http://www.lassotalk.com
> >> To unsubscribe, E-mail to: <[hidden email]>
> >> Send administrative queries to  <[hidden email]>
> >
> > #############################################################
> >
> > This message is sent to you because you are subscribed to
> >  the mailing list Lasso [hidden email]
> > Official list archives available at http://www.lassotalk.com
> > To unsubscribe, E-mail to: <[hidden email]>
> > Send administrative queries to  <[hidden email]>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>   the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Replace non-standard characters?

stevepiercy
It depends on whether the OP wants to convert non-ASCII
characters to the equivalent ASCII character stripped of
diacritic marks, to another arbitrary character, or stripped away.

For example:

ü -> u
or
ü -> -
or
ü ->

It seems they wanted the first option.

Also consider whether case is important.

Ü -> U or u?

--steve


On 8/9/18 at 9:38 PM, [hidden email] (Bil Corry) pronounced:

>Yes, I have a tag for that too.  The default is to remove any non-ascii
>text, but you can specify an underline, or other character.
>
>- Bil
>
>
>[
>
>define_tag:'lp_string_zap',
>-description='Returns a string with all non-plain-ascii characters
>removed.',
>-priority='replace',
>-required='text_to_zap',
>-optional='replacement_text';
>
>if: !(local_defined:'replacement_text');
>local:'replacement_text' = '';
>/if;
>
>return: (string_replaceregexp: #text_to_zap,
>-find='[^\\x20-\\x7E\\x09\\x0A\\x0D]', -replace=#replacement_text);
>/define_tag;
>
>/* Example
>
>[var:'teststring' = 'test test 123\t123' + (decode_url:'%80') +
>(decode_url:'%81')]
><pre>
>Test String: (<b>[$teststring]</b>)<br>
>Zap (remove bad chars): (<b>[lp_string_zap: $teststring]</b>)<br>
>Zap (replace bad chars with *): (<b>[lp_string_zap: $teststring,
>'*']</b>)<br>
></pre>
>
>*/
>
>]
>
>
>On Thu, Aug 9, 2018 at 9:35 PM, Jolle Carlestam <[hidden email]> wrote:
>
>>Wow, a pretty long replacement for a one line regex. :-)
>>
>>And, Bil, you’d have to dig some more. I see at least two other of your
>>tags referred to in the code.
>>
>>I still think you should go the regex route.
>>String_ReplaceRegExp would probably fix it for you even in Lasso 8:
>>http://www.lassosoft.com/lassoDocs/languageReference/
>>obj/String_ReplaceRegExp
>>
>>HDB
>>Jolle
>>
>>>9 aug. 2018 kl. 18:23 skrev Bil Corry <[hidden email]>:
>>>
>>>Here's a tag I wrote a long time ago to do this, maybe it can be
>>adapted...
>>>
>>>
>>>- Bil
>>>
>>>
>>>define_tag:'lp_string_extendedToPlain',
>>>-description='Converts extended characters in UTF-8 to their plain ASCII
>>>equivalents.',
>>>-priority='replace',
>>>-required='string',-copy;
>>>
>>>local:'return' = string;
>>>local:'letter' = string;
>>>
>>>local:'zap' = true;
>>>if: params->(find:'-nozap')->size;
>>>#zap = false;
>>>/if;
>>>
>>>// first, make sure to convert screwy MS Word chars to standard UTF-8
>>(like
>>>"smart" quotes)
>>>#string = lp_string_CP1252toUTF8: (string: #string);
>>>
>>>// process one letter at a time
>>>iterate: #string, local:'s';
>>>// is it plain ascii already?
>>>if: #s->integer <= 127;
>>>#return += #s;
>>>loop_continue;
>>>/if;
>>>
>>>// convert foreign letters to plain letters
>>>if: (lp_logical_in: #s->chartype, (array:
>>>'LOWERCASE_LETTER','UPPERCASE_LETTER'));
>>>#letter = (string_findregexp: #s->charname, -find='\\b[A-Z]\\b',
>>>-ignorecase);
>>>if: #letter->size;
>>>if: #s->chartype == 'LOWERCASE_LETTER';
>>>#return += string_lowercase: (#letter->(get:1));
>>>else: #s->chartype == 'UPPERCASE_LETTER';
>>>#return += string_uppercase: (#letter->(get:1));
>>>/if;
>>>loop_continue;
>>>/if;
>>>/if;
>>>
>>>
>>>// convert foreign punctuation to plain punctuation
>>>if: (lp_logical_in: #s->integer, (: 160, 12288));  // 00A0, 3000
>>>#return += ' ';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 451, 10082));  // 01C3, 2762
>>>#return += '!';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8252));  // 203C
>>>#return += '!!';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8253, 8264));  // 203D, 2048
>>>#return += '?!';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8265));  // 2049
>>>#return += '!?';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 698, 8243, 12291, 8220, 8221,
>>>8222, 8223, 8246));  // 02BA, 2033, 3003, 201C, 201D, 201E, 201F, 2036
>>>#return += '"';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 9839));  // 266F
>>>#return += '#';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 1642));  // 066A
>>>#return += '%';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8216, 8217, 697, 700, 712, 8242,
>>>8245, 8218, 8219));  // 2018, 2019, 02B9, 02BC, 02C8, 2032, 2035, 201A,
>>201B
>>>#return += "'";
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 1645, 8270, 8727, 10033, 183, 903,
>>>8226, 8227, 8228, 8231, 8729, 8901, 12539, 9688, 9702, 8718, 9656));  //
>>>066D, 204E, 2217, 2731, 00B7, 0387, 2022, 2023, 2024, 2027, 2219, 22C5,
>>>30FB, 25D8, 25E6, 220E, 25B8
>>>#return += '*';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 1548, 12289));  // 060C, 3001
>>>#return += ',';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8208, 8209, 8722));  // 2010,
>>2011,
>>>2212
>>>#return += '-';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8210, 8211));  // 2012, 2013
>>>#return += '--';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8212, 8213));  // 2014, 2015
>>>#return += '---';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 212, 12290));  // 00D4, 3002
>>>#return += '.';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8229));  // 2025
>>>#return += '..';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8230));  // 2026
>>>#return += '...';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8260, 8725, 247));  // 2044, 2215,
>>>00F7
>>>#return += '/';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8758));  // 2236
>>>#return += ':';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 1563, 8271));  // 061B, 204F
>>>#return += ';';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 9001, 10216, 12296));  // 2329,
>>>27E8, 3008
>>>#return += '<';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 9002, 10217, 12297));  // 232A,
>>>27E9, 3009
>>>#return += '>';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8800 ));  // 2260
>>>#return += '<>';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 894, 1567));  // 037E, 061F
>>>#return += '?';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8726));  // 2216
>>>#return += '\\';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 708, 710, 8963));  // 02C4, 02C6,
>>>2303
>>>#return += '^';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 717, 8215));  // 02CD, 2017
>>>#return += '_';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 715, 8245));  // 02CB, 2035
>>>#return += '`';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 448, 8739, 10072));  // 01C0,
>>2223,
>>>2758
>>>#return += '|';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 732, 8275, 8764, 65374));  //
>>02DC,
>>>2053, 223C, FF5E
>>>#return += '~';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 169));  // 00A9
>>>#return += '(c)';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 174));  // 00AE
>>>#return += '(R)';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 177));  // 00B1
>>>#return += '+/-';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 185));  // 00B9
>>>#return += '1';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 178));  // 00B2
>>>#return += '2';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 179));  // 00B3
>>>#return += '3';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 188));  // 00BC
>>>#return += '1/4';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8531));  // 2153
>>>#return += '1/3';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8532));  // 2154
>>>#return += '2/3';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8539));  // 215B
>>>#return += '1/8';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8540));  // 215C
>>>#return += '3/8';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8541));  // 215D
>>>#return += '5/8';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8542));  // 215E
>>>#return += '7/8';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 189));  // 00BD
>>>#return += '1/2';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 190));  // 00BE
>>>#return += '3/4';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 215));  // 00D7
>>>#return += 'x';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8482));  // 2122
>>>#return += 'TM';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8470));  // 2116
>>>#return += 'No.';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8804));  // 2264
>>>#return += '<=';
>>>loop_continue;
>>>else: (lp_logical_in: #s->integer, (: 8805));  // 2265
>>>#return += '>=';
>>>loop_continue;
>>>/if;
>>>//return: (x: '2025, 2026');
>>>// not a char we can convert
>>>#return += #s;
>>>/iterate;
>>>if: #zap;
>>>#return = (lp_string_zap: #return);
>>>/if;
>>>// return modified string
>>>return: #return;
>>>
>>>//lp_string_extendedtoplain:'abcd ABCD räksmörgås / RÄKSMÖRGÅS / € ‚ ƒ
>>„ …
>>>† ‡ ˆ ‰ Š ‹ Œ Ž ‘ ’ “ ” • – — ˜ ™ š › œ ž Ÿ';
>>>//'<br>';
>>>//lp_string_extendedtoplain:'abcd ABCD räksmörgås / RÄKSMÖRGÅS / € ‚ ƒ
>>„ …
>>>† ‡ ˆ ‰ Š ‹ Œ Ž ‘ ’ “ ” • – — ˜ ™ š › œ ž Ÿ',-nozap;
>>>/define_tag;
>>>
>>>
>>>
>>>On Thu, Aug 9, 2018 at 8:13 AM, Jolle Carlestam <[hidden email]>
>>wrote:
>>>
>>>>
>>>>> 9 aug. 2018 kl. 16:34 skrev Brett Harvey <[hidden email]>:
>>>>>
>>>>> What’s the best way to replace non-standard characters in a file name?
>>>>> Characters like ä, ü, é, ç, ô  ?
>>>>>
>>>>>
>>>>> #string->(replace('ä','a'));  Doesn’t seem to work…
>>>>>
>>>>> Having a foggy brain day - seems like it should be simple.
>>>>
>>>> I would use regex for this. Here’s an example for filenames.
>>>>
>>>> #string->replace(regexp(`([^0-9a-zA-Z-.,_])`), '_’)
>>>>
>>>> The above will replace any char not in the approved range with
>>underscore.
>>>> it’s better than nto look for specific chars, since that path is an
>>endless
>>>> mess of fighting creative users.
>>>>
>>>> NB, this is for Lasso 9.
>>>>
>>>> HDB
>>>> Jolle
>>>>
>>>> #############################################################
>>>>
>>>> This message is sent to you because you are subscribed to
>>>>  the mailing list Lasso [hidden email]
>>>> Official list archives available at http://www.lassotalk.com
>>>> To unsubscribe, E-mail to: <[hidden email]>
>>>> Send administrative queries to  <[hidden email]>
>>>
>>>#############################################################
>>>
>>>This message is sent to you because you are subscribed to
>>>the mailing list Lasso [hidden email]
>>>Official list archives available at http://www.lassotalk.com
>>>To unsubscribe, E-mail to: <[hidden email]>
>>>Send administrative queries to  <[hidden email]>
>>
>>
>>#############################################################
>>
>>This message is sent to you because you are subscribed to
>>the mailing list Lasso [hidden email]
>>Official list archives available at http://www.lassotalk.com
>>To unsubscribe, E-mail to: <[hidden email]>
>>Send administrative queries to  <[hidden email]>
>>
>
>#############################################################
>
>This message is sent to you because you are subscribed to
>the mailing list Lasso [hidden email]
>Official list archives available at http://www.lassotalk.com
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy              Website Builder              Eugene, OR
<[hidden email]>               <http://www.stevepiercy.com/>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Replace non-standard characters?

Jolle Carlestam-2
10 aug. 2018 kl. 06:52 skrev Steve Piercy - Website Builder <[hidden email]>:

>
> It depends on whether the OP wants to convert non-ASCII characters to the equivalent ASCII character stripped of diacritic marks, to another arbitrary character, or stripped away.
>
> For example:
>
> ü -> u
> or
> ü -> -
> or
> ü ->
>
> It seems they wanted the first option.
>
> Also consider whether case is important.
>
> Ü -> U or u?
>
> --steve

I read his hopes that way too. But as I wrote, that is not a sound way to proceed. There are an endless amount of chars he’d have to look out for. Swedish, Danish, German alphabet all have their own quirky letters. French have all their á,à etc. There’s Spanish, Portuguese. What if some user throws in Arabic, Russian, Thai. And then there’s the endless fun with emojis. Why would someone not name their file "Ösig bild på Günther [insert your own emoji here].jpg”? I’ve had that happen.

(Oh, and the reason I don’t actually put an emoji in my example is due to a bug in Lasso 9 preventing it from saving text with emojis to the DB. This affects Lasso talk as well.)

In any case. If it’s a requirement I suggest implementing a couple of known non-ASCII characters to equivalent ASCII characters replacements and then run a catch-all regex on the result. Bils regex will catch all non-ASCII. I still think mine is better. It will make sure there’re only safe file name chars in the string. After all, some ASCII is not safe to use as file names.

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Replace non-standard characters?

stevepiercy
Indeed, this is part of what I do in Lasso 8, which the OP uses:

     $newfile = $files->find('upload.realname')->split('/')->last->split('\\')->last;
     $newfile->lowercase;
     $newfile = string_replaceregexp($newfile,
-find='[^a-z0-9.]', -replace='-');

I allow only lowercase alphanumeric characters, hyphen, and period.

I also sniff the file with magic to determine its MIME type and
use a proper file extension (I never trust the user).

--steve


On 8/10/18 at 7:06 AM, [hidden email] (Jolle Carlestam) pronounced:

>10 aug. 2018 kl. 06:52 skrev Steve Piercy - Website Builder <[hidden email]>:
>>
>>It depends on whether the OP wants to convert non-ASCII characters to the equivalent
>ASCII character stripped of diacritic marks, to another
>arbitrary character, or stripped away.
>>
>>For example:
>>
>>ü -> u
>>or
>>ü -> -
>>or
>>ü ->
>>
>>It seems they wanted the first option.
>>
>>Also consider whether case is important.
>>
>>Ü -> U or u?
>>
>>--steve
>
>I read his hopes that way too. But as I wrote, that is not a
>sound way to proceed. There are an endless amount of chars
>he’d have to look out for. Swedish, Danish, German alphabet
>all have their own quirky letters. French have all their á,à
>etc. There’s Spanish, Portuguese. What if some user throws in
>Arabic, Russian, Thai. And then there’s the endless fun with
>emojis. Why would someone not name their file "Ösig bild på
>Günther [insert your own emoji here].jpg”? I’ve had that happen.
>
>(Oh, and the reason I don’t actually put an emoji in my
>example is due to a bug in Lasso 9 preventing it from saving
>text with emojis to the DB. This affects Lasso talk as well.)
>
>In any case. If it’s a requirement I suggest implementing a
>couple of known non-ASCII characters to equivalent ASCII
>characters replacements and then run a catch-all regex on the
>result. Bils regex will catch all non-ASCII. I still think mine
>is better. It will make sure there’re only safe file name
>chars in the string. After all, some ASCII is not safe to use
>as file names.
>
>HDB
>Jolle
>
>#############################################################
>
>This message is sent to you because you are subscribed to
>the mailing list Lasso [hidden email]
>Official list archives available at http://www.lassotalk.com
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy              Website Builder              Eugene, OR
<[hidden email]>               <http://www.stevepiercy.com/>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Replace non-standard characters?

Bil Corry-3
Ideally, you'd randomly create a file name for the actual "on disk" file,
but present the file name as whatever the user wants when allowing it to be
downloaded or displayed on a web page.  Otherwise, the user could name it
".htaccess" or other badness.  Also, depending on the usage, you might need
to create a sub-folder system so that no one sub-folder has too many files
over the life of the solution.  Of course, if you're using AWS buckets,
then it doesn't matter.  Context is king!


- Bil

On Thu, Aug 9, 2018 at 10:25 PM, Steve Piercy - Website Builder <
[hidden email]> wrote:

> Indeed, this is part of what I do in Lasso 8, which the OP uses:
>
>     $newfile = $files->find('upload.realname'
> )->split('/')->last->split('\\')->last;
>     $newfile->lowercase;
>     $newfile = string_replaceregexp($newfile, -find='[^a-z0-9.]',
> -replace='-');
>
> I allow only lowercase alphanumeric characters, hyphen, and period.
>
> I also sniff the file with magic to determine its MIME type and use a
> proper file extension (I never trust the user).
>
> --steve
>
>
> On 8/10/18 at 7:06 AM, [hidden email] (Jolle Carlestam) pronounced:
>
>
> 10 aug. 2018 kl. 06:52 skrev Steve Piercy - Website Builder <
>> [hidden email]>:
>>
>>>
>>> It depends on whether the OP wants to convert non-ASCII characters to
>>> the equivalent
>>>
>> ASCII character stripped of diacritic marks, to another arbitrary
>> character, or stripped away.
>>
>>>
>>> For example:
>>>
>>> ü -> u
>>> or
>>> ü -> -
>>> or
>>> ü ->
>>>
>>> It seems they wanted the first option.
>>>
>>> Also consider whether case is important.
>>>
>>> Ü -> U or u?
>>>
>>> --steve
>>>
>>
>> I read his hopes that way too. But as I wrote, that is not a sound way to
>> proceed. There are an endless amount of chars he’d have to look out for.
>> Swedish, Danish, German alphabet all have their own quirky letters. French
>> have all their á,à etc. There’s Spanish, Portuguese. What if some user
>> throws in Arabic, Russian, Thai. And then there’s the endless fun with
>> emojis. Why would someone not name their file "Ösig bild på Günther [insert
>> your own emoji here].jpg”? I’ve had that happen.
>>
>> (Oh, and the reason I don’t actually put an emoji in my example is due to
>> a bug in Lasso 9 preventing it from saving text with emojis to the DB. This
>> affects Lasso talk as well.)
>>
>> In any case. If it’s a requirement I suggest implementing a couple of
>> known non-ASCII characters to equivalent ASCII characters replacements and
>> then run a catch-all regex on the result. Bils regex will catch all
>> non-ASCII. I still think mine is better. It will make sure there’re only
>> safe file name chars in the string. After all, some ASCII is not safe to
>> use as file names.
>>
>> HDB
>> Jolle
>>
>> #############################################################
>>
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy              Website Builder              Eugene, OR
> <[hidden email]>               <http://www.stevepiercy.com/>
>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Replace non-standard characters?

Jolle Carlestam-2

> 10 aug. 2018 kl. 07:32 skrev Bil Corry <[hidden email]>:
>
> Ideally, you'd randomly create a file name for the actual "on disk" file,
> but present the file name as whatever the user wants when allowing it to be
> downloaded or displayed on a web page.  Otherwise, the user could name it
> ".htaccess" or other badness.  Also, depending on the usage, you might need
> to create a sub-folder system so that no one sub-folder has too many files
> over the life of the solution.

This is my solution as well. Files are stored on disk with a lasso_uniqueid name. Original name is stored in a table and used when sending file to user. No cleaning up of file names done.
Files are stored in a per date folder ensuring that there’re not too many files in one place.

The cleaning up file name routine is used in a solution where the client wanted image files created on the server with names based on an ID value that they provided. In that case it was important to make sure that the provided value is actually usable as a file name, hence the cleaning.

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Replace non-standard characters?

Jussi Hirvi-2
In reply to this post by Brett Harvey
On 9.8.2018 17.34, Brett Harvey wrote:
> What’s the best way to replace non-standard characters in a file name?
> Characters like ä, ü, é, ç, ô  ?
>
> #string->(replace('ä','a'));  Doesn’t seem to work…

It works in Lasso 8.6, I just tested. I have been using that exact
replacement before, too.

var('a') = 'Näin tää menee.';
$a -> replace('ä','a');
$a;
=> Nain taa menee.

If it does not work, there could be incongruity between the encoding of
your input and that of your code.

- Jussi

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
12