unicode ?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

ajperks
Posts: 103
Joined: Sat Sep 06, 2014 3:38 pm

unicode ?

Post by ajperks » Mon Oct 08, 2018 5:50 pm

I have a field with paragraphs of text in it. Each paragraph comes from users who may type RETURN to create paragraphs of their own. The resulting inputs are displayed in a text field as a series of paragraphs. Only a bold heading will show the start of each users input.

Think of a Facebook series of posts.

I wish to separate each users input in such a way that the count of paragraphs relate to the number of users, not RETURN key entries.
I wondered if inserting a Unicode character as the delimiter between users input rather than RETURN is the solution.
If it is, how do you set the delimiter? Is it like setting a TAB or Comma delimiter.
If so, how do you word/code the Unicode character?

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: unicode ?

Post by bogs » Mon Oct 08, 2018 7:40 pm

Sounds to me like what your looking for isn't unicode character or a delimiter, but to assign each user a 'token', which can then be used to delineate each paragraph.Unless you plan to use a unique unicode character for each user, which amounts to the same thing, but may become a bit difficult to implement as user numbers increase.

Tokens can be anything that is unique, for instance numbers. If you had 1000 users, you might setup a numbering system such as [0001 to 1000]. You might put an easy to find character (or character combo) at the beginning / end of the number that wouldn't normally be found in the text, such as @0050@ or #{0205}# which you could test for in an if / then statement or handler to create your paragraphs using delimiters and chunk expressions.
Image

ajperks
Posts: 103
Joined: Sat Sep 06, 2014 3:38 pm

Re: unicode ?

Post by ajperks » Mon Oct 08, 2018 8:57 pm

I am already thinking about a delimiter of a different kind.
It isn't as convenient as addressing a paragraph (in the sense of a clean one). For example, the five hundredth paragraph that has been clicked on is also the five hundredth record, directly. A delimiter has to be searched for amongst the clicked on text and then all those before it have to be counted...
I am also still considering the simple, effective, but somewhat uggly presentation of a line in a table field.
I prefer to explore the paragraph idea more fully.
Any good ideas?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: unicode ?

Post by dunbarx » Mon Oct 08, 2018 9:42 pm

Hi.

If i understand you correctly, inserting an untypable delimiting char (ASCII > 127) seems like the easiest way to separate, count and find paragraphs (records?). Untypable so there is no chance that char can ever find its way into print. I would choose one of the higher ones like numToChar(252), which, though not invisible, is nearly so.

Do you know all the tricks to find a word located somewhere among a string of items?

Or, does your content have to be visible? In other words, can your body of text be built as an array? You can then parse each paragraph by the keys of that array, in any way you want, with the text of the paragraph itself an element of a key.

Craig Newman

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: unicode ?

Post by FourthWorld » Tue Oct 09, 2018 12:05 am

ajperks wrote:
Mon Oct 08, 2018 5:50 pm
I have a field with paragraphs of text in it. Each paragraph comes from users who may type RETURN to create paragraphs of their own. The resulting inputs are displayed in a text field as a series of paragraphs. Only a bold heading will show the start of each users input.

Think of a Facebook series of posts.
A Facebook series of posts are separate fields, one for each post.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: unicode ?

Post by dunbarx » Tue Oct 09, 2018 12:25 am

You mentioned locating the paragraph "that has been clicked on". So my array idea is not applicable. You obviously have a scrolling field or table field, whatever, of all these entries.

On another note, you mentioned 500 or more entries? This is a bit ungainly, no? Unless only the bottom of the list is open for users to add their paragraph.

I can I assume you are familiar with the itemDelimiter?

Anyway. this goes back to those tricks I mentioned. If you click on a field of locked text, you can

Code: Select all

on mouseUp
   put the number of items of char 1 to word 2 of the clickchunk of me
end mouseUp
:

That sort of thing. There are others.

This will return the item (paragraph) clicked on, assuming the itemDel has been already set to your liking. I think a delimiter is the way to go.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: unicode ?

Post by dunbarx » Tue Oct 09, 2018 12:30 am

Richard makes a point, in that if you create a string of fields, where the user enters his post into a newly created one at the bottom, then the "last" field is the one of interest. The numbering (layering) of the fields is automatic. The "clickField" function would be of use here.

But then I do not yet understand what you intend. Is it that a user can click on any field in that pile? And is that the same as "any paragraph in that pile", assuming a single list field of some kind, that you originally suggested?

There are many ways to do things in LC. Le's make sure to start out with the best one.

Craig

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: unicode ?

Post by bogs » Tue Oct 09, 2018 10:50 am

dunbarx wrote:
Tue Oct 09, 2018 12:30 am
But then I do not yet understand what you intend.
Me either, apparently. I don't use or read FB myself, but the way ajperks worded that first post, it sounded (to me) like this~
..1.) has a field of paragraphs.
..2.) paragraphs come from users after hitting [Return].
..3.) paragraphs are separated by bold headings.
..4.) wants to separate each users input in such a way that the count of paragraphs relate to the number of users, not RETURN key entries.

That last line says (to me) that they want to tie each paragraph to a particular user, which means you need a token, not a delimiter. If it were a simple delimiter issue, you could indeed use anything, even the return key, but if your trying to tie to a particular user, your looking at tokens of some kind.

It can be a system as easy as I mentioned above (if its a small user base) or as complicated as necessary (probably a db and look-ups). In either case, a series of fields or a table would be better than squashing it into one open field, but again if it is small enough scale the field should be able to handle it with formatting.

I myself would probably be inclined towards a field with a table cell inserted below each paragraph heading, then back to the field for the next entry.
Image

ajperks
Posts: 103
Joined: Sat Sep 06, 2014 3:38 pm

Re: unicode ?

Post by ajperks » Tue Oct 09, 2018 11:41 am

Thank you all for your helpful suggestions.
I started out with individual fields that were generated by a script. Each had a number to the name for indirect addressing. The script was to quickly change size, spacing etc so the presentation looked its best.
I was trying to emulate a Facebook style.
The downside was the group was not easily formed to be scrollable. I tried scaling to gather the fields that would otherwise be off the screen and then enlarging to original.
I also considered a block of about 8 of these fields and 'paging' up or down.
So early on in development, the thing seemed unwieldy and I put it to one side.

Without wishing to compromise appearance and to advance development, yet not creating a dead end, I tried the basic table field.
With a suitable font, using bold and colour coding, the single lines without a grid showing looked feasible.
A DataGrid might be better and I might still have to use it. I prefer simple though and memory considerations on an unknown mobile is paramount. The block of 8 had advantages in this regard, loading data for 8 at a time...

I also considered a single text field, with scrolling, to contain many paragraphs, and cleaning the user text to remove all unwanted paragraph triggers, except the final one at the end of the post. Each paragraph would be truncated to 3 lines. A Bold informative heading, red for top views, black for no views, typical of a new post and a blank separator line. This would give the user a clue to content. By clicking somewhere on it, a partial overlay field would appear with the full scrollable post, would be loaded. By that I mean just the post from that one poster.
I think this would look familliar to Facebook users, but the app is not aimed at them, it has a higher purpose. Perhaps I shouldn't be constrained by what they have done? Certainly the extra mobile memory use is a big concern.
(Background to this memory concern comes from the drone user forum I subscribe to. The drone software is a big problem for small memory mobiles. I don't need that agro.)

Just for now, I will stick with the basic table field so I can proceed with development. I will divert to the server side app for the moment and get that part working. It might throw up issues I never imagined because this is all new ground for me.

One area that has taxed me, thinking about the server side, is how to add new addressable posts to the server and delete time expired posts. This is of course quite easy for just a few users. The posts must be addressable, because comments will be added to them. This means the comment to a specific post must be added to the list of its comments and then put back in the correct place on the server.
A feature of the system is that all posts expire and are deleted. Deletion leaves gaps in the list and these are filled with new posts. This makes addressing the posts on the server predictable, they will always be in the same place. Sorting occurs on the users device so newest are top, followed by top viewed ones. I worked on the basis that an old post is unlikely to be accessed by a user, commented on and put back after the original was deleted and replaced with a different, new one. The file would not be locked to read, so deletion would be possible.

If anyone has any thoughts or advice on this project, I would love to hear from you.
Thanks.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: unicode ?

Post by jacque » Tue Oct 09, 2018 5:00 pm

I'd probably go old-school with a regular LC field. Separate each user entry with an untypable character (I like ascii 3 or 8 which are consistent in any font). Text chunks can hold metadata, so you can set the metadata of the entire user entry to their name and date or anything else you need. Metadata isn't visible but scripts can retrieve it.

When parsing the entries, set the linedelimiter to ascii 3 (or 8 ) and that way the number of lines will be the number of user entries. Get the metadata of the line to extract the stored info about the entry.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: unicode ?

Post by FourthWorld » Tue Oct 09, 2018 7:12 pm

ajperks wrote:
Tue Oct 09, 2018 11:41 am
I started out with individual fields that were generated by a script. Each had a number to the name for indirect addressing. The script was to quickly change size, spacing etc so the presentation looked its best.
I was trying to emulate a Facebook style.
The downside was the group was not easily formed to be scrollable. I tried scaling to gather the fields that would otherwise be off the screen and then enlarging to original.
I also considered a block of about 8 of these fields and 'paging' up or down.
So early on in development, the thing seemed unwieldy and I put it to one side.
Creating custom controls can be a bit daunting when new to LiveCode. Fortunately a custom control is included which provides a very flexible foundation for things like this: take a gander at the DataGrid.

http://lessons.livecode.com/m/datagrid
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: unicode ?

Post by dunbarx » Tue Oct 09, 2018 8:24 pm

So, Jacque and I both suggest a delimiter. That means it HAS to be the way forward. :D

Bogs calls it a token.

Whatever we call it, it will be an untypable char that will parse the "paragraphs" uniquely, independent of how many returns, if any, the user includes in the text he adds. The itemDelimiter will be set to this character, and you can do anything you want to.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9249
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: unicode ?

Post by richmond62 » Wed Oct 10, 2018 7:11 am

This is a fascinating discussion, but I am not entirely sure why it is headed "unicode ?".

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: unicode ?

Post by bogs » Wed Oct 10, 2018 2:54 pm

dunbarx wrote:
Tue Oct 09, 2018 8:24 pm
So, Jacque and I both suggest a delimiter. That means it HAS to be the way forward. :D
...Bogs calls it a token.
Bogs was unaware of ~
jacque wrote:
Tue Oct 09, 2018 5:00 pm
Text chunks can hold metadata, so you can set the metadata of the entire user entry to their name and date or anything else you need. Metadata isn't visible but scripts can retrieve it.
SHAME ON BOGS!! Which just goes to show you how far I am behind the curve :? Bogs has now joined with Craig and Jacque's take on the subject. Bogs is just glad to know a regular field is still in the mix :P

Bogs also thanks Jacque for the illumination and information Image

@ Richmond ~ it was titled unicode because of the OP's set of questions at the bottom of the first post :
I wondered if inserting a Unicode character as the delimiter between users input rather than RETURN is the solution.
If it is, how do you set the delimiter? Is it like setting a TAB or Comma delimiter.
If so, how do you word/code the Unicode character?
However, while good questions, I think what Jacque proposed would be a better solution to the problem.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9249
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: unicode ?

Post by richmond62 » Wed Oct 10, 2018 4:34 pm

Richmond has suffered from 8 days of combined influenza and crappy internet: he has now
joined the consensus . . . for the moment.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”