Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

an awful 'to-word bug...

 [1/6] from: Christophe::Coussement::mil::be at: 8-Sep-2003 10:10


Hi list, I just spent about one hour to find this awful bug into my code, which I want to share with the list. SITUATION: --------- I'm loading data from a SQL Server table containing a field "label" in char(30), which results in something like: string-label: ["label1 " "label2 "] I wanted to use those to _labelize_ some data in to a block, so i did:
>> a-block: copy [] >> foreach label string-label [append a-block reduce [to-word label "test"]]
which should have result:
>> a-block
== [label1 "test" label2 "test"] but
>> a-block/label1
** Script Error: Invalid path value: label1 ** Near: a-block/label1 OBSERVATION: ----------- the content of a block was not as expected, but was initially attributed to a REBOL formatting problem:
>> a-block
== [label1 "test" label2 "test"] SOLUTION: -------- There was no formatting problem, but the 'to-word function did not execute any trim before converting the string! into word!, so
>> a-block/label1
couldn't possibly work, as a-block/label1........24 spaces..... should have Solution is then obvious (aren't they always once you found the problem :) ): 'trim the string
>> string-label: ["label1 " "label2 "] >> a-block: copy [] >> foreach label string-label [append a-block reduce [to-word trim label "test"]]
== [label1 "test" label2 "test"]
>> a-block/label1
== "test" Hopes this information helps someone ! CU, ==xtof

 [2/6] from: andrew:martin:colenso:school at: 10-Sep-2003 10:08


Christophe wrote:
> >> a-block > == [label1 "test" label2 "test"]
One of the problems of this approach is that your code has to "know" the labels, like:
> >> a-block/label1 > == "test"
Have you considered something like this:
>> a-block: ["label1" "test" "label2" "test"]
== ["label1" "test" "label2" "test"]
>> select a-block "label1"
== "test"
>> L: "label2"
== "label2"
>> select a-block L
== "test" ? Andrew J Martin Attendance Officer & Information Systems Trouble Shooter Colenso High School Arnold Street, Napier. Tel: 64-6-8310180 ext 826 Fax: 64-6-8336759 http://colenso.net/scripts/Wiki.r?AJM http://www.colenso.school.nz/ DISCLAIMER: Colenso High School and its Board of Trustees is not responsible (or legally liable) for materials distributed to or acquired from user e-mail accounts. You can report any misuse of an e-mail account to our ICT Manager and the complaint will be investigated. (Misuse can come in many forms, but can be viewed as any material sent/received that indicate or suggest pornography, unethical or illegal solicitation, racism, sexism, inappropriate language and/or other issues described in our Acceptable Use Policy.) All outgoing messages are certified virus-free by McAfee GroupShield Exchange 5.10.285.0 Phone: +64 6 843 5095 or Fax: +64 6 833 6759 or E-mail: [postmaster--colenso--school--nz]

 [3/6] from: Christophe:Coussement:mil:be at: 10-Sep-2003 8:11


Hi Andrew,
> Christophe wrote: > > >> a-block
<<quoted lines omitted: 13>>
> >> select a-block L > == "test"
Actually, the approach you describe is the one i use when it goes about dynamic adressing, as in:
>> labels: ["label1" "label2" "label3"] >> foreach label labels [select a-block label]
But in this particular case of use, i have to adress deep nested informations, and the path notation seems more appropriate to me:
>> bennet_raw: ab_results/bennet/total/scale/score/raw/
I guess it's more a coding convention we use inside the project: a label should be word! Thanks for your suggestion ;-)) ==xtof

 [4/6] from: antonr:iinet:au at: 10-Sep-2003 17:45


I am interested why you need to do this. How is your code used. Can you show us some real example data? Anton.

 [5/6] from: Christophe:Coussement:mil:be at: 10-Sep-2003 12:44


Hi Anton,
> I am interested why you need to do this. > How is your code used. > Can you show us some real example data? > > Anton. >
USE CONTEXT ----------- Scales evaluation of psychotechnical testing are stored into a MS SQLServer DB There is one row per scale. I need to get those data, reformat it for easier access, and compose a report which will be submitted to the psychologist who will evaluate the client. EXAMPLE ------- 1. Get data from DB: ["84040942" "10-4-2002 " 6 "CP" "Ac " "25.00" "46.00 "] ["84040942" "10-4-2002 " 6 "CP" "Ai " "23.00" "42.00 "] which are: ['client_id 'comparution_date 'test_id 'test_name 'scale name 'raw_score 'standard_score] 2. reformat the data, which become: results: [cp [test_name "CP" test_date "10-4-2002" Ac [raw "25.00" std "46.00"] Ai [raw "23.00" std "42.00"]] 3. use those reformated data for reporting: ac: results/cp/ac/std ai: results/cp/ai/std report: compose/deep load pdf-report-template in which 'pdf-report-template is a "pdf-maker"-based document definition where ea we find: textbox 82 13 30 5 [font Courier 4 "Lp = " (ac)] All those handling results into a dynamic created PDF report. More than 200 data/clent are handled the same way, which results in 5 reports. Hope this answers your question ;-) ==xtof

 [6/6] from: antonr:iinet:au at: 11-Sep-2003 0:40


Certainly, thankyou. -Anton.

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted