Hey, there's an option 3 for changing values in an array, utilizing
<@ADDROWS>. I filtered out a subset of the array that held the variable
I wanted to work with (code 545), then built a new mini array with the
changed value (code 546), a row at a time, if it matched a criteria (>
3/31,2009) in a corresponding row in my filtered array. My new mini
array duplicated a number of rows in the filtered array, except for the
changed value. I added my new mini array to my filtered array, and used
<@DISTINCT> to get rid of the duplicate rows. Finally I used <@FILTER>
to take out the rows corresponding to my original filtered array from my
original full array, then added my newly built array to my original. I
know. More then you wanted to know.
<@ASSIGN NAME=trial_data VALUE=@@resultset SCOPE=LOCAL>
<@ASSIGN NAME=trial_data VALUE='<@FILTER ARRAY="trial_data"
SCOPE="request" EXPR="#2=545">' SCOPE=request>
<@ROWS ARRAY="trial_data" SCOPE=request>
<@ASSIGN NAME=ARRY1 VALUE="<@DATETOSECS DATE='<@SUBSTRING
STR="03/31/2009" START=1 NUMCHARS=10>'>" SCOPE=request>
<@ASSIGN NAME=ARRY2 VALUE="<@DATETOSECS DATE='<@SUBSTRING STR="<@COL
NUM=7>" START=1 NUMCHARS=10>'>" SCOPE=request>
<@IF EXPR="@@ARRY2 > @@ARRY1">
<@ASSIGN NAME="agcy1" VALUE="<@COL NUM=1>" SCOPE="request">
<@ASSIGN NAME="agcy2" VALUE="546" SCOPE="request">
<@ASSIGN NAME="agcy3" VALUE="<@COL NUM=3>" SCOPE="request">
<@ASSIGN NAME="agcy4" VALUE="<@COL NUM=4>" SCOPE="request">
<@ASSIGN NAME="agcy5" VALUE="<@COL NUM=5>" SCOPE="request">
<@ASSIGN NAME="agcy6" VALUE="<@COL NUM=6>" SCOPE="request">
<@ASSIGN NAME="agcy7" VALUE="<@COL NUM=7>" SCOPE="request">
<@ASSIGN NAME="agcy8" VALUE="<@COL NUM=8>" SCOPE="request">
<@ASSIGN NAME="agcy9" VALUE="<@COL NUM=9>" SCOPE="request">
<@ASSIGN NAME="agcy10" VALUE="<@COL NUM=10>" SCOPE="request">
<@ASSIGN NAME="agcy11" VALUE="<@COL NUM=11>" SCOPE="request">
<@IfEmpty <@COL NUM=12>>
<@ASSIGN NAME="agcy12" VALUE="00" SCOPE="Request">
<@ASSIGN NAME="agcy13" VALUE="00/00/00 00:00:00" SCOPE=Request>
<@ELSE>
<@ASSIGN NAME="agcy12" VALUE="<@COL NUM=12>" SCOPE="LOCAL">
<@ASSIGN NAME="agcy13" VALUE="<@COL NUM=13>" SCOPE="LOCAL">
</@IF>
<@ASSIGN NAME="row_names" SCOPE="request" value="<@ARRAY
VALUE='<@VAR "agcy1">,<@VAR "agcy2">,<@VAR "agcy3">,<@VAR "agcy4">,<@VAR
"agcy5">,<@VAR "agcy6">,<@VAR "agcy7">,<@VAR "agcy8">,<@VAR
"agcy9">,<@VAR "agcy10">,<@VAR "agcy11">,<@VAR "agcy12">,<@VAR "agcy13">'>">
<@ADDROWS ARRAY="MO_DATA" SCOPE=request VALUE="<@VAR
NAME='row_names' SCOPE=request>">
<@COMMENT>
<@ASSIGN NAME=rownum VALUE=<@CURROW> SCOPE=request>
<@DELROWS ARRAY="trial_data" POSITION=@@rownum NUM=1 SCOPE="request">
</@COMMENT>
</@IF>
</@ROWS>
<@ASSIGN NAME=client_data VALUE='<@FILTER ARRAY="client_data"
SCOPE="request" EXPR="#2 !=545">' SCOPE=request>
<@SORT "trial_data" COLS=13 sortDir=ASC SCOPE=request>
<@ADDROWS ARRAY="trial_data" SCOPE=Request VALUE="<@VAR 'MO_DATA'
SCOPE=Request> " POSITION=0>
<@ASSIGN NAME="trial_data" VALUE="<@DISTINCT ARRAY='trial_data' COLS='3'
SCOPE='request'>" SCOPE="request">
<@SORT "client_data" COLS=13 sortDir=DESC SCOPE=request>
<@ADDROWS ARRAY="client_data" SCOPE=Request VALUE="<@VAR 'trial_data'
SCOPE=Request>" POSITION=0>
<@SORT "client_data" COLS=2 sortDir=ASC SCOPE=request>
</@IF>
Ben Johansen wrote:
There are few commands in Witango that let work with an array as like
a database. would be nice if there were more
you have 2 options,
option 1. you use an @for loop and query the date on each iteration
and adjust the value column if date meets condition.
but, if the array is large, a for loop can take to long on the server
and cause the browser to time out
option 2. use the @intersect like...
<@assign request$array2 <@filter request$array1 "#date >= <@var
request$date>">>
<@assign request$array2[*,value] 546>
<@assign request$array1 <@intersect array1=request$array1
array2=request$array2 cols=uniqueidcolumn alpha>>
this method create a temp subset array using @filter to do the
criteria, then you do an assign using * to iterate thru all rows in
array, then you use intersect to bring them back together using a
unique id field
On May 24, 2009, at 8:21 AM, Charles Brown wrote:
How do I edit data in an array? For all instances after a certain
date, I want to change a value of 545 to 546. I have a feeling this
is really obvious, but I am stumped. Thanks in advance for your help.
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
Ben Johansen
http://www.webspinr.com
[email protected]
Phone: 360-597-3372
Mobile: 360-600-7775
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf