Storing multiple lines of text in custom properties

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Storing multiple lines of text in custom properties

Post by gyroscope » Mon Mar 16, 2009 8:32 am

I've moved this from a previous thread, if that's OK (it was after one of my own posts, so I hought it might have got lost!)

I've now found yet another stack that is close to what I'm after but can't seem to work out putting more than one line of data into each field. The stack is called CustPropDatabase/Programming/Rev Online and in the "See Record" button is the following script (including the search):

Code: Select all

 on mouseUp 
  
  global gLineNumber 

  ask "Find what?" 
  if it is empty or the result is "Cancel" then exit mouseUp 
  put it into finne 
  set the htmlText of fld "kust" to the MittArkiv of this cd 
  put fld "kust" into tArkiv 
    
  repeat with i = 1 to number of lines of tArkiv 
    if finne is in line i of tArkiv then 
      put line i of tArkiv into tArkivLinje 
      put i into gLineNumber 
      --answer gLineNumber 
      
      --Puts the data into the various fields: 
      repeat with y = 1 to 5 
        set itemdel to comma 
        put "Title,Album,Composer,Artist,Year" into temp 
        put item y of temp into tField 
        set itemdel to "#" 
        put item y of tArkivLinje into fld tField 
      end repeat 
      exit repeat 
    end if 
  end repeat 
end mouseUp
I can't, for the life of me alter the last bit of the handler so that any more than one line of text appears in the appropriate text box. I have given it a whirl for quite a while but no success; I'm sure it's pretty much straightforward...

So could anyone help to amend the script, to allow for multiple lined text to appear in the appropriate fields please :?:

Philhold
Posts: 64
Joined: Thu Mar 05, 2009 3:39 pm

Post by Philhold » Mon Mar 16, 2009 11:56 am

Hi,

I'm very new to this but I think that there is a fundamental problem in the way the data is stored in that stack from the point of view of displaying multiple lines in a field. Because it stores the data as HTMLtext paragraphs are saved <p>like that</p> these act as delimiters as well as the # delimiter.

The example that Mark pointed you to on another thread "A Revolution Database.rev" appears to store the number of lines that are in a "field" in a "database" array". So the number of lines that should be returned to a field is described rather than delimited.

I would be interested to hear which is the best format for storing data in custom properties. I would prefer some form of "field" and "record" delimiter.

Cheers

Phil

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Mon Mar 16, 2009 12:24 pm

Thanks for your reply, Phil.
there is a fundamental problem in the way the data is stored in that stack from the point of view of displaying multiple lines in a field. Because it stores the data as HTMLtext paragraphs are saved <p>like that</p> these act as delimiters as well as the # delimiter.
I understand; perhaps not making the text HTMLtext might get it to work? I'll experiment with that.
The example that Mark pointed you to on another thread "A Revolution Database.rev" appears to store the number of lines that are in a "field" in a "database" array". So the number of lines that should be returned to a field is described rather than delimited.

That certainly is a neat stack by Mark but as there was no custom properties showing in the Inspector, my confusion concerning custom properties became worse, if that's the way to put it. I'll check it out again and see if I can understand it this time round. (I seem to be a slow learner with certain aspects of the Rev language... :( )

:)

Philhold
Posts: 64
Joined: Thu Mar 05, 2009 3:39 pm

Post by Philhold » Mon Mar 16, 2009 12:58 pm

(I seem to be a slow learner with certain aspects of the Rev language... Sad )
Me too!

Phil

Klaus
Posts: 14197
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Tue Mar 17, 2009 9:14 am

Hi all,

when it comes to store text in custom properties line by line, I usually "urlencode" the text, so any text (with or without pragraphs) will always be ONE line :-)


Best

Klaus

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Mar 17, 2009 9:32 am

Dear gyroscope,

If your property doesn't contain htmlText, just put the text into the field

Code: Select all

put the mittArkiv of this cd into fld "My Field"
Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Tue Mar 17, 2009 3:32 pm

Phil:
Me too!
Slow learners of Rev unite!

Thank you Klaus & Mark for info.

:)

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Thu Mar 26, 2009 8:00 pm

Hi, still battling this one. A good thing is custom properties have fallen into place with me (well, almost).

My main prob is to item delimeter the text but to allow chunks of paragraphs for each field in place of "item"

Klaus wrote:
when it comes to store text in custom properties line by line, I usually "urlencode" the text, so any text (with or without pragraphs) will always be ONE line "
Which would solve this problem, presumably keeping paragraphs as well?

OK, deleted something here, (must try harder to sort things myself first before posting on the Forum... :wink: ) off to try it now....

:)

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Fri Mar 27, 2009 1:32 am

Still failed here unfortunately, can't get URLEncode (or URLDecode) to work with the following code:

Code: Select all

on mouseUp
  
  global gLineNumber

  set the htmltext of fld "Database" to the DGCustProp of this cd
  put fld "Database" into TArchive


  --Order the record as 1 line delimited by "#"
  
  put "Title,Notes,Code" into temp
  --repeat with i = 1 to number of items of temp
     put fld "Title" & "#" after tMyVar
     put fld "Notes" & "#" after tMyVar
     put fld "Code" & "#" after tMyVar
  --end repeat
  
  --Ask to know if new record or changed old:
  answer "What will you save?" with "Cancel" or "Changed old record" or "New record" 
  
  if it is "Cancel" then exit mouseUp
  switch it
  case "Changed old record"
    put tMyVar into line gLineNumber of TArchive
put TArchive into fld "Database"
    break
  case "New record"
    --Puts the data of the record you just have filled in, after the last line of the archive:
    put tMyVar & return after fld "Database"
    
  end switch
  
  
  --Save the data back to the custom property:
  
  set the DGCustProp of this cd to the htmltext of fld "Database"
end mouseUp
And I've amended the code from the first post in this thread to:

Code: Select all

on mouseUp
  
  global gLineNumber

  ask "Find what?"
  if it is empty or the result is "Cancel" then exit mouseUp
  put it into finne
  set the htmltext of fld "Database" to the DGCustProp of this cd
  put fld "Database" into TArchive
   

  ---------------------original script
  
  repeat with i = 1 to number of lines of TArchive
    if finne is in line i of TArchive then 
      put line i of TArchive into TArchiveLine
      put i into gLineNumber
     answer gLineNumber
  
      
      --Puts the data into the various fields:
      repeat with y = 1 to 5
        set itemdel to comma
        put "Title,Notes,Code" into temp
        put item y of temp into tField
        set itemdel to "#"
        put item y of TArchiveLine into fld tField
      end repeat
      exit repeat
    end if
  end repeat
end mouseUp
Now if only I knew how to save and place complete chunks of text instead of just the first lines, i.e instead of itemDelimeter I need some sort of Text Chunk delimeter...

Because there are several ways to use custom properties for records, the code above seems closest to what I'm after, i.e Pressing a button saves all the contents (not just the first line though) of 2 or 3 fields then clicking on a list field, automatically puts the relevant text from the custom property back into he fields.

(I'm going down the route of having each button its own custom property and card, i.e all code snippets to do with animation on one card, all snippets to do with controls on another card, etc)

I hope I'm making sense here (it is past midnight again and I might be thinking with one brain cell :wink:). Any help appreciated or perhaps if I uploaded my Script collector stack someone could see what I'm trying to achieve?

Edit: I've decided to upload the stack, RevOnline>gyroscope>My Script Collector

Any help really appreciated, thank you.
Last edited by gyroscope on Sat Mar 28, 2009 2:01 am, edited 1 time in total.

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Fri Mar 27, 2009 8:02 pm

I'm still skirting this castle but getting a bit closer, I think...(there's a mixed metaphor!)

I've found some more code which I added into the ListField code:

Code: Select all

on displayData
      put the UserData[field "Notes"] of stack "Script col 2" into field "Notes"
   put the UserData[field "Code"] of stack "Script col 2" into field "Code"
end displayData
(This obviously is not enough as it would put the same info in the text boxes) whatever line was clicked....)

and in the single heading field:

Code: Select all

  set the UserData[field "Notes"] of stack "Script col 2" to field "Notes"
   set the UserData[field "Code"] of stack "Script col 2" to field "Code"
But I'm still stuck how to code to be able to xlick any particular heading in the list field which would bring up the necessary text in the Notes and Code field.

But perhaps I'm getting "warmer" :?: Actually, it's quite getting me down this, and I'm rapidly losing my enthusiasm for this project. :(

Post Reply