Actionscript - call symbol using variable as part of name (increment number) and change x/y position - actionscript-3

Looked everywhere for this but can't find anything so I hope someone can help. Maybe there is something online but I am not putting it in the right words....
Using Actionscript I want to change the x and y multiple symbols I have that go up by row number and col number in their names i.e. SP_01_01 - SP_01-10...... SP_02_01... etc
I need to access that symbol using two other variables holding the Number parts of the name and change the x and y values.
Here is what I have tried from what I've searched and thought was corrent
["SP__" + rownum + "_" + colnum].x = xcol;
["SP__" + rownum + "_" + colnum].y = yrow;

Try to call objects in this way:
getChildByName("SP__" + rownum + "_" + colnum).x = xcol;
getChildByName("SP__" + rownum + "_" + colnum).y = yrow;
This way even better:
import flash.display.DisplayObject;
var cell:DisplayObject = getChildByName("SP__" + rownum + "_" + colnum);
cell.x = xcol;
cell.y = yrow;

Related

How to get a drop-down filter in Spotfire Information Link?

Generally people use the default option that Spotfire gives. Connect to the DB and pull the set of columns that you need and create an Information Link and load the data to Spotfire.
However, I am using SQL Query to fetch data to Spotfire. I am creating a table similar to Views, and writing a simple stored procedure to pull the data:
Create procedure ProcA(In Start_Date date, IN End_Date date, In Site_Name text)
Begin
SELECT * FROM TableA where day between Start_Date and End_Date and
site_name = Site_Name;
This works fine if I am not using site name filtering.
The Information Links helps in filtering the date properly. But when it comes to Site Name, nothing works.
There are 2 requirements:
Is it possible to give a drop-down just like how filter comes for Date
How to pass multiple site names to pull only those sites into the Spotfire file
TL;DR: There are better ways to do this; if it's just for the column names, I don't think it's worth it to do part 2, since it's easy enough to change the sql in the information link, but it's possible.
Okay, I will try (read: fail) not to be too long-winded.
1) Is it possible to do a drop-down for dates? Yes. The easiest way to do this would be to pull a data table with all of your date choices available for the end user. Here's an example finding a list of better way to generate months/year table Remember when creating your dropdownlist that your Document Property has to have the Data type "Date", and then you should be able to set property values through Unique Values in column against your date column from the new data, the same as you would do for a string drop-down list.
If you have a small subset of specific dates to choose from, this probably isn't too bad. If the drop down list gets longer, your end-users can type in the date they're looking for to speed up their search (though in my experience, a lot of them will scroll through until they find the date they're looking for).
While this is perfectly acceptable, if you're at all comfortable adding javascript, I'd personally recommend using a Popup Calendar These are fairly straightforward for end-users, and can allow them to use the calendar or type it themselves. (And if they type something that isn't a date in, it's even kind enough to inform them with red letters and an exclamation mark that they haven't typed an actual date)
2) How to pass multiple site names to pull only those sites into the Spotfire file
Hoo boi, where to start.
Step one: How do you want to select your list of Site Names? I'm going to go ahead and assume you have a data table with a list of distinct Site Names.
Your next choice is how to let your user select which Site Names they want. General options are using a List Box Filter, displaying a table and using marked rows, or providing a text area where the user can type their selections themselves.
When I needed to do this, I did a combo of a data table and a text area, so that's what I'm going to describe here.
I start off by providing the user with a text area, formatted to "specific size" with a larger than usual height to prompt that, yes, they are allowed to type multiple rows. If they know the values they're looking for, they can type them in manually, or copy paste from an excel file, etc.
If they don't know what they're looking for, the list of Site Names would be in a Table displayed for the user, where they can then mark the rows they want on the visualization and push a button which will do a cursor through the list of marked Site Names, concatenate them together, and put them in the text box previously mentioned (Note: if you don't want to let them enter their list manually, you can leave off the text area, combine these next two pieces of code, and throw it straight into the SpecialFilterProperty).
Please note that cursors are slow; if you have more than a few thousand rows to cycle through, this may stall out for a few seconds.
Code for the button:
from Spotfire.Dxp.Application.Visuals import CrossTablePlot
from Spotfire.Dxp.Data import IndexSet
from Spotfire.Dxp.Data import RowSelection
from Spotfire.Dxp.Data import DataValueCursor
from Spotfire.Dxp.Data import DataSelection
TextFltr = ""
crossSource = Document.Data.Tables["Distinct_SiteNames"]
##Get a Row Count
rowCount = Document.Data.Tables["Distinct_SiteNames"].RowCount
##Index Set of all our rows
rowIndexSet=Document.ActiveMarkingSelectionReference.GetSelection(Document.Data.Tables["Distinct_SiteNames"]).AsIndexSet()
allRows = IndexSet(rowCount,True)
if rowIndexSet.IsEmpty != True:
allRows = rowIndexSet
colCurs = DataValueCursor.CreateFormatted(crossSource.Columns["Site_Name"])
##Optional: Loop through to determine average value
colTotal = ''
for row in crossSource.GetRows(allRows, colCurs):
colTotal += ', ' + colCurs.CurrentValue
if TextFltr == "":
TextFltr += colTotal[2:]
else:
TextFltr += colTotal
Document.Properties["SelectedSiteNames"] = TextFltr
from System.Collections.Generic import Dictionary
from Spotfire.Dxp.Application.Scripting import ScriptDefinition
import clr
scriptDef = clr.Reference[ScriptDefinition]()
Document.ScriptManager.TryGetScript("Change Special Filter Value", scriptDef)
params = Dictionary[str, object]()
Document.ScriptManager.ExecuteScript(scriptDef.ScriptCode, params)
At the bottom it references a second script; this is the script attached to the button that parses through the text area when the user wants to submit their selections and refresh the data table.
The General Code I've used is here, script titled "Change Special Filter Value", which allows delimiting by newline, tabs, commas, quotes, and a few others. Feel free to add or subtract here, depending on your user-base's needs.
strVals = Document.Properties["SelectedSiteNames"]
lst = ""
cnt = 0
x = 0
y = 0
z = 0
for letter in strVals:
if y == 1:
if letter == " ":
lst = lst + "'" + strVals[x:z] + "', "
y = 0
elif letter == ",":
lst = lst + "'" + strVals[x:z] + "', "
y = 0
elif letter == "\n":
lst = lst + "'" + strVals[x:z] + "', "
y = 0
elif letter == "\r":
lst = lst + "'" + strVals[x:z] + "', "
y = 0
elif letter == "'":
lst = lst + "'" + strVals[x:z] + "', "
y = 0
elif letter == '"':
lst = lst + "'" + strVals[x:z] + "', "
y = 0
elif letter == '\t':
lst = lst + "'" + strVals[x:z] + "', "
y = 0
else:
if letter <> " " and letter <> "," and letter <> "\n" and letter <> "\r" and letter <> "'" and letter <> '"' and letter <> "\t":
if y == 0:
cnt += 1
print letter
x = z
y = 1
z += 1
if y == 1:
lst = lst + "'" + strVals[x:z] + "', "
print lst
lst = lst.upper()
if len(lst) > 0:
lst = lst[1:len(lst) - 3]
Document.Properties["SpecialFilterValue"] = lst
Step one is now complete! You have a list of all your selected site names in a property that you can now pass to your stored procedure.
Note: I believe there's a limit to the number of characters Spotfire can pass through a string value. In my previous testing, I think it's been over 500,000 characters (it's been a while, so I don't remember exactly), so you have a lot of leeway, but it does exist, and depending on which data source you're using, it may be lower.
Step Two: Alter the stored Procedure
Your stored procedure will basically be something along the lines of this:
Create procedure ProcA(In Start_Date date, IN End_Date date, In Site_Name text)
Begin
DECLARE #Script nvarchar(max) =
N'
Select * from TableA where day between Start_Date and End_Date and Site_Name in (' + #Site_Name + ') '
EXECUTE (#Script)
Downright easy in comparison!
(No loop after all! The bizarre use case I was remembering doesn't apply here, unless you're also using a data base that doesn't allow you to pass parameters directly...)

SSRS Hyperlink dual parameters errors

I am trying to pass a hyperlink in SSRS to open a new SSRS report (in pdf) from a text box. It is currently set up and works passing a single parameter :
="http://servername/ReportServer_REPORTS16/Pages/ReportViewer.aspx?%2fdummy%2fDocuments%2fCertificate+of+Insurance+Issued&rs:Command=Render&PolicyNo="
& Parameters!PolicyNo.Value &"&rs:Format=PDF"
However when I add in the second parameter :
="http://servername/ReportServer_REPORTS16/Pages/ReportViewer.aspx?%2fdummy%2fDocuments%2fCertificate+of+Insurance+Issued&rs:Command=Render&PolicyNo="
& Parameters!PolicyNo.Value &"&
Entitled="&Parameters!Entitled.Value &"&rs:Format=PDF"
I get an error message :
The ActionInfo.Action.Hyperlink expression for the text box
‘Textbox48’ contains an error: [BC30277] Type character '&' does not
match declared data type 'Object'.
I've gone through every similar error I've found on google but cant work out where im going wrong.
You need to convert all your values to strings then use the + operator....
Here'a an exmaple from one of my reports that does the same thing.
=IIF(Fields!PackSizeDesc.Value = Nothing, Nothing,
"http://MyServername/ReportServer?/Brand+Value/_sub+SKU+Price+Details"
+ "&CountryID=" + cStr(Fields!CountryID.Value)
+ "&CategoryID=" + cStr(Fields!CategoryID.Value)
+ "&RecordedPeriodID=" + cStr(Parameters!PeriodID.Value)
+ "&TMB=" + cStr(Fields!TrademarkBrandID.Value)
+ "&PriceStage=" + cStr(IIF(Fields!IsActualprice.Value = 1, 10, 11))
+ "&pm=" + cStr(Fields!PackMaterialID.Value)
+ "&pt=" + cStr(Fields!PackTypeID.Value)
+ "&ps=" + cStr(Fields!PackSizeID.Value)
+ "&psu=" + cStr(Fields!PackSizeUnitID.Value)
+ "&upp=" + cStr(Fields!UnitsPerPack.Value)
+ "&rc:Parameters=Collapsed")
Note: The first line just disables the link if there is now value in a particular column. This does not render to PDF but that's not part of your issue.

How can I fix an error in the MCMChregress function that seems to stem from the R argument

I'm attempting to run a Bayesian Hierarchical model using MCMChregress, but don't know to fix the problem expressed by this error. My code is below. I believe the problem has to do with the R and r argument and how they relate to the number of parameters. So I didn't include the data set. Let me know if any additional information would be helpful!
"Error: in Wishart(r,rR) prior, R not comformable [q times q].
Error in form.wishart.prior.hmodels(r, R, nq) :
Please respecify and call MCMChregress() again."
#bayesian hierarchical
bhlm.2 = MCMChregress(
fixed = nip_wk_avg ~ unique_elements + vbs.theme_relevance +
vbs.total_score + vbs.product_attributes +
Super_Segment + vbs.play_promise +
vbs.visual_appeal + outgoing + pp79.99 + pp19.99,
random = ~ unique_elements + vbs.theme_relevance +
vbs.total_score + vbs.product_attributes +
Super_Segment + vbs.play_promise +
vbs.visual_appeal + outgoing + pp79.99 + pp19.99,
group = "Super_Theme", data = train.data,
r = 20, R = diag(20))

SSRS Hyperlink expressions

I am wanting to understand if possible to set a conditional hyperlink expression in SSRS within the Action setting.
My code which works currently is
=iif(First(Fields!IsHosted.Value, "ReportServer") = "Y", First(Fields!ServerName.Value, "ReportServer"), Globals!ReportServerUrl) +
"/Pages/ReportViewer.aspx?" + Globals!ReportFolder + "/" +
code.GetTargetReportName("Student Performance Against Goal Drill") +
"&GoalCol=" + Code.URLEncode(Parameters!GoalCol.Value) +
"&SectionCol=" + Code.URLEncode(Parameters!SectionCol.Value) +
"&TargetCol=" + Code.URLEncode(Parameters!TargetCol.Value) +
"&ItemCol=" + Cstr(Fields!Item.Value)
I simply want to say "If field B =0 then do nothing, else use the above. I am not familiar how to wrap this statement in the action.
You can nest IIF() functions:
=IIF(First(Fields!B.Value,"ReportServer") = 0,Nothing,
iif(First(Fields!IsHosted.Value, "ReportServer") = "Y",First(Fields!ServerName.Value, "ReportServer"), Globals!ReportServerUrl) +
"/Pages/ReportViewer.aspx?" + Globals!ReportFolder + "/" +
code.GetTargetReportName("Student Performance Against Goal Drill") +
"&GoalCol=" + Code.URLEncode(Parameters!GoalCol.Value) +
"&SectionCol=" + Code.URLEncode(Parameters!SectionCol.Value) +
"&TargetCol=" + Code.URLEncode(Parameters!TargetCol.Value) +
"&ItemCol=" + Cstr(Fields!Item.Value)
)
I don't know what the dataset structure is but this could help you.

Basic boolean minimization

I am trying to simplify the following piece of boolean algebra so I can construct the circuit :
A'.B'.C.D + A'.B.C.D' + A'.B.C.D + A.B'.C'.D + A.B'.C.D + A.B.C'.D + A.B.C.D' + A.B.C.D
So far I have gotten it to :
(C.D) + (B.C) + (A.C'.D)
Is this correct?
I want to get the best possible minimization.
The steps I have went through so far are :
A'.B'.C.D + A'.B.C.D' + A'.B.C.D + A+B'+C'+D + A.B'+C+D + A.B.C'.D + A.B.C.D' + A.B.C.D
= A.A'(B'.C.D) + A.A'(B.C.D') + A.A'(B.C.D) + B.B'(A.C'.D)
= (B.C.D) + (B'.C.D) + (B.C.D) + (B.C.D') + (A.C'.D)
= (C.D) + (B.C) + (A.C'.D)
Can I do any more?
Assuming your equation is actually:
X = (A'.B'.C.D) + (A'.B.C.D') + (A'.B.C.D) + (A+B'+C'+D) + (A.B'+C+D) + (A.B.C'.D) + (A.B.C.D') + (A.B.C.D);
I just ran this through Logic Friday and it factored it down to:
X = 1;
So you might want to check your simplification work and/or check that you've given the correct equation.
However I suspect there may be typos in the original equation above, and perhaps it should be:
X = (A'.B'.C.D) + (A'.B.C.D') + (A'.B.C.D) + (A.B'.C'.D) + (A.B'.C.D) + (A.B.C'.D) + (A.B.C.D') + (A.B.C.D);
?
In which case Logic Friday simplifies it to:
X = B.C + A.D + C.D;
The only thing I can see that you could possibly do is distribute the "C" in the left two terms:
(C).(B+D)+(A.C'.D)
Or you could distribute the "D":
(C+A.C').D + (B.C)
Response to Comment: The distributive law is described here: http://www.ee.surrey.ac.uk/Projects/Labview/boolalgebra/. See the information under heading "T3"
Here's another solution (found by brute force):
(a+c).(b+d).(c+d)
for simplifying boolean expressions use karnaugh maps. i think it is very much useful if we less number of variables. but if we have more variables then we can follow methods because this method is not that preferable.