NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: CaseyR on November 30, 2015, 03:56:30 PM

Title: Generating script strings with StringTheory
Post by: CaseyR on November 30, 2015, 03:56:30 PM
Hi, Bruce
Pretty sure I know that answer to this question but if I am wrong it will save a lot of work and potential bugs so here goes:
Is there a way to take the standard text you might find in a Javascript and double up or replace with ascii numbers all the < { ' characters using StringTheory.  Replacing < and { are easy, but I don't see any way to deal with single quotes.  For some reason, I thought I saw it in your session on StringTheory on ClarionLive, but couldn't find it when I reviewed the session. Thanks.
Title: Re: Generating script strings with StringTheory
Post by: kevin plummer on November 30, 2015, 08:02:27 PM
check out QUOTE in the clarion docs - it might be all you need.
Title: Re: Generating script strings with StringTheory
Post by: CaseyR on December 01, 2015, 11:00:13 AM
Thanks, Kevin.  At a loss as why I never noticed it before.
Title: Re: Generating script strings with StringTheory
Post by: CaseyR on December 01, 2015, 02:32:55 PM
Thanks again, Kevin, but the Clarion Language QUOTE does not handle single quotes despite the documentation.  QUOTE in the Template Language does though.

QUOTE( ' Test ' < {  Characters ' ),0) will yield the same compiler errors as MESSAGE( ' Test ' << {{ ')

Looks like a CODE template for building script strings is in order   
Title: Re: Generating script strings with StringTheory
Post by: kevin plummer on December 01, 2015, 03:59:56 PM
Correct - to use Quote you need to start with a valid string in the clarion language. Sounds like your code template might have potential.




Title: Re: Generating script strings with StringTheory
Post by: CaseyR on December 01, 2015, 05:33:50 PM
For anyone with the same problem, this code template will take your source text, convert it to a qualified Clarion string and append it to the packet.  Watch the line break on first line.

#CODE(ClarionString,'Packet Clarion String from Input'),DESCRIPTION('Packet Clarion String: '&%DescriptionText)
#!Double ups ' { < and appends to packet
#DECLARE(%ModifiedText)
#PROMPT('Text to append:',TEXT),%InputText
#DISPLAY('No start and end quotes')
#PROMPT('Description:',@s255),%DescriptionText
#SET(%ModifiedText,QUOTE(%InputText))
packet.append('%ModifiedText')