From: "Robert Kjettrup" Received: from mail-lj1-f179.google.com ([209.85.208.179] verified) by media-motion.tv (CommuniGate Pro SMTP 6.1.0) with ESMTPS id 7112061 for AE-List@media-motion.tv; Fri, 06 Jul 2018 17:44:21 +0200 Received: by mail-lj1-f179.google.com with SMTP id c12-v6so9497660ljj.1 for ; Fri, 06 Jul 2018 08:52:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=I8fhp2JbTLzBMMB7eJ+YXGVdrp5CYD4EU3WNbacP2zI=; b=cIMyVaAdpXLCJ3pJ7/62eptd9LUq8uD/596KKuIK4R6SgGZaY6e/W/9Nynudjm7u5v YTNEuvOfygLUmRG1oFozevzuUDVP2OO5CBAAILQrz4NHhgzuDY7dBUBZs/LXjY5LeuKQ LN3aKiyjNHVij237tngDy8zc3+MY/HGL35WDf3YSFAxMcdRt3DmygVBcibXGuOjVT1NU pwLrJ7mjx2rjiaLj9QhAMEUV5+jDe2vjchnbUqvHA4O/As/ZFrJcvejNYUUWN/i8214i tpcEciN2ZWCV8gFUz7QMdMekc2MPUSpjIqPQk77nefI6lnLPZ/TzHJorUSctIb6/8P8a zz8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=I8fhp2JbTLzBMMB7eJ+YXGVdrp5CYD4EU3WNbacP2zI=; b=JHQ8MizcIwmZa4em5x9fbb9uWg9IkcuiolGKgkQAjaI9PIIrQm4if6BQB4ZYk4oy7Q iX976xXUivmqDWu2QvaQuqd8EGTKRAYwsDWJs1Wj+OKkgrYm+Rqhh9u+nVYhT3I0l9Gp JaDU8fEWRahHg2LdeaE+VO8M45SmhCvp5YCVCQ5G+sxF+E/0sQef0qE+TxZvVKfXErDm cYMZvY0wiuAOf7D9ELDm3FC6fz55l3DKIHB2N2Eq7HuHaM0ENQNhcT9PvqcqqG97W76U 07WPDRiXk3cc1YQFE4iWJueHP7SmgMOI4VUD+6HtE7OTQ0Kg4t1v69yTm0azh4iiReEh 1oPg== X-Gm-Message-State: APt69E3izsDj8YOoi28P7I+zgYMJYf6Py4PQgsuHuNc+HhBbGuBqRX02 j2ushKqJ1uyssVz5jmyKEHFLoxNTaak0Fx2P5+nxlw== X-Google-Smtp-Source: AAOMgpeGbAAkE50H8mjlLjjz5HrtCXSSOdeo4NA3Bcc+S1/xuKNjcDBSl+bcwcJAoNZm7lSgdNaH7FW+yASzmjjPotk= X-Received: by 2002:a2e:59d1:: with SMTP id g78-v6mr7390265ljf.79.1530892357916; Fri, 06 Jul 2018 08:52:37 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:2405:0:0:0:0:0 with HTTP; Fri, 6 Jul 2018 08:52:37 -0700 (PDT) In-Reply-To: References: Date: Fri, 6 Jul 2018 17:52:37 +0200 Message-ID: Subject: Re: [AE] Try Catch expression To: After Effects Mail List Content-Type: multipart/alternative; boundary="0000000000002eddf7057056a7de" --0000000000002eddf7057056a7de Content-Type: text/plain; charset="UTF-8" Hi Steve ofcourse i should do that instead, sometimes the answer is so obvious that you dont see it :-D... im already using sourceText.length for turning on/off layers so i dont know why i didn't think of this. Thank you Steve. much appreciated for getting me in the right direction The error was just a generic invalid numeric value: "invalid numeric result (divide by zero?)." it makes sense since it tries to return a value from a string character that doesnt exists. down to 0 errors now :-) 2018-07-06 17:09 GMT+02:00 Steve Zuranski : > I have not tested this and I have not done any AE scripting in years. Why > don't you inspect the length of the string before you attempt to read at an > out of bounds index rather than using a try catch statement? > > Also what do the error messages say? That will help in determining the > cause. > > // Get the length of the string. > txtVal = thisComp.layer("ab").text.sourceText; > fps = 1/thisComp.frameDuration; > Ch = 3; > length = txtVal.value.text.length; > > if(length >= Ch-1) { > txtVal.charCodeAt(Ch-1)/fps; > }else{ > 0; > } > > > On Fri, Jul 6, 2018 at 10:04 AM Steve Zuranski > wrote: > >> I have not tested this and I have not done any AE scripting in years. Why >> don't you inspect the length of the string before you attempt to read at an >> out of bounds index rather than using a try catch statement? >> >> Also what do the error messages say? That will help in determining the >> cause. >> >> // Get the length of the string. >> txtVal = thisComp.layer("ab").text.sourceText; >> fps = 1/thisComp.frameDuration; >> Ch = 3; >> length = txtVal.value.text.length; >> >> if(length >= Ch-1) { >> txtVal.charCodeAt(Ch-1)/fps; >> }else{ >> 0; >> } >> >> >> On Fri, Jul 6, 2018 at 6:07 AM Robert Kjettrup >> wrote: >> >>> Hi >>> >>> im using .charCodeAt() to get a Unicode value from a textlayer to >>> timeremap a precomp, this is working great to use custom graphics to type >>> out words. >>> >>> But im having a small problem with AE giving me an expression error if i >>> use the charCodeAt() to read from a chararcter there is higher than the >>> length of the textstrring of the text layer >>> >>> >>> This error is not really problematic since it renders fine.... but now >>> that i have set up a larger project i have the expression warning banner >>> tell me about 55 errors, and that is quite annoying. >>> >>> Now im trying to use the Try Catch to get AE to ignore this error and >>> not return a warning for each layer that has this expression reading >>> outside the length of a textstring... but i cant get it to work. >>> What am i doing wrong. >>> >>> the setup is as follows: >>> >>> a precomp with a bitmat characters setup at framenumbers that match the >>> Unicode value that .charCodeAt() returns. >>> >>> This expression on the TimeRemap property of each copy of the character >>> comp, this is character 3, aka copy 3 of this comp: >>> >>> >>> txtVal = thisComp.layer("ab").text.sourceText; >>> fps = 1/thisComp.frameDuration; >>> Ch = 3; >>> txtVal.charCodeAt(Ch-1)/fps >>> >>> >>> And the Try/Catch method i cant get to work >>> >>> txtVal = thisComp.layer("ab").text.sourceText; >>> fps = 1/thisComp.frameDuration; >>> Ch = 3; >>> try { txtVal.charCodeAt(Ch-1)/fps } catch(err) { 0 } >>> >>> >>> >>> and a link to a screengrab of a simplified version of my setup: >>> https://adobe.ly/2NtbdHv >>> >> --0000000000002eddf7057056a7de Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Steve

ofcourse i should d= o that instead, sometimes the answer is so obvious that you dont see it :-D= ... im already using sourceText.length for turning on/off layers so i dont = know why i didn't think of this.
Thank you Steve. much apprec= iated for getting me in the right direction


The error was just a generic invalid numeric value:
&quo= t;invalid numeric result (divide by zero?)."

<= div>it makes sense since it tries to return a value from a string character= that doesnt exists.

down to 0 errors now :-)



2018-07-06 17:09 GMT+02:00 Steve Zuranski <AE-Li= st@media-motion.tv>:
= I have not tested this and I have not done any AE scripting in years. Why d= on't you inspect the length of the string before you attempt to read at= an out of bounds index rather than using a try catch statement?

<= /div>
Also what do the error messages say? That will help in determining the= cause.

// Get the len= gth of the string.
txtVal =3D thisComp.layer("ab").text.sourceText;=
fps =3D 1/thisComp.frame= Duration;
Ch =3D 3;
length =3D txtVa= l.value.text.length;

if(length >=3D Ch-1) {
txtVal.charCodeAt(= Ch-1)/fps;
}else{<= /div>
0;
}<= /div>


On Fri, Jul 6, 20= 18 at 10:04 AM Steve Zuranski <szuranski@gmail.com> wrote:
= I have not tested this and I have not done any AE scripting in years. Why d= on't you inspect the length of the string before you attempt to read at= an out of bounds index rather than using a try catch statement?

<= /div>
Also what do the error messages say? That will help in determining the= cause.

// Get the len= gth of the string.
txtVal =3D thisComp.layer("ab").text.sourceText;<= /span>
fps =3D 1/thisComp.frameD= uration;
Ch =3D 3;=
length =3D txtVal.value.= text.length;

if(length >=3D Ch-1) {
txtVal.charCodeAt(Ch-1)/fp= s;
}else{
0;
}


On Fri, Jul 6, 2018 at 6:07 AM Robert Kjettrup <AE-List@media-motion.tv> = wrote:
Hi

im using .charCodeAt() to = get a Unicode value from a textlayer to timeremap a precomp, this is workin= g great to use custom graphics to type out words.

But im having a small problem with AE giving me an express= ion error if i use the charCodeAt() to read from a chararcter there is high= er than the length of the textstrring of the text layer


This error is not really problematic since it renders fine.... b= ut now that i have set up a larger project i have the expression warning ba= nner tell me about 55 errors, and that is quite annoying.

Now im trying to use the Try Catch= to get AE to ignore this error and not return a warning for each layer tha= t has this expression reading outside the length of a textstring... but i c= ant get it to work.
What am i doing wrong.

the setup= is as follows:
a precomp with a = bitmat characters setup at framenumbers that match the Unicode value that .= charCodeAt() returns.

This expres= sion on the TimeRemap property of each copy of the character comp, this is = character 3, aka copy 3 of this comp:


txtV= al =3D thisComp.layer("ab").text.sourceText;
fps = =3D 1/thisComp.frameDuration;
Ch =3D 3;
txtVal.charCode= At(Ch-1)/fps
=

And the Try/Catch method i c= ant get to work=C2=A0

txtVal= =3D thisComp.layer("ab").text.sourceText;
fps =3D= 1/thisComp.frameDuration;
Ch =3D 3;
try { txtVal.charC= odeAt(Ch-1)/fps } catch(err) { 0 }



and a link to a scre= engrab of a simplified version of my setup:
https://adobe.ly/2NtbdHv

--0000000000002eddf7057056a7de--