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

[REBOL] Re: [bug?] Problem with 'load

From: brett:codeconscious at: 28-Nov-2003 23:26

> I was trying to think of a way of safely doing this myself, so your script > has given me hope that it is possible....We just need to solve the bad
preamble
> problem,
It would be better to have it fixed, but if you need the workaround I'm pretty sure it could be done with Parse and using a parse-rule that uses load/next (like the cookbook example to parse code). The trouble is knowing accurately what the rules are well enough to mimic the logic of REBOL when it validates a script. For example a valid file could have a preamble as you have shown, but it could also have an embedded script like: blah blah [ REBOL [Title: "Sample"] print now] blah blahblah blah blah blah Strangely enough, the Script? function that Yos pointed out seems to give a useful result in this case - the beginning of the embedded script, but not when the script is not embedded. Odd. Anyway, at least it will tell you if there is no point continuing :-) I think they are the two cases. If it is not embedded, it may have a preamble, then the rest is script. If it has an embedded script, then the script? function tells you were it is and you ignore the stuff coming after it. The embedded case should be easier to validate, the non-embedded case (having seen your example) means you probably need to be able to do a successful Construct on what you think is the header before you can call it the header. That's my guess - would be nice not to have to guess though. Regards, Brett.