String Character Assignment Problem

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
User avatar
mytekcontrols
Posts: 95
Joined: Sun Aug 19, 2007 6:38 pm
Location: Santa Rosa, California
Has thanked: 4 times
Been thanked: 7 times
Contact:

String Character Assignment Problem

Post by mytekcontrols »

I just ran across this today.


If you try to do the following in a String Manipulation Box: cursor = "\"

You'll get the following error when clicking on OK:

One or more string manipulation lines are invalid.

- or -

If you try to use the following in a Calculation Box: cursor[0] = '\'

You'll get this error when trying to compile:

Flowcode was unable to compile the flowchart's C code due to the following errors:

If your flowchart contains C code, please review this carefully.
If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.



In both cases this only seems to happen when trying to use the "\" character.

Any ideas or work-a-rounds?
Michael St. Pierre
FlowCode V3&V4 Pro Registered User
Manufacture: Heat Load Controllers,
and a variety of other widgets.

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

The "\" character is used as an "escape" character to allow you to enter special characters into a string. For example:

Code: Select all

\n = a carriage return
\t = tab
\" = quote
\\ = backslash
Unfortunately, it looks like the latter does not work well with the LCD component. The simulation does not work (it displays 2 backslash characters).

It does work correctly in hardware, but the backslash character in the LCD character set is replaced with a yen symbol (I think).

User avatar
mytekcontrols
Posts: 95
Joined: Sun Aug 19, 2007 6:38 pm
Location: Santa Rosa, California
Has thanked: 4 times
Been thanked: 7 times
Contact:

Post by mytekcontrols »

Hi Steve,

I tried cursor = "\\" in the String Manipulation Box and it still chokes, although cursor = "\n" is accepted (but unfortunately not what I want).

Just to give you an idea of what I am trying to do, this is the actual string I wish to define: cursor = "|/-\|/-\" This will be used within a loop, where I will extract 1 character at a time (in sequence) and display it as a rotating cursor on the LCD.

Pseudo code:

Define Variables: cursor[8], ctemp[1]

String Manipulate: cursor = "|/-\|/-\" (initialize)

While 1 (main loop)
LCD Cursor: Home,0 (position cursor)
Calculation: ctemp[0] = cursor[loop]
LCD PrintString: ctemp
Calculation: loop = loop + 1 (move pointer to next character)
If loop >= 8 then loop = 0
Delay: 50ms
Wend


If the "\\" would work as you mentioned, this would be acceptable for forming the string. example String Manipulate: cursor = "|/-\\|/-\\"

Any possibility that this can be made to work in the next FlowCode update?
Michael St. Pierre
FlowCode V3&V4 Pro Registered User
Manufacture: Heat Load Controllers,
and a variety of other widgets.

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

You may not be able to get this to work because the LCD character set does not have a backslash character - at least, mine doesn't.

User avatar
mytekcontrols
Posts: 95
Joined: Sun Aug 19, 2007 6:38 pm
Location: Santa Rosa, California
Has thanked: 4 times
Been thanked: 7 times
Contact:

Post by mytekcontrols »

:o You're right!! I was so intent on resolving the code problems, I hadn't even considered whether all the symbols I chose were displayable.

I'll have to re-think this :D

However it probably would be good to have the back slash problem fixed for devices that can display it, such as a CRT terminal connected via RS232.
Michael St. Pierre
FlowCode V3&V4 Pro Registered User
Manufacture: Heat Load Controllers,
and a variety of other widgets.

User avatar
mytekcontrols
Posts: 95
Joined: Sun Aug 19, 2007 6:38 pm
Location: Santa Rosa, California
Has thanked: 4 times
Been thanked: 7 times
Contact:

Post by mytekcontrols »

I have come up with a solution for the spinning cursor program missing a Back Slash "\" character. I found a display with an enhanced character set, that just happens to include the missing character (New Haven p/n M0216MD-162MDBR2-J). This is actually a large digit, 2 line x 16 character Vacuum Fluorescent Display that uses a standard LCD interface.

The only problem is that the "\" is not mapped into the standard ASCII position for this character, so it did require a slightly different approach as I have listed below.


Pseudo code:

Define Variables: cursor[4], ctemp[1]

Equate String to = Spinning Cursor Characters:
cursor[0] = '/'
cursor[1] = '-'
cursor[2] = 140 (140 = mapped "\" character location)
cursor[3] = '|'

While 1 (main loop)
LCD Cursor: Home,0 (position cursor)
Calculation: ctemp[0] = cursor[loop]
LCD PrintString: ctemp
Calculation: loop = loop + 1 (move pointer to next character)
If loop >= 4 then loop = 0
Delay: 50ms
Wend

In the above program I also figured out that I only needed to construct a 4 character string array to hold my animated spinning cursor characters (I don't know what I was thinking in my first example, where I had defined an 8 character array).

By the way, this will also work on a Noritake-itron CU16029ECPB-W1J Vacuum Fluorescent Display as well, although the New Haven display will cost you considerably less. The reason I decided to use a Vacuum Fluorescent Display instead of an LCD is because I really like the high contrast blue/green display. For someone that still wishes to use an LCD, I would imagine that these companies (or others) probably also manufacture an LCD with the same enhanced character set. And of course one could also make use of the CG RAM to serve up a custom character that was pre-defined as "\" as well.

End Result: It looks really cool :D

NewHaven 2x16 character (31mm x 108mm Actual Display Area) VFD Display ($45): http://www.newhavendisplay.com/index.cf ... prd150.htm
Michael St. Pierre
FlowCode V3&V4 Pro Registered User
Manufacture: Heat Load Controllers,
and a variety of other widgets.

Post Reply