Source language: Translate to:

insert question.

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

insert question.

Postby frednet » Tue May 01, 2012 1:44 pm

In a project I store several lines of a playlist in an array.
every line in the array tels several players which page to play.
the array can have a hundred lines.
every line is linked to a page number that can be programmed

The problem is that i'm not able to insert a line in the array.

I tried to use the basic database plugin, but unlike in a spreadsheet I'm not able to insert a new record, it only appends records.

Am I overlooking something obvious or is it not an easy thing to do?

Thanks Fred.
User avatar
frednet
 
Posts: 83
Joined: Fri Sep 23, 2005 4:29 am
Location: netherlands

Postby Gaev » Tue May 01, 2012 4:40 pm

Fred:

Databases always append new records ... but they can be made to display records in a sorted order ... so what you can do is have a field in the database called SortOrder ... and then ask to view the records sorted by this field.

Some tips for easy maintenance ...

1) when adding a record (playlist line), assign SortOrder numbers in increments of 1,000 or 10,000

2) so when you want to insert a line between SOrtOrder of 1000 and 2000, assign it a SortOrder of 1500 ... and then 1250 or 1750 etc.


If you run out of numbers ... e.g. you need to insert between lines with SOrtOrder of 1201 and 1202 ... you have to export the records (or copy them to another Database Table) ... in the SortOrder ... and then reload them with a new SortOrder that is spaced again by a 1,000 or 10,000.

P.S. Make sure the SortOrder field is defined as numeric ... because text fields will sort like this ...

1
10
101
102
11
110
12
13
...
19
2
20
21
...
29
3
etc.
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby frednet » Wed May 02, 2012 10:25 am

Gaev;
Thanks for pointing that out to me.
Most easy thing for me would be to export the array to a database to openoffice calc, edit it there and import the re edited version.

regards Fred
User avatar
frednet
 
Posts: 83
Joined: Fri Sep 23, 2005 4:29 am
Location: netherlands

Postby TechMediaPlugins2010 » Wed May 02, 2012 10:56 am

what is the dimension of the array?
Advanced Plugins for NeoBook
www.techmedia-plugins.com.br
TechMediaPlugins2010
 
Posts: 298
Joined: Wed Jun 23, 2010 1:45 pm
Location: Rio de Janeiro - Brazil

Postby frednet » Wed May 02, 2012 12:17 pm

TechMediaPlugins2010 wrote:what is the dimension of the array?


it contains a namestring, and fourteen variables for each row.
maximumnumber of rows about 80 to hundred.

each row is linked to a pagenumber in the neobook

so the variables list is something like:
page no x : (name)( x), (p1) x,(p2) x,........ (d1) x,(d2) x, etc.

where p stores the page to be played and d contains a delay option for each player

Thanks Fred.
User avatar
frednet
 
Posts: 83
Joined: Fri Sep 23, 2005 4:29 am
Location: netherlands

Postby dec » Wed May 02, 2012 12:30 pm

Hi there,

I'am not sure, but maybe my npStrs plugin can help you. This plugin allow you mantain an string list on memory and provide lots of actions to deal with it. For example, it's possible to insert an specific item in certain position. Also the plugin allow you to deal with list of pairs of keys and values, with an easy way to retrieve keys and values separatelly, short the strings, search for strings, allow or disallow duplicates, load/save the list from/to a file, appropiate events to react when the list change, and many more.

Maybe you want to take a look at them. If not, please, excuse me and ignore this message. ;)
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Postby TechMediaPlugins2010 » Wed May 02, 2012 1:58 pm

A "dirty" method that i can think, is create a new array and populate it with lower and upper bounds of the old arry, puting the new value in between. I don't know how fast it will be performed, but is is a lot fast than write to a DB and retrieve it back

Say, you have an array with 80 elements. Create a new array with 81 elements. You want to insert the values in row 39.
Make a for loop from 1 to 38, populate the new array with this data. Insert the new value on pos 39 on new array, make another loop from 39 to 80 and populate the new array. It is a dirty method, without doubt, but it will work.
Advanced Plugins for NeoBook
www.techmedia-plugins.com.br
TechMediaPlugins2010
 
Posts: 298
Joined: Wed Jun 23, 2010 1:45 pm
Location: Rio de Janeiro - Brazil

Postby frednet » Wed May 02, 2012 2:27 pm

TechMediaPlugins2010 wrote:A "dirty" method that i can think, is create a new array and populate it with lower and upper bounds of the old arry, puting the new value in between. I don't know how fast it will be performed, but is is a lot fast than write to a DB and retrieve it back


Now that is a very good suggestion, at the right moment.
Just spend several hours trying to import from openoffice calc to the basic neobook plugin. open office acting weird with dbf file. enough of that.
Going to follow your suggestion,


Years ago I wrote this thing to be able to synchronize video playback of several computer. Its use is to have multi image projections in the theater plays I work on. This time the director wants to have all scenes happen in a digital projected stage. 22 scenes and several audio inserts as wel. so manualy rewriting all takes seems no option this time.

Thanks a lot for sharing.
User avatar
frednet
 
Posts: 83
Joined: Fri Sep 23, 2005 4:29 am
Location: netherlands


Return to NeoBook Action Commands

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron