Falcon and the Data description language

45 views
Skip to first unread message

Roberto Giacomelli

unread,
Jan 4, 2013, 6:00:45 AM1/4/13
to falc...@googlegroups.com
Hi all.
I'm new here. My first question is intended to asses a migration to Falcon from a Lua project that involves SQLite3/Postgresql and LaTeX as reporting tool. So the questions:
I have some data structured in the Lua table format, stored in a plain text file.
This is an example:
[code]
plant {
   id = 1,
   codicefabbricato = '8084.8101',
   stairs = 1,
   address = 'Cabrini Street',
   zipcode = '54027',
   number = '154',
   comune = 14,
   allPrivate = 2,
   allPublic = 2,
   miscode = '5450531531',
}
[/code]
This structure is a Lua table passed to the 'plant()' function.
Is there anything to similar in Falcon language?
How I can process this kind of data description format in the Falcon language?
Thank you.
Roberto

Paul Davey

unread,
Jan 4, 2013, 6:14:34 AM1/4/13
to falc...@googlegroups.com
Hi Roberto,

In falcon the equivalent data structure to the table is a dictionary, they are written as [ name => value, name2 => value2, ...] this can be used to replace the lua table.
The fact that lua treats name { ... } as a call is syntactic sugar which is not reflected in falcon so to achieve the same thing you would have to surround the dictionary in () so your example would become.

[code]
plant( [

   id => 1,
   codicefabbricato => '8084.8101',
   stairs => 1,
   address => 'Cabrini Street',
   zipcode => '54027',
   number => '154',
   comune => 14,
   allPrivate => 2,
   allPublic => 2,
   miscode => '5450531531',
] )

[/code]

If you kept the same scheme in falcon.



Roberto

--
You received this message because you are subscribed to the Google Groups "FalconPL" group.
To view this discussion on the web visit https://groups.google.com/d/msg/falconpl/-/v033V_qoRuwJ.
To post to this group, send email to falc...@googlegroups.com.
To unsubscribe from this group, send email to falconpl+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/falconpl?hl=en.

Giancarlo Niccolai

unread,
Jan 4, 2013, 7:21:41 AM1/4/13
to falc...@googlegroups.com
> --

We have a Json module that does pretty that; plus, it creates data that
is interchangeable with Java and Javascript.

Gian.

Roberto Giacomelli

unread,
Jan 4, 2013, 7:42:53 AM1/4/13
to falc...@googlegroups.com
Uhm,
I don't know JSON... Would you explain something to me with a basic code example?
Thank you.
In this moment I try to performe a connection to a SQLite3 database
It's my first Falcon script...
R.



2013/1/4 Giancarlo Niccolai <g...@niccolai.cc>
--
You received this message because you are subscribed to the Google Groups "FalconPL" group.
To post to this group, send email to falc...@googlegroups.com.
To unsubscribe from this group, send email to falconpl+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/falconpl?hl=en.




--
Roberto Giacomelli

Steven Oliver

unread,
Jan 4, 2013, 7:44:21 AM1/4/13
to FalconPL
Here is an example of using SQLite if that helps you any:


Steven N. Oliver

Paul Davey

unread,
Jan 4, 2013, 7:47:26 AM1/4/13
to falc...@googlegroups.com
JSON stands for JavaScript Object Notation.  It is a serialisation format that is mostly a subset of YAML. 

Basically it looks a lot like lua tables, but it also has arrays using square brackets so an example would be 

{
 a = "blah",
 b = 1
 c = [ 1, 2 ,3 ]
 d = [ "a", 2, "b"]
 e = [ { b = 3}, { a = 5}]
}

this will create an object (JSON name for a dictionary) with several members, a is the string blah, b is the integer 1, c is an array of integers 1 to 3, d is an array of mixed strings and integers, e is an array of objects.

Falcon has a module that can serialise and deserialise objects into JSON format for storing on disk or sending over a network.
Reply all
Reply to author
Forward
0 new messages