B4J Question [BANano] [SOLVED] Unexpected token on 1422

Mashiane

Expert
Licensed User
Ola

Can I please get advice on how to solve this? Do I need to escape the array values perhaps

B4X:
Sub BeautifyName(namx As String) As String
    namx = namx.trim
    If namx = "" Then Return ""
    Dim notCool As List
    notCool.Initialize 
    notCool.AddAll(Array("~", "!" , "@" , "#" , "$" , "%", "^" , "&" , "*" , "(" , ")" , "-" , "_" , "+" , "=" , "{" , "}" , "|" , "\", "]", "["))
    notCool.AddAll(Array(":", ";", "'", "<", ">", "," , ".", "?", "/"))
    For Each cn As String In notCool
        namx = namx.Replace(cn, " ")
    Next
    Dim sname As String = ProperCase(namx)
    sname = sname.Replace(" ", "")
    Return sname
End Sub

Transpiler output

B4X:
// [1417] Sub BeautifyName(namx As String) As String 
_B.beautifyname=function(_namx) {
var _notcool,_cn,_sname;
// [1418]  namx = namx.trim 
_namx=_namx.trim();
// [1419]  If namx = {895} Then Return {896} 
if (_namx=="") { return "";}
// [1420]  Dim notCool As List 
_notcool=[];
// [1421]  notCool.Initialize 
_notcool.length=0;
// [1422]  notCool.AddAll(Array( {897} , {898} , {899} , {900} , {901} , {902} , {903} , {904} , {905} , {906} , {907} , {908} , {909} , {910} , {911} , {912} , {913} , {914} , {915} , {916} , {917} )) 
_notcool.splice(_notcool.length,0,...["~","!","@","#","$","%","^","&","*","(",")","-","_","+","=","{","}","|","\","]","["]);
// [1423]  notCool.AddAll(Array( {918} , {919} , {920} , {921} , {922} , {923} , {924} , {925} , {926} )) 
_notcool.splice(_notcool.length,0,...[":",";","'","<",">",",",".","?","/"]);
// [1424]  For Each cn As String In notCool 
for (var _cnindex=0;_cnindex<_notcool.length;_cnindex++) {
_cn=_notcool[_cnindex];
// [1425]  namx = namx.Replace(cn, {927} ) 
_namx=_namx.split(_cn).join(" ");
// [1426]  Next 
}
// [1427]  Dim sname As String = ProperCase(namx) 
_sname=_B.propercase(_namx,_B);
// [1428]  sname = sname.Replace( {928} , {929} ) 
_sname=_sname.split(" ").join("");
// [1429]  Return sname 
return _sname;
// End Sub
};

I know I can just write a different sub to do this by just getting anything meeting "abcdefghijklmnopqrstuvwxyz0123456789 "

Thanks.
 
Top