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


 [1/3] from: ryan::christiansen::intellisol::com at: 30-Apr-2001 14:24

Can anyone point me to usage documentation for 'parse-header? Using 'help, I get the following, but I'm still not sure what 'parse-header is used for? (I'm trying to digest mime-model.r and it uses 'parse-header)
>> help parse-header
USAGE: PARSE-HEADER parent data DESCRIPTION: Returns a header object with header fields and their values PARSE-HEADER is a function value. ARGUMENTS: parent -- Default header object (Type: object none) data -- String to parse (Type: any-string) Thanks. Ryan C. Christiansen Web Developer Intellisol International 4733 Amber Valley Parkway Fargo, ND 58104 701-235-3390 ext. 6671 FAX: 701-235-9940 Global Leader in People Performance Software _____________________________________ Confidentiality Notice This message may contain privileged and confidential information. If you think, for any reason, that this message may have been addressed to you in error, you must not disseminate, copy or take any action in reliance on it, and we would ask you to notify us immediately by return email to [ryan--christiansen--intellisol--com]

 [2/3] from: brett:codeconscious at: 1-May-2001 8:00

Hi Ryan, The parent parameter of parse-header seems to provide a template of the object you want returned. Using none gives you an object where you only get fields for the header lines actually in your string and one content field. The use of parse-header in mime-model.r is parse-header none message because I want an object where only the header lines present in string become fields in the returned object. Here's an example of it in action:
>> probe parse-header none {any-old-header: some value
{ { The content} make object! [ any-old-header: "some value" content: "The content" ] Alternatively if I had a template I could do:
>> template-object: context [header1: header2: none] >> probe parse-header template-object {header1: value1
{ { My content - notice no header line for header2} make object! [ header1: "value1" header2: none content: "My content - notice no header line for header2" ] I came across the function when I was trying to understand how the import-email function worked. source import-email Regards Brett.

 [3/3] from: arolls:bigpond:au at: 2-May-2001 5:07

Here is the source, anyway:
>> probe second get in header-rules 'parse-head
[ head-list: make block! 10 if not parse/all data [header content] [ net-error "header not correctly parsed" ] make either parent [parent] [object!] head-list ] Anton.