Tagged with scripting - Visokio Forums http://forums.visokio.com/discussions/tagged/scripting/feed.rss Mon, 30 Oct 17 11:37:40 -0400 Tagged with scripting - Visokio Forums en-CA Scripting: cryptographic hash of a message with JavaScript? http://forums.visokio.com/discussion/2935/scripting-cryptographic-hash-of-a-message-with-javascripts Sat, 16 May 2015 16:34:06 -0400 sherriff 2935@/discussions http://www.movable-type.co.uk/scripts/sha256.html

Question: is it possible to implement the above in Omniscope perhaps using the Custom Script operation?]]>
Scripting: DataManager Custom Script block http://forums.visokio.com/discussion/2716/scripting-datamanager-custom-script-block Tue, 16 Sep 2014 12:30:39 -0400 acohen 2716@/discussions
For an input array, I would like to loop through one of the fields and do a calculation but I am falling over at the first hurdle.

How do I reference a field and record number of an input array for instance? Or return a full field from the input array? So I would try something like Input1[Baseball players] for example and hope to preview just that one field.

Apologies, I am a real novice when it comes to JavaScripting.

Thanks]]>
Scripting: Converting Hexadecimal string to Decimal number? http://forums.visokio.com/discussion/2934/scripting-converting-hexadecimal-string-to-decimal-numbers Sat, 16 May 2015 15:03:55 -0400 sherriff 2934@/discussions
Any suggestions as to how to do this?]]>
Idea: Saving HTML5 source code in IOK files? http://forums.visokio.com/discussion/671/idea-saving-html5-source-code-in-iok-filess Mon, 07 Mar 2011 05:38:31 -0500 Alk 671@/discussions
It will be good if rather than a link to a local HTML file, we can embed the source code of the HTML file into the iok. Reason being, I am rolling out the iok to multiple users and I have to drop the HTML file onto each computer the IOK will run on. If I want to update the HTML file, then I need to roll out the file onto all computers again - rather long-winded and not user friendly.

If the HTML code was saved in the IOK, then I just need to update the IOK which we have a roll-out of on a frequent basis.]]>
R Analytics: Encountering script error? http://forums.visokio.com/discussion/2771/r-analytics-encountering-script-errors Wed, 26 Nov 2014 19:20:20 -0500 mbj999 2771@/discussions
The script runs in R but gives me the attached errors in Omniscope.

Any feedback/thoughts?

Martin Jetton

]]>
Content View: Creating a custom view using a JS library http://forums.visokio.com/discussion/2679/content-view-creating-a-custom-view-using-a-js-library Mon, 11 Aug 2014 08:58:55 -0400 steve 2679@/discussions
Try online
Download IOK

We use the example from http://www.datatables.net/examples/data_sources/js_array.html and use server-side JS preprocessing to inject dynamic data into the data array declarations in the client-side JS. Open in Omniscope Desktop and edit the Content View source to see how this works.]]>
Scripting: Incorporating Google Charts Gallery? http://forums.visokio.com/discussion/2522/scripting-incorporating-google-charts-gallerys Thu, 17 Apr 2014 06:12:26 -0400 daniel 2522@/discussions https://developers.google.com/chart/interactive/docs/gallery

Would it be possible to get these graphs into Omniscope's Content view? I'm mainly interested in the Timeline and the Candlestick charts which Omniscope views do not currently provide.

I've been able to get the code examples to work but I don't know how to write the JavaScript to actually get the graphs to use the data within Omniscope files.


Clarification:

The code example here has a section which define var data and the array of data, how do I write it so that var data becomes a reference to columns of data in the Omniscope file?

var data = google.visualization.arrayToDataTable([
['Mon', 20, 28, 38, 45],
['Tue', 31, 38, 55, 66],
['Wed', 50, 55, 77, 80],
['Thu', 77, 77, 66, 50],
['Fri', 68, 66, 22, 15]
// Treat first row as data as well.
], true);

https://developers.google.com/chart/interactive/docs/gallery]]>
Scripting: Examples from D3.js Gallery? http://forums.visokio.com/discussion/2528/scripting-examples-from-d3.js-gallerys Wed, 23 Apr 2014 09:13:31 -0400 daniel 2528@/discussions
https://github.com/mbostock/d3/wiki/Gallery]]>
Content View: Scripting - Get the screen size? http://forums.visokio.com/discussion/2495/content-view-scripting-get-the-screen-sizes Thu, 20 Mar 2014 07:41:15 -0400 Bart 2495@/discussions
Is there a way to get a screen size inside Content view with native browser settings enabled? I need to use those numbers to get the right size of my pictures. ]]>
Content View: Scripting - Array of colours? http://forums.visokio.com/discussion/2494/content-view-scripting-array-of-colourss Thu, 13 Mar 2014 08:50:22 -0400 Bart 2494@/discussions
Is there a way to get all colours assigned to the field into array inside content view?

Bart
]]>
Scripting: Copying values from above if null? http://forums.visokio.com/discussion/2386/scripting-copying-values-from-above-if-nulls Wed, 23 Oct 2013 12:17:19 -0400 SimonWiggins 2386@/discussions
I've been trying to find a way to automate copying values down from above if the row is null.
The problem I have is that you can't execute 'for' or 'while' loops in functions in the field organiser (short of scripting)

For example in a column I have:
[Fieldname]
Data1
null
null
null
Data2
null
null
etc..

(where the nulls are empty cells)

I know I can use something of the form:

IF([Fieldname]!=null,[Fieldname],
[Fieldname]=null,IF(
Cell([Fieldname],CURRENTROW()-1)!=null,Cell([Fieldname],CURRENTROW()-1),
Cell([Fieldname],CURRENTROW()-2)!=null,Cell([Fieldname],CURRENTROW()-2),
Cell([Fieldname],CURRENTROW()-3)!=null,Cell([Fieldname],CURRENTROW()-3),
Cell([Fieldname],CURRENTROW()-4)!=null,Cell([Fieldname],CURRENTROW()-4),
Cell([Fieldname],CURRENTROW()-5)!=null,Cell([Fieldname],CURRENTROW()-5),
"Error field may contain more than 6 empty rows"),"Error")

but the limitations of this are if the latest data is pulled in and has more than 6 nulls before a value is above then it will print the error. Obviously also it creates an unnecessary extra field and the old one needs to be deleted in a second Field Organiser. Obviously I could copy paste and edit it up to 100 or more but this isn't very elegant.

I know I can use the Custom Script block to write a JavaScript function and as such have been learning javascript but am having a hard time applying it to my problem.

My question is:
Is there an easy/elegant way of doing this in formulas that I have overlooked?
Or is it a case of using JavaScript to solve my problems?
Is it better done in a 'script' fomula or in a 'Custom script' block bearing in mind I want to do it for 3 columns and keep the rest of the data in line?

I've attached a sort of example of what I mean of some basic data and how I would and have solved it in the past but not copied the formula down long enough therefore it errors after 6 nulls.

Hopefully this makes some sort of sense to someone! Thanks in advance for absolutely any help!

Simon]]>
Demo: Content View - Creating Dynamic Tables http://forums.visokio.com/discussion/2231/demo-content-view-creating-dynamic-tables Fri, 05 Jul 2013 09:26:56 -0400 Bart 2231@/discussions Content View: Scripting - Alert and confirm windows? http://forums.visokio.com/discussion/2106/content-view-scripting-alert-and-confirm-windowss Tue, 23 Apr 2013 05:55:18 -0400 Bart 2106@/discussions
I can get prompt window in Content View, why I can't get any alert or confirm windows? ]]>
Content View: Dynamic HTML table scripting? http://forums.visokio.com/discussion/2019/content-view-dynamic-html-table-scriptings Mon, 18 Feb 2013 05:40:42 -0500 enrico68 2019@/discussions
ncolloc=

SUBSET_UNIQUECOUNT('ABICapoGruppo',
SUBSET2('Dataregolamento','Dataregolamento',datafiltromin,datafiltromax,'>=','<='))<br />
Which is the correct syntax to include the ncolloc variable in the following COLSPAN definition??

< td > colspan=????ncolloc??? rowspan=1> Raccolta Netta Collocatori < /td >

(I intentionally put spaces after < and > to have full definition line visible)

Thanks
]]>
Formulae: Working days between dates? http://forums.visokio.com/discussion/1988/formulae-working-days-between-datess Wed, 16 Jan 2013 05:04:00 -0500 enrico68 1988@/discussions
I'd like to know how to use this function in a 'html extended' script in a Content View and how to call this function in the same script?

Thanks, Enrico]]>
Scripting: extracting specific token in text string? http://forums.visokio.com/discussion/1920/scripting-extracting-specific-token-in-text-strings Mon, 26 Nov 2012 04:13:53 -0500 naruemon 1920@/discussions
I have the data like the following:
-----------------------
index information
1 A,B,C
2 A,B,C
3 A,B,C
-----------------------

Is that possible to get the data in specific token using the separator ','?
The expected result is:
-----------------------
index information
1 A
2 B
3 C
-----------------------

I tried with SCRIPT function but get the error 'sun.org.mozilla.javascript.internal.InterpretedFunction@554eef31'

------------------------------
SCRIPT("
function getToken(sVal, iIndex, sDelimiter)
{

if (sDelimiter.length > 0)
{
var aSubString = new Array();
aSubString = sVal.split(sDelimiter);


if (iIndex > aSubString.length
|| iIndex < 1)
{
return null ;
}
else
{
return aSubString[iIndex - 1]
}

}
else
{
return null ;
}

}
"


, "sVal", [information], "iIndex", [index], "sDelimiter", ",", 50)
------------------------------

Please kindly suggest. Thank you.

Omniscope v.2.8 build 414]]>
Demo: Content View - Using JavaScript arrays (2.8+) http://forums.visokio.com/discussion/1698/demo-content-view-using-javascript-arrays-2.8- Fri, 10 Aug 2012 07:15:58 -0400 CRead 1698@/discussions The result is the internal rate of return (IRR).
The data is a set of consecutive annual payments.
This is the same as the IRR function in Excel, so you can test against that for verification.

Further explanation:
http://office.microsoft.com/en-us/excel-help/irr-HP005209146.aspx
http://en.wikipedia.org/wiki/Internal_rate_of_return

Source code prior to adaptation:
http://code.google.com/p/npoi/source/browse/trunk/main/SS/Formula/Functions/Irr.cs?r=227]]>
Scripting: 2 Fields into multi-dimensional array? http://forums.visokio.com/discussion/1825/scripting-2-fields-into-multi-dimensional-arrays Wed, 10 Oct 2012 11:59:14 -0400 Bart 1825@/discussions JavaScript: script using nested loops? http://forums.visokio.com/discussion/1785/javascript-script-using-nested-loopss Tue, 25 Sep 2012 09:48:51 -0400 enrico68 1785@/discussions
For each outer loop element (ABICapoGruppo) the resulting table has to show:
- an header row
- a serie of detail rows
- a summary row.

The number of detail rows is different for each ABICapoGruppo element.

At the moment I've written the following script (I've cut out all the details of data calculations).

Only the outer loop works fine, printing the description of ABICapoGruppo but no details from inner loop are produced.

I think that the key point is the inner array variable declaration that, for each outer loop cicle, is based on the current value of the outer loop element.

<#/*TABLE HEADER ROW*/#> [......] <#<br />//START OF OUTER LOOPvar array = subset_uniquesList('ABICapoGruppo', SUBSET('ABICapoGruppo',null,'<>'));for (var i in array) { var val = array[i]; #> <#/*ABICapoGruppo HEADER ROW*/#> [......] <#<br /> //START OF INNER LOOP array2 = subset_uniquesList('ABIAppartenente',SUBSET('ABICapoGruppo', '" + val+"') ); for (var j in array2) { var val2 = array2[j]; #> <#/*REPEATED DATA ROW*/#> [......] <# } #> <#/*ABICapoGruppo SUMMARY ROW*/#> [......] <# } #>

Is this the right way to write this script?

Attached to this post a doc word with a more readable version of this script. - Thanks
]]>
JavaScript: NULL or null values (no value) in formula? http://forums.visokio.com/discussion/1784/javascript-null-or-null-values-no-value-in-formulas Tue, 25 Sep 2012 08:48:47 -0400 enrico68 1784@/discussions
SUBSET_UNIQUESLIST([Field 2], SUBSET([Field 2],NULL,'<>'))

and it works fine, returning the list of non-empty in [Field2].

However, when I tried it in a script defining an array:

var array = subset_uniquesList('ABICapoGruppo', SUBSET('ABICapoGruppo',NULL,'<>'));

it returns the message that NULL is not defined. Which is the way to express the NULL values in scripts?

Thanks
]]>
Content View: Scripting question http://forums.visokio.com/discussion/1782/content-view-scripting-question Mon, 24 Sep 2012 08:04:16 -0400 enrico68 1782@/discussions
I'm trying to create a content with a table included using the following script:

//START OF LOOP
var array = subset_uniquesList("ABIAppartenente");
for (var i in array) {
var val = array[i];
#>

<#/*REPEATED ROW*/#>



<#=val#>
<#/* example of inserting a script expression */#>


<#= formula("SUBSET_SUM('Netto', SUBSET('ABIAppartenente', '" + val+"'))") #>
<#/* example of embedded formulas using the formula() function from within a script*/#>


<#= formula("RECORDCOUNT(SUBSET('ABIAppartenente', '" + val+"'))") #>
<#/* example of embedded formulas using the formula() function from within a script*/#>


{{RECORDCOUNT(SUBSET2('Dataregolamento','ABIAppartenente', '04/09/2012','" + val+"'))}}
<#/* example of embedded formulas using the formula() function from within a script*/#>


<#<br />}
The table is created on a loop on ABIAppartenente code and have different columns:

- first column is the ABIAppartenente code itself;
- second column is a total amount for each ABIAppartenente code;
- third column is the count that contributes for each code;
- fourth column counts record for each ABIAppartenente code for a fixed date.

Everything works fine except for last column that return always 0 (for each ABIAppartenente, also if there are records for each ABIAppartenente code and the indicated date Dataregolamento).

So I'd like to know if anyone have an idea about the problem in using the SUBSET2 as indicated - Thanks
]]>
Modifying Field Data using Scripts http://forums.visokio.com/discussion/1741/modifying-field-data-using-scripts Fri, 31 Aug 2012 07:14:26 -0400 sjhstott 1741@/discussions
script(`
var array1 = subset_uniquesList("Operator");
var array2 = subset_uniqueslist("Con_L2Callstackdesc");
for (var i in array2) {
for (var j in array1) {
var str=array2[i];
var n=str.search(array1[j]);
if (n != -1) {
subset("Con_L2Callstackdesc",array2[i]) += "DINGDING"
}
}
}
`,[Con_L2Callstackdesc],[Operator])]]>
Demo: Business Days Between Two Dates http://forums.visokio.com/discussion/1726/demo-business-days-between-two-dates Thu, 23 Aug 2012 07:13:10 -0400 CRead 1726@/discussions
This formula gives the same result as the NETWORKDAYS() function in Excel for all the dates I tested:

DECLARE(
ve,DECLARE(de,DATETOTEXT([End Date],'E'),IF(de='Mon',0,de='Tue',1,de='Wed',2,de='Thu',3,de='Fri',4,de='Sat',5,6)),
vs,DECLARE(ds,DATETOTEXT([Start Date],'E'),IF(ds='Mon',0,ds='Tue',1,ds='Wed',2,ds='Thu',3,ds='Fri',4,ds='Sat',5,6)),
5*INTFLOOR(DATEDIFF([Start Date],[End Date])/7) + VALUE(MID('1234555512344445123333451222234511112345001234550', 7*vs + ve + 1, 1))
)

Source of inspiration:
http://stackoverflow.com/questions/1828948/mysql-function-to-find-the-number-of-working-days-between-two-dates


====== Old version, recommended against! ========
Passing dates as dates into a script can cause odd behaviour in JavaScript. This demonstrates passing them as text, then converting in JavaScript to circumvent those issues.

The result is a calculation of the number of business days between two dates.
The script itself is a copy of:
http://partialclass.blogspot.co.uk/2011/07/calculating-working-days-between-two.html]]>
Scripting: Using arrays of data (2.8+) http://forums.visokio.com/discussion/1656/scripting-using-arrays-of-data-2.8- Mon, 16 Jul 2012 11:23:32 -0400 steve 1656@/discussions
You can use Javascript in Omniscope in the SCRIPT function in formulae, and to do HTML pre-processing in the Content view.

Syntax:

dataArray(fields, rowSubset, includeFieldNames)

Argument "fields": An optional array of field names. If omitted, all fields are retrieved.
Argument "rowSubset": An optional data subset, as returned by the subset function.
Argument "includeFieldNames": if true, the first 'row' in the returned 2d array 'table' will be the field names.

Returns: A two-dimensional array of cell data, indexed as [column][row], with indexes numbered from 0 to n-1.

See attached example, using dataArray inside a Content View.]]>
Formula: Referencing same-field cells http://forums.visokio.com/discussion/1022/formula-referencing-same-field-cells Thu, 29 Sep 2011 16:16:57 -0400 alexhoward 1022@/discussions
Also, thank you for the SCRIPT idea. Could you please post an example formula with a script that could help get me started writing one?

Thanks]]>