Re: YAML Libraries

2020-01-21 Thread Trevor DeVore via use-livecode
On Tue, Jan 21, 2020 at 11:06 AM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Trevor, I'm curious what the significance is in using /** as the begin
> comment indicator? Is it something you use internally?


The comment syntax I use before a handler is the documentation syntax used
by LiveCode to create docs from scripts.

-- 
Trevor DeVore
ScreenSteps

>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: YAML Libraries

2020-01-21 Thread Bob Sneidar via use-livecode
Trevor, I'm curious what the significance is in using /** as the begin comment 
indicator? Is it something you use internally?

Bob S


> On Jan 19, 2020, at 06:45 , Trevor DeVore via use-livecode 
>  wrote:
> 
> /**


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: YAML Libraries

2020-01-19 Thread Trevor DeVore via use-livecode
On Fri, Jan 17, 2020 at 2:19 PM Sannyasin Brahmanathaswami via use-livecode
 wrote:

> I found the handler
>
> ## Monte's YAMLToArray command
> constant kMultiLineModeNone = 0
> constant kMultiLineModeLiteral = 1
> constant kMultiLineModeFolded = 2
>
> command YAMLToArray pYaml
>
> [snip] in the levure initialization behavior.
>
> I think that's it. There is no "ArrayToYaml"  but that is not needed.
>

BR - I'm glad you were able to locate the handler you need in the source
code. Here is a handler I use for printing out arrays as YAML when I'm
debugging or logging. It most likely could use some improvements but works
well for what I do with it.

-- 
Trevor DeVore
ScreenSteps
www.screensteps.com

/**
Summary: Prints an array using YAML.

Returns: YAML string
*/
function printArray pArray
  local tKeys, tKey, tYAML

  put the keys of pArray into tKeys
  sort tKeys numeric

  repeat for each line tKey in tKeys
put _outputKeyAsYAML(pArray, tKey, 1) & cr after tYAML
  end repeat
  delete the last char of tYAML

  return tYAML
end printArray


private function _outputKeyAsYAML pArrayA, pKey, pLevel
  local tIndent, tKey, tStr, i

  repeat with i = 1 to pLevel-1
put space & space after tIndent
  end repeat
  put tIndent after tStr
  put pKey & ": " after tStr

  if pArrayA[pKey] is an array then
put cr after tStr
repeat for each key tKey in pArrayA[pKey]
  put _outputKeyAsYAML(pArrayA[pKey], tKey, pLevel+1) & cr after tStr
end repeat
  else
if pArrayA[pKey] contains CR then
  put space & space after tIndent
  put "|+" & cr & tIndent after tStr
  replace CR with CR & tIndent in pArrayA[pKey]
end if

if pArrayA[pKey] contains "'" then
  replace "'" with "''" in pArrayA[pKey]
  put "'" & pArrayA[pKey] & "'" & cr after tStr
else
  put pArrayA[pKey] & cr after tStr
end if
  end if
  delete the last char of tStr

  return tStr
end _outputKeyAsYAML
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: YAML Libraries

2020-01-17 Thread Sannyasin Brahmanathaswami via use-livecode
I found the handler

## Monte's YAMLToArray command
constant kMultiLineModeNone = 0
constant kMultiLineModeLiteral = 1
constant kMultiLineModeFolded = 2

command YAMLToArray pYaml

[snip] in the levure initialization behavior.

I think that's it. There is no "ArrayToYaml"  but that is not needed.

BR

@Trevor DeVore I am not ready to "levurize" 
SivaSiva. (although it seems a good fit, I don't know what I getting into.. a 
bit "scary" ) But perhaps you have the libraries someone would need?
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


YAML Libraries

2020-01-17 Thread Sannyasin Brahmanathaswami via use-livecode
I am finding the constraints of JSON to be a bit, well, "constraining" , for 
use in small "data serializations". e.g. a list of 20 stories with various 
parameter, that you don't want to put in a database (for now, maybe later once  
the dBase design clarifies itself and the number of "stories" start to scale-up)

Looking at YAML, seems the perfect fit. But there are no "YamlToArray" or 
"ArrayToYaml" plug ins in the "inclusions"

@Trevor DeVore I am not ready to "levurize" 
SivaSiva. (although it seems a good fit, I don't know what I getting into.. a 
bit "scary" ) But perhaps you have the libraries someone would need?

BR
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode