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: Klaus, FourthWorld, heatherlaine, kevinmiller

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

Re: unicode ?

Post by jacque » Wed Oct 10, 2018 5:14 pm

Bogs has now joined with Craig and Jacque's take on the subject.
As our numbers grow we shall prevail. Onward!
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: unicode ?

Post by bogs » Wed Oct 10, 2018 6:20 pm

richmond62 wrote:
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.
Sure hope your feeling better now my friend.
jacque wrote:
Wed Oct 10, 2018 5:14 pm
As our numbers grow we shall prevail. Onward!
(Pulling out my best Peter Lorre voice) Yes master!
Image

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

Re: unicode ?

Post by ajperks » Fri Oct 12, 2018 8:48 pm

Again, thank you all.
I took a step back and have decided to do as Jacque etc has suggested and use the text field.
Metadata was mentioned and I would welcome an explanation of what that actually is, in the text field context.


In addition, could I include an image.jpg in with the text?
If so, how is that achieved?

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

Re: unicode ?

Post by bogs » Fri Oct 12, 2018 11:38 pm

It is always wise to do as Jacque says, welcome to the club :D

You certainly can put images into fields with text, using 'imageSource'. Here is an example snippet I used first time I messed with it :

Code: Select all

repeat with x = 1 to the number of lines of the folders
      if character 1 of line x of the folders = "." then
         // pass it...
      else
         put "* " & line x  of the folders & cr after field "dirList"
      end if
   end repeat
   
   // put in the folder icons per line ...
   repeat with x = 1 to the number of lines of field "dirList"
      set the imageSource of char 1 of line x of field "dirList" to 1077
   end repeat
I ran similar code to put the image of the stack file into the list.
and here is a picture of the result :
Selection_001.png
File and folder images in a text field...
Selection_001.png (8.9 KiB) Viewed 392 times
*Edit - forgot your metadata question. Max's excellent wiki has the answer. In fact, it had lots of answers :wink:
Image

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

Re: unicode ?

Post by jacque » Sun Oct 14, 2018 5:22 am

Reading and writing from/to a field is one of the slowest operations LC does. If the OP is going to have hundreds of entries, adding an imageSource directly into the field for each line could get pretty slow. It would be more efficient to write the field's htmltext in a variable and set the content in one go using that.

We can help if it comes to that later.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: unicode ?

Post by bogs » Sun Oct 14, 2018 1:05 pm

I should point out that the example I posted was not intended for use in this application, but merely as an example of how to put an image in a text field. Although the code posted works quickly enough for what I used it for (a simple file browser), Jacque is quite correct that there are far faster ways to actually read / write the information, if you find doing it directly is too slow.
Image

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

paragraphs, text and images in a text field

Post by ajperks » Sat Oct 20, 2018 12:46 pm

Dear Jacque and all,
I have progressed another step with my project, as you wisely advised, and can put html into a text field with a non typeable character to separate each effective paragraph. I say effective from the script's point of view, because an effective paragraph might have grammatical paragraphs in it. I can now select an effective paragraph and isolate it by clicking.

I noted the issue of speed you mentioned regarding formatting html text in the field of effective paragraphs and it is a concern. I also noted the even slower inclusion of an image in the same text field.


What is the fastest way of including the images in with the text? I plan to save each post with its images in a text field and combine many of these posts as effective paragraphs in a single text field and convert to display as html.

How do I code for the images in with the text?

Thank you all

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

Re: unicode ?

Post by jacque » Sat Oct 20, 2018 8:30 pm

The fastest way is to write the html in a script and then set the htmltext of the field to the whole thing at once. If there are images involved it will still take slightly longer than if there are none, because the engine has to load the image and insert it, but at least it bypasses constant field access.

One of the best ways to determine what html you need to construct is to manually create one user's entry along with an imagesource, then "put the htmltext of fld <whatever>" into the message box and see what comes back. In the case of images, LC uses:

Code: Select all

<img src="1005" char="x"> this is the field text
This would be where the placeholder character for the image in the line is lower-case "x" and the inserted image has an ID of 1005.

You can store a template of the htmltext in a custom property with placeholder text that you would replace for each entry. For example:

Code: Select all

<p><img src="**ID**" char="x"> **TEXT**</p>
This would represent the structure of a single user entry. When you retrieve their text and image ID, use the "replace" command to replace **ID** with the correct image ID, and replace **TEXT** with the text of their entry (which will include the non-typeable paragraph separators.)

Continue adding new entries until you have an entire field's-worth and then:

Code: Select all

set the htmltext of fld <whatever> to tHTMLCollected -- your variable name here
Note that if you are storing entries in fields anyway, there will still be multiple field access when the engine retrieves the content. It would be faster to store the entries in a custom property or custom property set, so any field access is avoided entirely until the final insertion.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: unicode ?

Post by ajperks » Sun Oct 21, 2018 10:26 am

Thank you Jacque, this is most helpful. It will take me a while to work through it, so I might go dark on the subject for a while.
I am about to start work on the server element of the project now, so I can start using real data to see what holes I have dug for myself.

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

Re: unicode ?

Post by FourthWorld » Sun Oct 21, 2018 10:50 am

Will you be using LiveCode Server?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: unicode ?

Post by ajperks » Mon Oct 22, 2018 11:43 am

Hi Forthworld, You have raised a good question. It makes sense to use LiveCode Server, but at this stage, I know nothing about it.
Your question prompted me to find out more about servers. Obviously I will need to deal with the issue of high throughput of data, once I have everything up and running.
In my ignorance, the server software I need to write for my project seems quite simple. As a concept, it is just a table field where the first cell is a post and the cells to the right are comments relating to it.
After a set period, the whole line will expire and be deleted. That line can then take the next new post. I propose to adjust the size of the data by adjusting the expiry time and keep it to a small size. I don't envisage any industrial strength database. Sorting will take place on the device, the newest and most popular at the top.
New posts and comments to existing posts will arrive in a file at the server. Part of its file name will be the time it was sent, in seconds. The server cycles through and produces a file list. It sorts for time and stores appropriately, then deletes the file from the server folder. When the file list is empty, the server does the next stage of its program...
The user device reads the table field on the server directly and deals with the sorting prior to display. The total data block will be small enough to work on an older android device with just a Gig of memory. (As I see it at this moment. I expect I will be wrong, but who knows?)

Subject to bombarding the server with generated posts and comments, I will see how well it copes under load.
By then, the project will be demed to be working (or not) and it can be placed on a commercial server to see how it performs with generated data.

I expect you are all laughing at me, but I am enjoying programming again.
Just as an aside, In 1974, I wrote software to run on a HP65 programable calculator that experts claimed could only run on a mini computer. I proved them wrong.
Later, using BASIC and a Radio Shack TRS80 and one of their bog-roll plotters I created a timber frame house estimating and, production design and drawing program. Of all the thousands of different design of panels and components it plotted and printed out, everything fitted perfectly in production and on site.
It was at a time (1979) when CAD was in its infancy, as regards construction.

If anyone can see what problems I might run into, please let me know. I obviously need help...

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

Re: unicode ?

Post by bogs » Mon Oct 22, 2018 11:49 am

ajperks wrote:
Mon Oct 22, 2018 11:43 am
I expect you are all laughing at me
I doubt that :)
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”