Counting words in a text widget

Hi,
Is there a way I can count the number of words in a text box widget?  I realise that means counting the number of words in the attached variable - but can I do this?
I have tried playing with Javascript (about which I know nothing)
I put the script below into the script window for a button, but nothing seems to happen!
Test=Q5WidgetAnswer.split(" ").length-1;
document.write(Test);
I want to check for three words in an answer and if there are only two, or four, warn that there are Three answers.
Would be grateful for any help!

After much heartache I solved the issue. 
The code needed to be as follows:
var objCP = document.Captivate;
var Answer = objCP.cpEIGetValue('WidgetAnswer');
var Words;
if(Answer ==  ''){   /* tests for empty answer */
  Words=0;
alert("Fred")
else {
Words = Answer.replace(/[^ ]/g,'').length+1;    /* counts the number of spaces in answer */
Where objCP can be any name you want, and cpEISetValue and cpEIGetValue are special Captivate functions
/* and */ enclose a comment

Similar Messages

  • How to count words in a text ?

    Hi all,
    can anyone show me how to count the number of words in a text.
    thank in advandce,
    Toan.

    Hi,
    Are you reading the text from a file or is it stored in a string buffer?
    The best way would be to use a StringTokenizer assuming that all your words are separated by a space ' ' you could use that as your delimiter.
    Something like..
    String text = "This is just a bunch of text stored as a string.";
    StringTokenizer words = new StringTokenizer( text, " ", false );
    int numberOfWords = words.countTokens();I hope that helps,
    .kim

  • How can I make the Counter move from inside text box to inside Footer?

    I am tweaking a page. At this point, I cannot move the Counter and the Email Me icon from the bottom of the text box to inside the footer like someone here said he does.
    Why do the Counter and the Email Me icon resist being moved?
    I am in Graphics mode. I never had this problem before.
    — Lorna in Southern California

    Lorna,
    I'm not sure why you can't move it down into the
    footer — by inside the text box, do you mean the page
    "content" or "body" section, or did you somehow get
    the icons into a text box? I know that you can
    "force" a text box into the footer (or header) by
    selecting it, then dragging it while holding the
    command (Apple) key down at the same time.
    Hope this helps.
    Bob
    Bob,
    When I say Text box maybe I am not using the right word. I am referring to that entire space on the page which is dedicated to receiving documents or images. If you have a lot of pictures or words, then that text box/space has to be lengthened to accomodate.
    I am saying that the two icons -- Counter and Email Me -- are sitting (or were sitting. It's morning now and honestly, I can't recall from last night!) at the very bottom of the text box/space.
    I made a Footer (55 pixels) specially to accomodate the Counter and Email icons. The problem, as stated, was/is that those icons would not budge from where they were sitting.
    — Lorna in Southern California

  • Counting words in a textArea

    Help !!
    I am trying to count the number of words contained in a text area - Is it possible to do this ?
    I am new to Java and I'm stuck because I only know how to write programs that use FileReader to count the number of words in a file.
    Is it possible to count the number of words in a string directly - or will I have to save the string to file and then apply another program to count the number of words ?

    You inser this code in your source file (TextArea1 is the name of the TextArea, whose you want to count words)
    String texte=TextArea1.getText();
    String rt=String.valueOf((char)13) + String.valueOf((char)10);
    StringTokenizer mots=new StringTokenizer(texte," ,.:;!?\t"+rt);
    int nbremots=mots.countTokens();
    and you place at the header of the file
    import java.util.StringTokenizer;
    nbremots is the number of words The delimitors between words are noticed in the second argument of the constructor of class StringTokenizer. I have choosen the main signes of punctuation like space, coma,stop... the String rt
    symbolise return on Windows. If you work on Unix prefer this code
    String texte=TextArea1.getText();
    StringTokenizer mots=new StringTokenizer(texte," ,.:;!?\t\n");
    int nbremots=mots.countTokens();
    You can also with the class StringTokenizer read the words one by one with this type of boucle
    while (mots.hasMoreTokens())
    String mot=mots.nextToken();
    mots.nextToken();
    It is an useful class. See the API about this class StringTokenizer in the package java.util

  • App for editing/reading/writing Excel, Word, Windows notepad text documents

    I was wondering if any of you's could recommend some apps (from experience) that would allow me to, edit/read/write Excel, Word, Windows notepad text documents.
    I could make do with an app that would do the above but without the ability to create, edit Windows notepad text documents. But been able to read, write, edit Word and Excel documents would have to be a must.
    Thanks in advance.

    Thanks everyone for the help it was much appreciated.
    After debating, I decided on Docs To Go at £9.99. For this amount its a universal app and as such I can have it installed on my iPhone as well as my iPad (which is what I have done), so £5 for to have it on each device is good value I feel. Quick Office on the other hand would have cost £8.99 for the iPad version and £5.99 for the iPhone version a total of almost £15, which is quite a bit more than I paid for Docs To Go.
    Upto now, I find Docs To Go does everything I want from it, with regards to editing, reading, writing my Excel files. I tried transferring a Microsoft Windows Notepad text document over to the iPad/iPhone, I was able to read this and also add additional text/words to it and save it too. I do use text documents sometimes because if I want to add them onto a friend's computer for example, I know that they will be able to read them because with them having a Windows PC and also my friend does not have the Microsoft Office program on their PC.
    The transferring of files from the computer to the iPhone/iPad is done via a free download of the Docs To Go desktop software program (which is both PC and Mac) compatible). You first need to go into the Docs To Go app and select 'ADD DESKTOP'. This then allows you to add a device to the Docs To Go desktop program thus enabling transfer. You are shown a pin number on the screen which you enter into the Docs To Go app, this procedure only needs to be done once.
    The Docs To Go desktop program creates a folder during installation, where all the files etc are stored that are transferred/going to be transferred over are kept.
    Some people might think needing to use a program to transfer files over is a bit of a nuisance, when other similar programs allow transfer via a web browser. Personally I find that those programs, the transfer is a bit cumbersome and can be a bit slow. I find the transfer via the Docs To Go desktop program is a lot easier and faster than using the web browser. The only downside I can see with needing to use the Docs To Go desktop program is that.. If I am at a friend's house and want to transfer something on to my iPhone/iPad. My friend would need to install the program, but saying that, its a very small program and its not a big deal having to install it. If they didn't want to install it, then there is either emailing the file or transferring the file to my Dropbox account. I forgot to mention that Docs To Go supports cloud/online storage such as Dropbox, GoogleDocs as well as others.
    Once the above is done, you switch the wifi on, load the Docs To Go app, load the Docs To Go desktop program. You then just drag and drop the folders etc that you are wanting transferred over into the The Docs To Go desktop program, then you click on the circular arrow button and they are then transferred over onto the iPhone/iPad.
    Once on the iPhone/iPad, you can view them, add additional information, when you make any changes you can press the circular arrow symbol (bottom left of the Docs To Go app) on the Docs To Go app and the changes are then synced back to the same file that is stored on the computer, so its very easy to keep everything in sync and up to date.
    It is possible whilst using a Microsoft Word document to have a word count, you just touch the symbol at the bottom right of the Docs To Go app and choose Word Count from the drop down menu. I have heard a few people in some reviews saying that 'Docs To Go doesn't have a word count', when indeed it does.
    One surprise is that Docs To Go, does not have a spell checker, but hopefully during later updates, the feature might be added. I sent my feedback to Docs To Go requesting this feature on future releases. I expect that there will be many other people who have requested this feature too.
    I just thought I would share my experience with using Docs To Go.
    Thanks again everyone for the help, it was much appreciated

  • Styling individual words in scrolling text interaction Captivate 7

    Does anybody know if it is possible to style only a portion of text that is being shown within the Captivate 7 scrolling text widget?
    For example, at the moment if I select a word that I'd like to make bold the entire content of the text pane is made bold, same with italic and underline.
    Any solution needs to be HTML5 compatible.
    Thanks in advance.

    Hi Sreekanth,
    It would definitely be useful if the styling worked properly, afterall, the options are shown in the editor so one can only think that it's a bug. I could even live with it if it accepted HTML markup.
    Re: your question, I put together a basic test using the Scrolling Text Interaction populated with lorem ipsum text and it seems to work as desired.
    I tested on Windows Vista Pro in Safari, IE9 and Chrome. I also tested on iPad running iOS7. I published in HTML5 only.
    The only thing (other than the styling issue mentioned above) was that the text pane seems to sit about 20px lower in the published file than it does on the Captivate stage. Not ideal when laying out individual content screens but not the end of the world to have to nudge the pane up in my working file.

  • CP8: Custom question using multiple TEBs / Scrollable Text Widgets

    Hi,
    I want to create a custom question with multiple Text Entry Boxes (TEBs) or Scrollable Text Widgets (STWs) that is compatible with HTML5.
    User has to enter just one word in each TEB / STW i.e. a one line STW.
    I want the user to be able to Retry the question i.e. click Retry button to automatically clear the TEBs / STWs that are incorrect.
    Question is not being scored or reported to an LMS.
    TEBs:
    I'm assuming you can't clear a TEB so I tried using a STW.
    STWs:
    FYI: I'm clearing the STW using Null.
    The issues I am trying to resolve are:
    1. Disabling the Enter key so that the 1 line STW will behave like a TEB i.e. doesn’t move to the 2nd line, and the Up Down scrollable indicators aren't displayed.
    There is a post that suggests executing JS on Slide Enter but I already have an Advanced Action associated with Slide Enter.
    https://forums.adobe.com/thread/1451011?q=disabling%20Enter%20key
    2. When retrying a question how do I disable STWs i.e. ones that contains a correct answer so user can't change it. (I know the Disable action won't work)
    I am using Captivate 8.0.1.242 on Windows 8.
    Thanks for your help.
    Regards
    Donal.

    Some answers, probably not all what you want. I blogged about using the Scrolling Text (formerly the TextArea widget) several times.
    In Captivate 8 you can indeed control what is shown in the Scrolling Text Interaction, by changing the associated variable. That was not possible before this version (have been begging for it, finally with success) and it is still not possible for a Text Entry Box. You can change the value of the variable, but it will not be visible in the TEB.
    An interaction is automatically reset when re-entering the slide, maybe that can help you as well? That is not the case for a TEB.
    Disabling  has no sense for an interaction that is static, only for interactive objects (and interactions). That means that you can disable a TEB, but not a Text Scrolling Interaction.
    Maybe this tip to prevent changing a correct answer for the interaction:  replace the interaction by a similar looking text container with the value of the variable if the answer is correct.

  • Count word without space in C#

    Dear sir,
    I would like to count word in sentence without space in c# but I could not solve this code.Please solve this one coding is below
                int i = 0,b=0;
                int Count2 = 1;
                for (i = 0; i < Paragraph.Length; i++)
                    if (Paragraph[i] == ' ')
                        for (b = i; b < Paragraph.Length; b++)
                            if (Paragraph[b] != ' ' && Paragraph[b] != '\t')
                                Count2++;
                                break;
                Console.WriteLine("Total Word = {0} .", Count2);

    Dear Sir,
    I want to count words without space in a Sentence but I face a problem that when I run the program space is also count with words but I want count only words Please guide . My C#  program is as under .
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Text.RegularExpressions;
    using System.IO;
    namespace Static_Method_Count_Word
        class Program
            static void Main(string[] args)
                Console.WriteLine("Please Enter Any Paragraph .");
                string Paragraph = Console.ReadLine();
                Count.Coun(Paragraph);
                Console.ReadLine();
        class Count
            public static void Coun(string Paragraph )
                int i = 0,b=0;
                int Count2 = 1;
                for (i = 0; i < Paragraph.Length; i++)
                    if (Paragraph[i] == ' ')
                        for (b = i; b < Paragraph.Length; b++)
                            if (Paragraph[b] != ' ' && Paragraph[b] != '\t')
                                Count2++;
                                break;
                Console.WriteLine("Total Word = {0} .", Count2);

  • Need help to add the words in a text file to an arraylist

    I am new to java and I really need some help for my project.I want to add the words of a text file to an arraylist. The text file consist of words and the following set of punctuation marks {, . ; : } and spaces.
    thanks in advance :-)

    I/O: [http://java.sun.com/docs/books/tutorial/essential/io/index.html]
    lists and other collections: [http://java.sun.com/docs/books/tutorial/collections/index.html]

  • How to set to bold a single word in the text box?

    How can I set to bold a single word in the text box? When I try, it puts the whole text bold.

    you should do this by HTML way
    like this :
    sym.$("your text box Name").html("Hello i'm <strong>Bold</strong> one")
    Zaxist

  • To get  a  word in the text  file

    Hi,
    I m beginner to java.
    HOw i get a word in the text file.
    I used this code, it is only display the all sentence which are available in the text file.
    But , I need to print particular word (if it is available in that text file)
    package com.beryl;
    import java.io.*;
    class FileReadTest {
    public static void main (String[] args) {
         FileReadTest f = new FileReadTest();
    f.readMyFile();
    void readMyFile() {
         BufferedReader dis =null;
    String record = null;
    int recCount = 0;
    try {
    File f = new File("E:/hello/abc.txt");
    FileInputStream fis = new FileInputStream(f);
    BufferedInputStream bis = new BufferedInputStream(fis);
    dis
    = new BufferedReader(new InputStreamReader(bis));
    while ( (record=dis.readLine()) != null ) {
    recCount++;
    System.out.println(recCount + ": " + record);
    } catch (IOException e) {
    // catch io errors from FileInputStream or readLine()
    System.out.println("Uh oh, got an IOException error!" + e.getMessage());
    } finally {
    // if the file opened okay, make sure we close it
    if (dis != null) {
         try {
    dis.close();
         } catch (IOException ioe) {
    Thanks & Regards,
    kumar

    I used this code, it is only display the all
    sentence which are available in the text file.
    But , I need to print particular word (if it
    is available in that text file)if
    String.indexOf()

  • Find a word in long text

    Hi,
    I need to find all the routing cards that don't contain a certain word in their long text. any suggestions???
    Eti

    Hi
    Please check in following links.....you will find some solution.
    How to search for a word in a text editor
    Search in long text
    Word Search
    search word for '.'.
    Regards
    Sujit

  • Counting words in a single cell in Numbers'09

    Hi there,
    I'm relatively new to Mac world, but I do have years of computer experience from a PC and have also had to do with Macs at the age of first eMacs . I have finally decided to switch to the brighter side of life (hopefully ;)).
    But here is my question: I need to count words in a cell in Numbers'09.
    Is there a specific function combination for achieving this? My idea was: strip excessive spaces, count the occurencies of all space character in a cell, add 1 and voila! Problem is I can not achieve it using formulas in Numbers'09. I have found some help for Excell but the formulas are a little different. And well, I would like to leave the past behind and stick to a Apple programs - if I can. I don't like the idea to install Excell on a Windows Bootcamp partion only for this purpose.
    Any help would be greatly appreciated. Thanks.
    Aleksander

    Badunit wrote:
    Yvan once had a list of all the different localizations. He may still have it.
    I'm late but, I was very busy
    The table with every localized functions names is (and will remain) available on my iDisk :
    <http://public.me.com/koenigyvan>
    Download :
    For_iWork:iWork '09:functionsNames.numbers.zip
    An easy soluce for foreign users (like me) is to duplicate Numbers.app and remove its languages resources minus English.
    Running it you will have it running in English (minus the decimal and the parameters separators, minus also date time formats and default currency).
    It would be easy to enter the formulas given in this forum.
    Once saved, we may open the doc in the 'standard' Numbers and the formulas will be automatically localized.
    Yvan KOENIG (VALLAURIS, France) mardi 2 mars 2010 18:30:45

  • How to count words in a PDF file?

    Is there any way I can count words in a PDF file without resorting to Acrobat Reader (which apparently has that feature)?
    That's a massive program, which I actually don't like.
    I need to count words in the PDF file because I write my papers with LaTeX, and they're full of my extensive comments.
    Do you know of any alternative?

    that utility IIRC cannot be found on xpdf (the official Archlinux package) anymore and its part of poppler
    edit: its pdftotext btw
    Last edited by dolby (2008-05-11 13:35:05)

  • How to copy paste a table structure from word document into Text Field [field format Rich Text]

    In our current implementation we have a Blank page with Text Field [field format Rich Text] on generated PDF Document.
    Once the PDF document is generated, user can copy paste content form any word/rtf document to into the Text Field.
    Pasted content retains all text formatting [Bold, Italic, Underline, Indentation] except the Table format. Text Field is removing table metadata from the content and converting it into plant text.
    Is there anyway to copy paste table structure as it is from word document into Text Field?

    Hi,
    I don't think you can! While you can paste formatted text into the rich text field, the table metadata means nothing to the textfield.
    Niall

Maybe you are looking for