Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 2:21 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Script for checking how long (in characters) a variable is
PostPosted: September 15th, 2010, 4:15 pm 
Offline

Joined: December 21st, 2009, 5:26 pm
Posts: 27
Opus: Professional 7.03
OS: XP SP3
Hi,

I'm trying to show up to three different text boxes based on how many characters are contained in a variable, however I have no idea how to do this and doing a quick search on these forums hasn't come up with anything.

To be clear, the variable I want to use to do the check on will just contain single words, e.g ant, queen, xylophone etc. It will only be one word at a time.

Any help regarding this matter would be much appreciated.


Top
 Profile  
 
 Post subject: Re: Script for checking how long (in characters) a variable
PostPosted: September 15th, 2010, 6:02 pm 
Offline

Joined: November 3rd, 2004, 2:11 pm
Posts: 323
Check the OpusScript Help file.

var welcome = "Hello"
strLength = welcome.length

At least that's what I think you are after.

_________________
Opus Pro XE 9.1 Win7 64-bit Core i3 8MB RAM


Top
 Profile Visit website  
 
 Post subject: Re: Script for checking how long (in characters) a variable
PostPosted: September 15th, 2010, 9:06 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Jammy,

Here's another approach. But instead of using 3 Text Objects, use one and resize it (plus have an additional hidden Text box).

First, set up the 'hidden' Text Object making sure it uses the same font and size you will use for displayed text. Make this object long enough for the longest word you anticipate. Let's call this Text000

Insert your variable, for example, TheWord1.

The rest is simply a matter of finding the X-coordinate of the last character in Text000.
e.g., var charInfo = Text000.PointFromChar(String.length(TheWord1) -1) //you need to verify this, test this to make sure of using correct zero-based index.

Now, supposing you have created that one Text Object to display the text using the same TheWord1 variable... call it TextObj01, resize it to lengthen or shorten its width. Hint: Use charInfo.x from above.

How to resize TextObj01? Do a search on the forum for 'SetObjectSize'.
There are a couple other ways to change the object's dimensions and position. But you get the idea.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 43 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group