• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to concatenate a carriage return or new line to a captivate variable?

Guide ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

I need to provide more detailed feedback than captivate makes possible based on what users do in questions.  I've got this mostly working, but I need to put the feedback for each question on a new line.  Captivate has resisted my best efforts to make this happen.

Any suggestions?

Thanks in advance!

TOPICS
Advanced

Views

7.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Oct 18, 2011 Oct 18, 2011

OK, this does work with the TextAreaWithVariables widget, but not the TextArea widget that comes with Captivate. And it does not add to the file size.

Thanks, Steve, Lilybiti, and Jim, for sticking with me!

Votes

Translate

Translate
Community Expert ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

AFAIK you cannot insert a CR in a variable. You are using variables to display the feedback in a Text Caption? A particular reason?

The only way I was able ever to have new lines in a variable was by inserting the text in the TextArea widget, where you can use Enter for new lines, and since this widget is associated with a variable, use that variable later on in a TextArea. Just FYI

Lilybiri

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

Lilybiri;

What other options are there for displaying variable text on the screen?  I am relatively new to Captivate, so if there's some other thing I could do, I'd use it.  But the problem remains of how to get the new line into the variable in the first place.

Who makes the text area widget?

Thanks;

Amy

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

The TextArea widget is included in Captivate. Jim (who answered about \n which is working fine for me) extended this widget (free to download) so that one can manipulate the variables with advanced actions, but for the use case I described you do not need the extended version.

Was asking why you do put the feedback text in a variable? If you explain goal and present work flow, perhaps I could understand better, to offer advice.

Displaying the content of a variable on the stage is by inserting it in a Text Caption, using the X-button in the Format accordion of the PI of the Text Caption.


Lilybiri

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

The goal is, for each question missed, to record the question stem and which lesson they should review to get it right next time. The team is not using the review option because it shows the right answer, and for whatever reason they want to force the learner to go back and review the lesson (and think this will have that effect).

So on the quiz review page, we need to present this information.  I believe that we can do this entirely within Captivate without having to resort to JavaScript if we can get beyond the carriage return issue.  I have retried both \n and \r, and neither works.  Is it possible that this is something that was added in 5.5?  If so, maybe I can persuade the powers that be to upgrade.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

OK, the solution I used is to use the enhanced TextArea widget, which correctly interprets \n as a new line, rather than literally displaying \n on the screen, as a caption does.

Thanks, Jim and Lilybiri!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

Try using \n (for a new line)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

Whow, thanks Jim, this works great.


Do you have other similar tricks?

Lieve

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

I tried \n and also \r, and it just put \n or \r as a string onto the screen.  I can try again and see what happens.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

Hi Amy,

Advanced actions are froggy with the + plus sign.  Are you trying to conctenate a line break to the END of a string?  You already know this... but for future readers of this post, the plus sign can mean addition of two numbers, or the concatenation of two strings.  So doing 1 + 2 returns 3.  But '1' + '2' returns '12'.  I've learned by trial and error that if you concatenate a line break to the end of a string:  'foo' + '\n', nothing happens.  If you add another string to the end it will work.  'foo' + '\n.' (added a period)

Then what I do is make that last period '.' the same color as the background and no one sees it.  The other option is to use MANY line breaks 'foo' + '\n\n\n\n\n\n\n\n.' then the period gets pushed down beyond the visibility of the text caption and no one can see that either.  This is how I've added line breaks to the end of a string.

Hope that helps,

Jim Leichliter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

Hi, Jim;

What I'm doing is using two expressions, because there's no way to say myVar + delimiter + 'someText'.  So I use an expression myVar + delimiter and another myVar + 'someText'.  (Obviously, I separated delimiter out to its own variable because all of this stuff is so crap in Captivate.)

The problem I am having is not that the new line isn't being added to the string (it is), but that Captivate is showing

MyText\nMyOtherText

instead of

MyText

MyOtherText

I think it would be really interesting to see how you make one character in a variable some other color, because so far the captivate variables have resisted my efforts at formatting.

I'm also finding that now the advanced widget isn't actually working with the \n as the delimiter character, even though it was before.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

Lillybiri & Jim;

Would one of you mind giving me a sample file with this working?  I had it working at one point with the text area with variables widget, but I did not save that version of the file and now nothing I am trying will work.  Steve tried it with his Captivate 5.5, and that is not working either.

Thanks;

Amy

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

Have it working... but it's kinda hacky...

Working demo:

http://captivatedev.com/demo/cp5/linebreaks/linebreakdemopub.htm

Download .cptx 5.5 file:

http://CaptivateDev.com/demo/cp5/LineBreaks/LineBreakDemo.zip

Amy Blankenship wrote:

I think it would be really interesting to see how you make one character in a variable some other color, because so far the captivate variables have resisted my efforts at formatting.

Yeah... brain was in left field when I wrote that.  That definitely won't work.

Here's the jist of what I did.

Created a user variable called "nl" for new line.  The default text for this variable is .\n (notice the period).  This trick enables Cp to concatenate the line break as a string (funny how that trick won't work in the advanced actions panel when used as a string literal).  The "hacky" part is that this also adds a period to the end of your string so it wont be suitable for every situation.

Simple things like this should not be so difficult.  Hopefully Cp 6 will be different, but notice I'm not holding my breath.

Jim Leichliter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

I don't want to sound ungrateful, but I'm pretty sure I can't open this in Captivate 5.5.

What I've been doing to get the \n into a string is a hidden text entry populates my delimeter variable.  As I said, this successfully gets added into the string--it's clearly visible there as itself, rather than a new line.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

OK, so the .\n works, but if I put a literal string

This text\nThat text

It doesn't convert \n to a new line.  And this is part of what I need to have happen as well.

<Sigh />

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

Hi Amy,

Didn't realize you were working in Cp 5.  I've updated the sample for a Cp 5.0 project if you want to download it... but it looks like you have it almost working.  Can you share a demo file?  Take a look at the advanced actions and see if that might work in your situation.

Thanks,

Jim

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

If you put "line 1 \n line 2" for the default value of a variable... then display that in a text caption, it does the line break.  But you're trying to do this from the Advance Actions panel correct?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

Amy,

That is what I thought as well based on your subject, that you wanted a variable in which a line break is inserted.

If you tried it another way, please could you post a screenshot of the advanced action you used?

Lilybiri

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

I'm actually doing this from the Assign in the enter frame action.  But even if I use a text area widget for it and try to use that value, it fails.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

Amy,

With Assign you can only put one value into a variable. What did you assign to what?

Lilybiri

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

I have a questionTopic variable that I populate in the assign of each frame (with the question and the topic, supposedly separated by a new line character).  This makes it possible to use the same advanced action in every "last attempt" action to assign the feedback.  Except for this glitch.  I suspect the engineers helpfully wrapped whatever you assign here in CDATA.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 14, 2011 Oct 14, 2011

Copy link to clipboard

Copied

OK, so I reached a compromise on the language which means we don't need a new line inside each questionTopic assignment.  However, I'm finding that when the assignment includes the words "not" or "or," the assignment treats it as an evaluation and my string becomes "true" or "false."

I have tried escaping the or with a back slash, which then shows on the screen.  I have been able to work around "not" by breaking our writing standards by using a contraction.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 15, 2011 Oct 15, 2011

Copy link to clipboard

Copied

Amy,

Sorry to be stubborn,  but I still do not get it. My intuition tells me you are making it too complicated, perhaps due to your background with more sophisticated apps. You cannot assign a new value on each frame, there is almost no control over frames (besides navigation), and the only events you can use for actions are slide events and Success/Failure for interactive objects. If I could 'see' what you want to achieve, perhaps I could offer a 'simple' approach because of my background with 'simple' Captivate

Lilybiri

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 17, 2011 Oct 17, 2011

Copy link to clipboard

Copied

I have created a file that shows the bug that you can download at ftp dot magnoliamultimedia dot com .

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 18, 2011 Oct 18, 2011

Copy link to clipboard

Copied

Hi Amy,

Got the file. Can I summarize what you want to do, and could you check if this is correct?

  • On each slide you want to display a text caption, but only after the button 'Click me'
  • The only varying part is stored in the user variable captionText and assigned on entering each slide
  • The text caption (presently having only the variable 'feedback') contains:
    • fixed text, presently stored in the variable 'variableFoundation'
    • a CR
    • the text stored in captionText (only varying part)

If this is correct, my Captivate intuition would replace this by a Text Caption that is initially hidden, and will be shown by the Click me button; in this caption I would put the fixed text, the CR with Jim's method of \n and the variable captionText. Although I'm an advanced action freak, I do not think you need an action at all, just show the text caption. Unless of course I'm misunderstanding everything.


Lilybiri

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources