Search row and column for return value
Dear Sir/Madam,
I have a problem for searching spreadsheet and hope you can help me out a bit. Im pretty new to Labview and Im currently using Labview 8.0. My task is to search the spreadsheet I have attached in row and column-wise, then return the corresponding value out. I had an attempt in doing this as you can see from the vi that i have attached. I try inputting the 'read from measurement file' into an array and using delete, index and search array I will be able to find the index value for the relevant row and column that i searched for by inputting them into an index array with the orginal array from the 'read from measurement file'.
So ultimately, when i enter a row value of 0.5 and a column value of 0.3, my output will be 1.688.
I can't see any mistakes in my logic but I getting really strange results, like I can read my data has been entered into an array but when i try deleting the first column and put it into another array, the orginal array with nothing deleted is outputted hence making my search to give out -1 value. So could you take a look please and give me any suggestion that can solve my problem or enhance the code a bit. Thank you for your time.
Best Regards,
Coato
P.s for some reason i can't attached the .lvm file of my data hence i have attached the excel version but i think you need to convert it back to .lvm for the 'read from measurement file' function to work.
Attachments:
Backswing compensation.csv 10 KB
Backswing comnpensation2.vi 109 KB
Your VI makes absolutely no sense to me, but maybe I don't understand what you are trying to do.
You seem to have dynamic data with 6 signals and 48 points/channel. Now you reshape this into an array of dynamic data with 4x13 elements from which you slice out one row or column, resp. "delete from array" is NOT the correct tool to do this, use "Index array" with one index unwired to get a row or column as 1D array.
So you end up with two 1D arrays of dynamic data that you search for DBL. It is difficult to understand how you want to search for an array element that corresponds to a scalar DBL value of 0.1. Your array elements are NOT DBLs but dynamic data, each containing many signals!
There are two elements on all your data that are "3", the rest are zero. You will never find anything that is 0.1.
Maybe you can convert your original dynamic data to a 2D array with "rows are signals" using "convert from dynamic data", then operate on the 2D array.
Coato wrote:
So ultimately, when i enter a row value of 0.5 and a column value of 0.3, my output will be 1.688.
Sorry, Please explain.
Please make a VI containing a simple 2D aray as diagram constant that contains e.g. 5x5 typical values. Let us know what kind of result you expect from your algorithm..
LabVIEW Champion . Do more with less code and in less time .
Similar Messages
-
thx guys.....i have a progress now in LV
But now i have new trouble here. Ok i attached my LV file (LV 7.0.1/7.1) and excel form. I just could'nt calculate more than one input value. I want a different result for each value that i enter ... and store it into different rows and column. But it just store at one row.
Attachments:
My Project.vi 31 KB
rumus motor bakar.xls 14 KBduplicate post
-
Need help setting up rows and columns for a shop page in DW
I sell my books and design tees on my site. I'm trying to set up a new page for a new site.
For some reason I can't get my products in a row and column fashion.
I have a attachment file so you can see what I actually mean. thanks to all that will give advice.Use a table for your product catalog.
Nancy O.
Alt-Web Design & Publishing
Web | Graphics | Print | Media Specialists
www.alt-web.com/
www.twitter.com/altweb
www.alt-web.blogspot.com -
Hide a row or column for characteristic value # in Query Designer
Hi gurus,
I would if we could hide a result row / column if one of the characteristic value is #. The requirement is actually to remove the meaningless row / column from the whole result set. For example, I have a char Material Group in the column. Since not every Material is assigned to a Material Group, I will get the following layout:
Material_Group A
Material_Group B
Material_Group C
Is it possible to define in query designer so that the column with # will automatically not be displayed?
Thanks,
MengHi Meng,
I guess we have the same users..
But there is one thing that is going to make a non sense on the report: if you do not display the "#" for material group, then the total of your query by material group will not be the summation of what is displayed on the screen...and if the user explort the information in Excel (pretty sure they will do so), you will have some calls that your query does not balance....
Based on that assumption, tell the users to assign a material group to the materials, so that this unassigned column disappears. You could even give them a control report listing all the parts that do not have a material group
If this is a standard business rule not to have a material group for all parts, then, what you could do is to change the text for empty rows for Material group, then the "#" will disappear and wil be under the text description you defined.
But keep in mind that your data is made of materials which do not have a material group in their definition, noraml or not ?
PY -
Hi, I would like to know how can i break the value for a row and column once i have converted the image to the array. I wanted to make some modification on the element of the array at a certain position. how can i do that?
At the moment (as per attachhment), the value of the new row and column will be inserted by the user. But now, I want to do some coding that will automatically insert the new value of the row and the column ( I will use the formula node for the programming). But the question now, I don't know how to split the row and the column. Is it the value of i in the 'for loop'? I've tried to link the 'i' to the input of the 'replace subset array icon' , but i'm unable to do it as i got some error.
Please help me!
For your information, I'm using LABView 7.0.Hi,
Thanks for your reply.Sorry for the confusion.
I manage to change the array element by changing the row and column value. But, what i want is to allow the program to change the array element at a specified row and column value, where the new value is generated automatically by the program.
Atatched is the diagram. I've detailed out the program . you may refer to the comments in the formula node. There are 2 arrays going into the loop. If a >3, then the program will switch to b, where if b =0, then the program will check on the value of the next element which is in the same row with b but in the next column. But if b =45, another set of checking will be done at a dufferent value of row and column.
I hope that I have made the problem clear. Sorry if it is still confusing.
Hope you can help me. Thank you!!!!
Attachments:
arrayrowncolumn2.JPG 64 KB -
Hi,
a) I want to read EACH VALUE from a spreadsheet file having multiple rows and columns WITH DELAY. I am attaching my VI and sample datalog file for reference (tempsensor.txt).I need to do so because as soon as I read put ON the Sensor button on front panel, LV reads all the values at one go. I need the values for each temperature to be displayed after a delay.
b) Secondly, I would like to read another file containing the state of four antennas (deployed:1; undeployed:0). I am logging state of each antenna in each column of the file(magnet.txt) I need to have four LEDS on front panel to display state of the antennas. I dont know what I have done for antennas in my VI is right or wrong. I guess thats rhe wrong way to approach the problem. Please help!!!(column1: Antenna1 state ; Column2:Antenna2 state.. and so..on..)
Any help would be greatly appreciated!!
Thanks in advance,
Ratnesh
FYI: The first column in my datalog file represents timestamp(number of seconds elapsed), second column: reading for temperature sensor 1, third column: reading for temperature senosr 2, and so on. I am using approx. 11 temperature sensors.
Also, I have generated the log files for the reference purpose only. They do not represent the actual values. They are far away from actual values.
Attachments:
01032005.zip 30 KBLook at this modified version of your VI. After looking at it, I determined that a shift reggister was not required in this case.
Lynn
Attachments:
MultiSensors.2.vi 85 KB -
I have tried intializing an array and replacing elements by specifying a particular row, and column, but in the end I get an array with only one element replaced, and I suspect that it is because as the for loops are running through their iterations each time the array is re-initializing. I have a simple vi that I will post below, it is not the exact situation that I have but is a good place for me to get some understanding. I have the row and column indexes being driven by the inner and outer loop iterations, which gives me the pattern I need. I am using the inner iterations as array elements. How do I set this up so that it works and d
oes keep re-initializing my array.
Attachments:
Untitled.vi 26 KBI have fixed a number of things in your vi.
You were right in thinking that the array was continuously re-initialized. To avoid this, use a shift register (right-click the loop border), which will pass the updated array into the next iteration.
Chilly Charly (aka CC)
E-List Master - Kudos glutton - Press the yellow button on the left...
Attachments:
your_vi.vi.zip 13 KB -
T-SQL and CLR types for return value do not match
Hi I am trying to create a CLR function to call a webservice, the CLR function return data type is double, whether I try
to create this as a table valued funcion or a scalar to return a distance travelled value I am receiving the error below. I've tried changing data types around in the CLR side and the SQL side but keep receiving the same error message, any help would be appreciated,
Thank you,
[Microsoft.SqlServer.Server.SqlFunction(Name = "DistanceCalc")]
public static Double DistanceCalc(Double SrcLat, Double SrcLong,
Double DestLat, Double DestLong)
MileageWS ws = new MileageWS();
ws.Url = "http://test.isp.ca/Distance.asmx";
int intUom = 0; // 0 = Mile, 1 = KM
RouteType RouteMethod = RouteType.Practical;
Requester RequestedFrom = Requester.LinkRoute;
Double distance;
distance = ws.GetDistanceInfoForLonLat(SrcLat, SrcLong, DestLat, DestLong, intUom, RouteMethod, RequestedFrom);
return distance;
CREATE FUNCTION DistanceCalc
@SrcLat as float, @SrcLong as float,
@DestLat as float, @DestLong as float
RETURNS TABLE (Distance float)
External NAME CLRfunctions.RIFunctions.DistanceCalc
GO
Error received when try to Create function ...
1, Level 16, State 2, Procedure pcMiler, Line 6
CREATE FUNCTION for "pcMiler" failed because T-SQL and CLR types for return value do not match.You defined at table-valued CLR function, but I think you meant to define a scalar CLR function. That might be the cause of the error.
RETURNS TABLE (Distance float)
should be
RETURNS (Distance float) -
Setup for discoverer table for showing number of Rows and columns of Report
As oracle discoverer report show "Rows 1-25 of"(Total rows) and "Column 1-6 Of"(Total Column).
This total rows and columns information's is not appearing on our reports.
Kindly let us know its setting/setups .
This is very urgent to us, Any help will be highly appreciated.
Thanks, AvaneeshHmm, what version of Discoverer are you on? Do I understand you correctly that you are able to run a Discoverer report and see this rows and columns information? What software are you running when you do this - Viewer, Plus, or Desktop? Where is this showing up - the top of the report maybe? Or maybe the bottom of the report? The only thing I can think of to handle this is the Page Setup for a workbook, and looking at the Header and Footer sections of that setup. But I am on Discoverer 10.1.2.2 and I don't see anything I can insert on the header/footer that would show this kind of information. Desktop will let you do Page x of y pages (Plus does not), but that is not what you are seeing. You can maybe look at the page setup and see if there is something there not documented in the Discoverer guides.
John Dickey -
Summing the Rows and Columns in an Array
I am importing a 2-dimensional array of integers.(which is held in a 2-dimensional array)
I need to store the row sums and column sums in separate 1-dimensional arrays.
I can get the integers in and print out a list along with the grand total(sum of all).
But, how do I pass each row's and each column's value in to my sumRow and sumCol methods to get the sum for each row and each column?
Can I do the row and column summing in the same "for" statement where I calculate the "grand total"? Or am I making this more difficult than it is?
Would appreciate any help.
This is what I have so far:
import java.awt.Graphics;
import java.applet.Applet;
public class TwoWayTable extends Applet {
int numRows;
int numCols;
int [] [] cell;
int [] rowSum;
int [] colSum;
int grandTotal;
public TwoWayTable(int [][] data){
grandTotal = 0;
cell = new int [data.length][data.length];
for(int i = 0; i < data.length; i++)
for(int j = 0; j < data.length; j++){
cell[i][j] = data[i][j];
grandTotal += cell[i][j];
System.out.println(cell[i][j]);
System.out.println(grandTotal);
public int sumRow(int [] data2){
int rowaccumulator=0;
rowSum = new int[data2.length];
for(int numRows = 0; numRows < rowSum.length; numRows++){
rowaccumulator += rowaccumulator + rowSum[numRows];
return(rowaccumulator);
public int sumCol(int [] data3){
int colaccumulator = 0;
colSum = new int[data3.length];
for(int numCols = 0; numCols < colSum.length; numCols++){
colaccumulator += colaccumulator + colSum[numCols];
return(colaccumulator);Thanks for your input.
I'll make the changes that you suggest.(after this)
My output prints:
4 6 3 8 21
9 1 5 3 18
13 7 8 11 39
numbers are right, but I need to format the table
the output needs to look like this:
int int int int | rowsum
int int int int | rowsum
colsum colsum colsum colsum | total
How do I do this?
I have no idea?
I'm supposed to call a "void setMargins( )" method to line this up, without
using the exotic formatting in the IO library.
I'm also supposed to use "public String toString( )"
This is what I have so far:
import java.awt.Graphics;
import java.applet.Applet;
public class TwoWayTable extends Applet {
int numRows;
int numCols;
int [] [] cell;
int [] rowSum;
int [] colSum;
int grandTotal;
public TwoWayTable(int [][] data){
cell = new int [data.length][data.length];
for(int i = 0; i < data.length; i++){
for(int j = 0; j < data.length; j++){
cell[i][j] = data[i][j];
calcTotals(cell);
for(int i = 0; i < cell.length; ++i){
for(int j = 0; j < cell.length; ++j){
System.out.print(cell[i][j] + " ");
System.out.println(rowSum[i] + " ");
for(int j = 0; j < cell.length-1; ++j){
System.out.print(colSum[j] + " ");
System.out.println(colSum[cell.length-1] + " " + (grandTotal));
public void calcTotals(int [][] data2){
grandTotal = 0;
rowSum = new int[data2.length];
colSum = new int[data2.length];
for(int numRows = 0; numRows < data2.length; numRows++){
for(int numCols = 0; numCols < data2.length; numCols++){
grandTotal += data2[numRows][numCols];
rowSum[numRows] += data2[numRows][numCols];
colSum[numCols] += data2[numRows][numCols]; -
Select row and column from header in jtable
hello i have a problem to select row and column from header in jtable..
can somebody give me an idea on how to write the program on it.Hi Vicky Liu,
Thank you for your reply. I'm sorry for not clear question.
Answer for your question:
1. First value of Open is item fiels in Dataset2 and this value only for first month (january). But for other month Open value get from Close in previous month.
* I have 2 Dataset , Dataset1 is all data for show in my report. Dataset2 is only first Open for first month
2. the picture for detail of my report
Detail for Red number:
1. tb_Open -> tb_Close in previous month but first month from item field in Dataset2
espression =FormatNumber(Code.GetOpening(Fields!month.Value,First(Fields!open.Value, "Dataset2")))
2. tb_TOTAL1 group on item_part = 1
expression =FormatNumber(Sum(CDbl(Fields!budget.Value)))
3. tb_TOTAL2 group on item_part = 3 or item_part = 4
expression =FormatNumber(Sum(CDbl(Fields!budget.Value)) + ReportItems!tb_TOTAL1.Value )
4. tb_TOTAL3 group on item_part = 2
expression =FormatNumber(Sum(CDbl(Fields!budget.Value)) - ReportItems!tb_TOTAL2 .Value)
5. tb_Close -> calculate from tb_TOTAL3 - tb_Open
expression =FormatNumber(Code.GetClosing(ReportItems!tb_TOTAL3.Value,ReportItems!tb_Open.Value))
I want to calculate the value of tb_Open and tb_Close. I try to use custom code for calculate them. tb_close is correct but tb_Open is not correct that show value = 0 .
My custom code:
Dim Shared prev_close As Double
Dim Shared now_close As Double
Dim Shared now_open As Double
Public Function GetClosing(TOTAL3 as Double,NowOpening as Double)
now_close = TOTAL3 + NowOpening
prev_close = now_close
Return now_close
End Function
Public Function GetOpening(Month as String,NowOpen as Double)
If Month = "1" Then
now_open = NowOpen
Else
now_open = prev_close
End If
Return now_open
End Function
Thanks alot for your help!
Regards
Panda A -
Setting number of rows and columns
How do I set the number of rows and columns of a table, say 2348 rows by 3 columns?
Then how do I quickly select the last row?
Also, if I enter a formula in row 1 column 2, how do I quickly copy that formula down to row 1435, or to the end of the column? Dragging seems slow and awkward.I wish to add a few words to Jerrold responce.
gjf12 wrote:
How do I set the number of rows and columns of a table, say 2348 rows by 3 columns?
Then how do I quickly select the last row?
Also, if I enter a formula in row 1 column 2, how do I quickly copy that formula down to row 1435, or to the end of the column? Dragging seems slow and awkward.
The process that you describe is inefficient.
The efficient one is :
create a table
enter the formulas in a single row
delete the rows below.
Now, each newly inserted row will contain the formulas.
From my point of view, it's when this is done that it will be interesting to apply a script adding rows.
Here is a script inserting rows.
--[SCRIPT insertRows]
Enregistrer le script en tant que Script : insertRows.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
Sélectionner une cellule au-dessous de laquelle vous voulez insérer des lignes.
menu Scripts > Numbers > insertRows
Le script vous demande le nombre de lignes désiré puit insère celles-ci.
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
--=====
Save the script as a Script: insertRows.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Select a cell below which you want to insert rows.
menu Scripts > Numbers > insertRows
The script ask you the number of rows to insert then it does the required insertion.
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
Save this script as a … Script in the "Folder Actions Scripts" folder
<startupVolume>:Library:Scripts:Folder Action Scripts:
--=====
Yvan KOENIG (VALLAURIS, France)
2010/01/13
--=====
on run
set defaultValue to 100
if my parleAnglais() then
set myInteger to my askAnumber("Insert how many rows ?", defaultValue, "i")
else
set myInteger to my askAnumber("Combien de lignes voulez-vous insérer ?", defaultValue, "i")
end if
set {dName, sName, tName, rname, rowNum1, colNum1, rowNum2, colNum2} to my getSelParams()
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
repeat myInteger times
add row below row rowNum2
end repeat
end tell
end run
--=====
on getSelParams()
local r_Name, t_Name, s_Name, d_Name, col_Num1, row_Num1, col_Num2, row_Num2
set {d_Name, s_Name, t_Name, r_Name} to my getSelection()
if r_Name is missing value then
if my parleAnglais() then
error "No selected cells"
else
error "Il n'y a pas de cellule sélectionnée !"
end if
end if
set two_Names to my decoupe(r_Name, ":")
set {row_Num1, col_Num1} to my decipher(item 1 of two_Names, d_Name, s_Name, t_Name)
if item 2 of two_Names = item 1 of two_Names then
set {row_Num2, col_Num2} to {row_Num1, col_Num1}
else
set {row_Num2, col_Num2} to my decipher(item 2 of two_Names, d_Name, s_Name, t_Name)
end if
return {d_Name, s_Name, t_Name, r_Name, row_Num1, col_Num1, row_Num2, col_Num2}
end getSelParams
--=====
set {rowNumber, columnNumber} to my decipher(cellRef,docName,sheetName,tableName)
apply to named row or named column !
on decipher(n, d, s, t)
tell application "Numbers" to tell document d to tell sheet s to tell table t to return {address of row of cell n, address of column of cell n}
end decipher
--=====
set { d_Name, s_Name, t_Name, r_Name} to my getSelection()
on getSelection()
local _, theRange, theTable, theSheet, theDoc, errMsg, errNum
tell application "Numbers" to tell document 1
repeat with i from 1 to the count of sheets
tell sheet i
set x to the count of tables
if x > 0 then
repeat with y from 1 to x
try
(selection range of table y) as text
on error errMsg number errNum
set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
return {theDoc, theSheet, theTable, theRange}
end try
end repeat -- y
end if -- x>0
end tell -- sheet
end repeat -- i
end tell -- document
return {missing value, missing value, missing value, missing value}
end getSelection
--=====
on decoupe(t, d)
local l
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
return l
end decoupe
--=====
Asks for an entry and checks that it is an floating number
set myInteger to my askAnumber(Prompt, DefaultValue, "i")
set myFloating to my askAnumber(Prompt, DefaultValue, "f")
on askAnumber(lPrompt, lDefault, ForI)
local lPrompt, lDefault, n
tell application (path to frontmost application as string)
if ForI is "f" then
set n to text returned of (display dialog lPrompt & " (" & (1.2 as text) & ")" default answer lDefault as text)
try
set n to n as number (* try to convert the value as an number *)
return n
on error
if my parleAnglais() then
display alert "The value needs to be a floating number." & return & "Please try again."
else
display alert "La valeur saisie doit être un nombre décimal." & return & "Veuillez recommencer."
end if
end try
else
set n to text returned of (display dialog lPrompt default answer lDefault as text)
try
set n to n as integer (* try to convert the value as an integer *)
return n
on error
if my parleAnglais() then
display alert "The value needs to be an integer." & return & "Please try again."
else
display alert "La valeur saisie doit être un nombre entier." & return & "Veuillez recommencer."
end if
end try -- 1st attempt
end if -- ForI…
end tell -- application
Here if the first entry was not of the wanted class
second attempt *)
tell application (path to frontmost application as string)
if ForI is "f" then
set n to text returned of (display dialog lPrompt & " (" & (1.2 as text) & ")" default answer lDefault as text)
try
set n to n as number (* try to convert the value as an number *)
return n
on error
end try
else
set n to text returned of (display dialog lPrompt default answer lDefault as text)
try
set n to n as integer (* try to convert the value as an integer *)
return n
on error
end try -- 1st attempt
end if -- ForI…
end tell -- application
if my parleAnglais() then
error "The value you entered was not numerical !" & return & "Goodbye !"
else
error "La valeur saisie n’est pas numérique !" & return & "Au revoir !"
end if
end askAnumber
--=====
on parleAnglais()
local z
try
tell application "Numbers" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
--[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) mercredi 13 janvier 2010 12:43:34 -
Programmactic Access DataGrid Rows and Columns
Hello,
I am new to ActionScript. Can you tell me how can I access
the rows and columns of a data grid?
What I want to do is that when the application load, I will
populate the datagrid with the Xml returned from the webservice.
After that, webservice will be called periodically (using timer)
and the information in the datagrid needs to be updated. The cells
which are updated need to be highlighted.
The datagrid actually contains the stock market data (symbol
name and its other attributes). So once the datagrid has been
populated on application creation, it contains all the symbols in
the market. After that, only attributes of the symbols will change,
like price, volume etc. What I want is that once the datagrid is
populated, i can access the row by using the value of symbol code
and then update the appropriate columns of that symbol. (Xml from
next time will contain only symbols whose values change from last
time).
Below is the code that I have written so far.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="OnAppCreationComplete()" width="100%"
height="100%">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
private var count:uint = 0;
private var messageFramXmlList:XMLList;
private var marketSnapshotTimer:Timer = new Timer(1000);
private function OnAppCreationComplete() : void
this.ajaxServiceInvokerProxy.addEventListener(ResultEvent.RESULT,
this.OnWebServiceResultArrived);
this.ajaxServiceInvokerProxy.InvokeService.send();
this.marketSnapshotTimer.addEventListener(TimerEvent.TIMER,
this.OnSnapshotTimerTick);
this.marketSnapshotTimer.start();
private function
OnWebServiceResultArrived(event:ResultEvent) : void
var marketSnapshotXml:XML = new XML(event.result);
this.messageFramXmlList =
marketSnapshotXml.child("MarketSnapshot").child("MessageFrameList")[0].child("MessageFram e");
this.dgTopPosts.dataProvider = this.messageFramXmlList;
this.btnCounter.label = this.count.toString();
private function OnSnapshotTimerTick(event:TimerEvent) :
void
this.count++;
this.ajaxServiceInvokerProxy.InvokeService.send();
]]>
</mx:Script>
<mx:WebService id="ajaxServiceInvokerProxy"
wsdl="
http://jehanzeb/ajaxserviceinvoker/ajaxserviceinvoker.asmx?wsdl"
useProxy="false">
<mx:operation name="InvokeService">
<mx:request>
<serviceWithComonentName>DetailedSnapshotComponent.MarketSnapshot@TADAWUL</serviceWithCom onentName>
<parametersXml><![CDATA[ <Parameters/>
]]></parametersXml>
</mx:request>
</mx:operation>
</mx:WebService>
<mx:Panel x="10" y="10" width="100%" height="100%"
layout="absolute" title="Market View">
<mx:RichTextEditor id="txtMarketViewResult" x="10" y="10"
width="612" height="194" />
<mx:DataGrid x="10" y="223" id="dgTopPosts" width="100%"
height="303">
<mx:columns>
<mx:DataGridColumn headerText="Symbol Code"
dataField="SymbolID" />
<mx:DataGridColumn headerText="Last Time"
dataField="LastTime" />
<mx:DataGridColumn headerText="Net Change"
dataField="NetChange" width="75"
/>
<mx:DataGridColumn headerText="Percent Change"
dataField="PercentChange" width="75" />
<mx:DataGridColumn headerText="Previous Closed"
dataField="PreviousClosed" width="75"/>
<mx:DataGridColumn headerText="Close" dataField="Close"
width="75"/>
<mx:DataGridColumn headerText="Direction"
dataField="Direction" width="75"/>
<mx:DataGridColumn headerText="BidPrice"
dataField="BidPrice" width="75"/>
<mx:DataGridColumn headerText="AskPrice"
dataField="AskPrice" width="75"/>
<mx:DataGridColumn headerText="BidVolume"
dataField="BidVolume" width="75"/>
<mx:DataGridColumn headerText="AskVolume"
dataField="AskVolume" width="75"/>
</mx:columns>
</mx:DataGrid>
<mx:LinkButton id="btnCounter" x="10" y="528" width="306"
textAlign="left" label="" />
</mx:Panel>
</mx:Application>To achieve what you want, I would have two functions:
* One populates the DataGrid for the first time, i.e. the
inital load
* The other does the 'update' on each interval, since there's
logic required
To update the DataGrid with only the rows that have changed,
you're going to have to compare
the incoming XML to the existing XML in the dataProvider of
the DataGrid, then selectively update the dataProvider.
You can use the
getItemAt() and
setItemAt() methods of the data provider to check each row
against the incoming data. So, some example code:
// This is the function which handles the result of your
'updated data only' webservice
private function handleUpdateInvoke (event:ResultEvent) :
void {
var incoming:XML = new XML(event.result);
var someList:XMLList = incoming.somePattern;
// For each data provider item, check the key and if it
matches
// one of the incoming keys, update it at that index
var numRows = this.dgTopPosts.dataProvider.length;
var existingDataRow:*
for (var i:Number = 0; i < numRows; i++) {
existingDataRow = this.dgTopPosts.dataProvider.getItemAt(i);
for each (var newDataRow:* in someList) {
if (existingDataRow.SymbolID == newDataRow.SymbolID) {
this.dgTopPosts.dataProvider.setItemAt(newDataRow, i);
} -
JTable - Swapping the Rows and Columns
This issue was raised in the Java Programming forum. Received initially as a weird requirement, it now seems that it is more common than you might think. Under it's original title it was "JTable - Limitation or Not?"
I introduced the topic here so that the thread perspective can include more experienced Swing developers.
The JTable in it's default layout is intended to hold database tables with records in rows. But what if you want records in columns?
Some have said why? Just accept the row layout. Others have said use a customised form. Both reasonable views. Despite this, others report that the inherrited power of the JTable is worth leveraging and they have been doing it for years. Albeit with messy code in certain cases.
This is a clear candidate for a popular derived component. If the existing JTable were renamed as a JTableRecordPerRow I am describing a JTableRecordPerColumn. The corresponding Table Model must naturally have a getRowClass method and no getColumnClass method.
Java is good at seperating data from display issues so essentially this is only a display issue. The data representation is unaffected.
While this may be so, the TableModel for a JTable makes the link from the display to the data so it must have knowledge about cell type to trigger the correct cell editor for example.
I think it is fair to say that the standard JTable has not be designed with alternative row/column or column/row displays in mind. Hence a single getColumnClass method. However implementing a Table model which exchanges columns for rows is a good start. This leaves a few loose ends where editting is concerned.
While this may not be an ideal topic for anyone just learning Swing I have been encouraged to consider the general case within the limitations of the cell types normally supported by the default Table model.
I would have a guess that this is an established component in many private Java libraries already.
Views and experience on this topic extremely welcome.It appears to me that while interchanging the rows and columns of a JTable is not trivial it is still worthwhile as a workhorse component.
Perhaps the original design could have allowed for an aternative layout manager of somekind but this could easily have made description of records/rows and fields/columns confusing.
I will probably get this summary wrong but I aill attempt to collate the neatest approach as I see it. Criticisms or shorter steps welcome. My thanks to the original contributors traceable from this thread.
In the descriptions below a distinction is made between the normal internal data model representation of a row, called "mrow", and the displayed form "row".
Only the TableModel need be changed.
1 Use row 0 to show the headers by a)disabling the normal TableHeader renderer b)setting the cell renderer for column 0 to the default renderer used by the TableHeader and c)using the getValueAt method to return mcol header values for the row entries.
2 For other row, col values to getValueAt return the value at mcol, mrow where mcol==row-1 & mrow==col.
3 Create a new getCellClass(col,row) method to return the class where mrow==0 and mcol==row-1. Note that I am only trying to immitate the common use of of a database record per mrow here.
4 Override a)getCellRenderer and b)getCellEditor to use getCellClass
Four steps with seven parts seems worth it to me.
The power of Swing!
Many thanks to all. -
How to get number of rows and columns in a two dimensional array ?
Hello,
What would be the simplest way to get number of rows and columns in a two dimensional array represented as integers ?
I'm looking for another solution as For...Each loop in case of large arrays.
Regards,
PetriHi Petri,
See a attached txt file for obtaining two arrays with upper and lower index values
Regards
Ray
Regards
Ray Farmer
Attachments:
Get2DArrayIndex.txt 2 KB
Maybe you are looking for
-
How can I get a refund from another country that does not have an Apple Store?
While going to the US for the summer, I went to the San Francisco Apple Store. I saw the Apple Gift Cards, and I was wondering if they would work on my Taiwan Apple ID, so I bought a $25 gift card and a 4 cards bundle pack each with $10 inside. But t
-
How I can make Bridge CS6 and Lightroom 4 share the same set of keywords in real time?
Can we point to the same file on the hard drive? What is the current best workflow practice for keyword sync between the two apps? Thanks
-
My mom's iPhone 4 with ios 6 won't work and won't backup
My mom's iPhone is starting to take a **** on her. Everything is super super SUPER slow! Her texts won't go through and sometimes don't even send at all and just disappear. She tried updating it using her wifi at her work and it got to the VERY end a
-
Install upgrade icon not showing up on desktop?
i'm trying to upgrade my ibook os 10.2.8 to tiger 10.4, but the initial install icon is not even popping up to click on to initate the process. i restarted the computer, but still no icon to hit and get the ball rolling. anyone have any ideas? any fe
-
My MacBook Pro has no audio. Sounds preferences showing output is Optical digital-out port. How do I change this to built-in speakers?