Hey Jonah ! I have tried out your example and it works greatly. This example and the info you gave me have really helped me understand it better. Many thanks Jonah!
Best regards Bengt Bredin ----------------------------------------------------------------------- LabIT Solutions AB Stockholm SWEDEN ----------------------------------------------------------------------- -----Ursprungligt meddelande----- Fr�n: Jonah Simpson [mailto:[EMAIL PROTECTED] Skickat: den 23 december 2003 10:56 Till: [EMAIL PROTECTED] �mne: Re: Witango-Talk: Array Hey Bengt! Duh, I made a mistake a couple mistakes in my code (musta been too early in the morning) ; > Try this: <@assign request$init_string value="Sample,Station,Date,Unr/Bnr,Sample_Number,Location,Reference"> <@rows> <@cols array="request$Ttext"> <@assign request$init_string value="<@var request$init_string>,<@var request$Ttext[1,<@curcol>]>"> </@cols> <@break> </@rows> <@assign name='request$Excel' value="<@ARRAY VALUE='<@var request$init_string>'>"> The idea being that you're creating a string of column names delimited with commas. Then you use the original string (Sample,Station,Date,Unr/Bnr,Sample_Number,Location,Reference) of comma-delimited values, concatenated with the init_string (which is really a string of comma-delimited values) to form the init string for the array. What you were trying to do before wouldn't work, as by default, when you specify a array like <@var request$Ttext[1,*]> you're gonna get an output of the form: <td><@var request$Ttext[1,1]></td><td>,<@var request$Ttext[1,2]></td> etc for the number of columns in your array. (put <@var request$Ttext[1,*]> in a results action and then view source to see what I mean). You change the default row and column delimiters in the witango.ini file, but I don't like to code based on defaults, I'd rather explicitly assign everything (never know when you're gonna have to host your code on a server with different defaults). I belive you can set those delimiters inline in your code too, but I could be wrong on that. The reason <@assign name="request$Excel" value="<@var request$Ttext[1,*]>"> works is because WiTango recognizes Ttext as an array. The way you were trying to do it before, WiTango wasn't sure whether the string was of type text or of type array, and was taking the array part to assign to the new variable. I'm sure I'm about 90% correct on the reasoning, but I'm sure someone will chime in and correct me if I'm wrong. Bottom line is, you've gotta be careful with your typing. Hope this answers your question. Jonah Simpson [EMAIL PROTECTED] ----- Original Message ----- From: "Bengt Bredin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, December 23, 2003 1:32 AM Subject: SV: Witango-Talk: Array Thanks Jonah ! Yes, I think you are right, but how do I add columns to the request$init_string ? In your example I end up only with the last column from request$Ttext in the request$init_string. If I'm right it's not possible to add columns with @assign, only rows. What I am trying to do is to give the user an array for Excel that's different from the table structure of the database. I don't know the numbers of columns for the Excel array before the user search the database. Best regards Bengt Bredin ----------------------------------------------------------------------- LabIT Solutions AB SWEDEN ----------------------------------------------------------------------- -----Ursprungligt meddelande----- Fr�n: Jonah Simpson [mailto:[EMAIL PROTECTED] Skickat: den 22 december 2003 16:20 Till: [EMAIL PROTECTED] �mne: Re: Witango-Talk: Array With the code you're using, you're building an array with a comma-delimited list, which is all well and good, but to the best of my knowledge <@var request$Ttext[1,*]> will not output in a comma-delimited format that you need. You should probably just create a new variable and iterate through the cols in Ttext, adding each column as it occurs. <@cols array="request$Ttext"> <@assign request$init_string value=",<@var request$Ttext[1,<@curcol>]>"> </@cols> <@assign name='Excel' value="<@ARRAY VALUE='Sample,Station,Date,Unr/Bnr,Sample_Number,Location,Reference <@var request$init_string>"> Good luck! Cheers, Jonah Simpson [EMAIL PROTECTED] ----- Original Message ----- From: "Bengt Bredin" <[EMAIL PROTECTED]> To: "Witango-Talk" <[EMAIL PROTECTED]> Sent: Monday, December 22, 2003 8:12 AM Subject: Witango-Talk: Array | | Hey list ! | | I would like to say Merry Christmas to you all and at the same time ask | for some help concerning a problem I have. | | I have a one row array <@var TText> with x numbers of columns in it. | Then I would like to create a new array, also one row with 7 named | columns and the <@var TText> columns added. | What happens is that I only get the <@var TText> columns in the new | array. | | <@assign name='Excel' value="<@ARRAY VALUE='Sample,Station,Date,Unr/Bnr, | Sample_Number,Location,Reference,<@var request$Ttext[1,*]>'> "> | | What am I doing wrong ? | | | Best regards | | Bengt Bredin | ----------------------------------------------------------------------- | LabIT Solutions AB | SWEDEN | ----------------------------------------------------------------------- | | | ________________________________________________________________________ | TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf ________________________________________________________________________ TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf ________________________________________________________________________ TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf ________________________________________________________________________ TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf ________________________________________________________________________ TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
