• Accessing Syncdata

    From Angus McLeod@VERT/ANJO to Finnigann on Mon Aug 6 00:21:00 2007
    Here's a fairly simple JS script you can try. Copy it to "junky.js" in ãyour EXEC directory, and from there you can run it by typing ãã jsexec junkyããat a command prompt. Here is the script:ãã load("sbbsdefs.js"); // load some useful SBBS definitionsãã var sub = "hobbies"; // search this subã var subj_search = new RegExp(/Fokker/i); // RE searchã var want_body = false; // keep it shortãã // open the message base;ã smb = new MsgBase(sub);ã if ( smb.open != undefined && smb.open() == false) {ã printf( "Uh-oh! Can't access %s: %s\r\n", sub, smb.last_error );ã delete smb;ã exit;ã }ãã // process each message in message baseã for (ptr = smb.first_msg;ã ptr <= smb.last_msg && !js.terminated;ã ptr++) {ã // grab the headerã header = smb.get_msg_header( false, ptr, false );ãã // skip certain messages for operational reasonsã if (header == null) continue;ã if (header.attr & MSG_DELETE) // skip marked for deletionã continue;ã if (header.attr & MSG_MODERATED && !(hdr.attr&MSG_VALIDATED))ã continue;ã if (header.attr & MSG_PRIVATE) // skip private messagesã continue;ã if (header.reverse_path) // no dupe loopã continue;ã if (header.from_net_type // don't gateã && smb.cfg != undefined && !(smb.cfg.settings & SUB_GATE))ã continue;ãã // skip messages that don't match subject-wiseã if (!header.subject.match( subj_search )) continue;ãã // give some very basic header infoã printf( "From: %s\nTo : %s\nSubj: %s\n\n",ã header.from, header.to, header.subject );ãã // retrieve and message body if neededã if (want_body) {ã body = smb.get_msg_body( false, ptr, true, true, true );ã if (body == null) {ã printf( "Uh-oh! Can't read body for #%ld\n", ptr);ã continue;ã }ã print( body );ã }ã }ããIt searches the "hobbies" message-base for any message that mentions the ãword "Fokker" in the subject, and lists a few fields (and the body, if you ãreally want). It just lists on the console. You can redirect to disk.ããIt would be fairly straightforward to search according to a complex set of ãcriteria, examining from/to, date, etc and even the body-text itself, ãbefore deciding whether to dump the message or not.ããBiggest problem with this is that it searches every message in the message ãbase. *NOT* just the ones that have been added since the last time it ãran. You would have to store smb.last_msg in a file somewhere on disk and ãread it back for use as a starting point instead of using smb.first_msg ãwach time. Not hard, but not part of this simple example. ããNow, would a more advanced version of this script be what you are looking ãfor? (A separate script could be written to add messages to a sub.) ãAnd, with your
    knowledge of BATch programming, are you able to make any ãsort of sense of this programming?ãã---ãPlaying loud: "Star" by "David Bowie"ã from "The rise & fall of Ziggy Stardust & the spiders from Mars" album.ã þ Synchronet þ Where we BAJA Rob into writing our modules. The ANJO BBSã