If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Rate Thread | Display Modes |
#16
|
|||
|
|||
Request help with 40tude dialog program syntax
Op Sat, 31 Dec 2016 21:35:45 +0000 (GMT), Rodney Pont schreef:
var Remove_Headers : String; Try adding the var section as above. If that says it's a duplicate the Remove_Headers has been defined elsewhere, likely as a const, so try to find where and change it to a string. I see what you're getting at, which is to define the string as a variable instead of as a constant. Given that syntax is my only problem, this definition should work as the first 2 lines of the program after the "program" line, right? program OnBeforeSendingMessage; var Remove_Headers : 'User-Agent: ,Date: '; Unfortunately, that fails with the error below: http://i.imgsafe.org/8398770bfe.jpg "(Error) OnBeforeSendingMessage.ds(3.18): Identifier expected The actual syntax goal would be solved if I can do this: program OnBeforeSendingMessage; var Remove_Headers : 'User-Agent: ,Date: '; Remove_Headers : 'User-Agent: '; Remove_Headers : 'Date: '; function OnBeforeSendingMessage():boolean; begin end; begin end. I tried exactly that above, which is as simple as I can make the program. It failed with the same error: http://i.imgsafe.org/83b4808676.jpg The simple script fails with a "duplicate identifier": http://i.imgsafe.org/83c1060a72.jpg program OnBeforeSendingMessage; const Remove_Headers = 'User-Agent: ,Date: '; Remove_Headers = 'User-Agent: '; Remove_Headers = 'Date: '; function OnBeforeSendingMessage():boolean; begin end; begin end. |
Ads |
#17
|
|||
|
|||
Request help with 40tude dialog program syntax
On Sun, 1 Jan 2017 00:18:50 +0100, Stijn De Jong wrote:
Op Sat, 31 Dec 2016 21:35:45 +0000 (GMT), Rodney Pont schreef: var Remove_Headers : String; Try adding the var section as above. If that says it's a duplicate the Remove_Headers has been defined elsewhere, likely as a const, so try to find where and change it to a string. I see what you're getting at, which is to define the string as a variable instead of as a constant. Given that syntax is my only problem, this definition should work as the first 2 lines of the program after the "program" line, right? program OnBeforeSendingMessage; var Remove_Headers : 'User-Agent: ,Date: '; No, that shouldn't work, the var section should be used to define variables, not to set them to a value, it needs the word String to tell it that the variable is a string type, see above. Unfortunately, that fails with the error below: http://i.imgsafe.org/8398770bfe.jpg "(Error) OnBeforeSendingMessage.ds(3.18): Identifier expected The actual syntax goal would be solved if I can do this: program OnBeforeSendingMessage; var Remove_Headers : 'User-Agent: ,Date: '; Remove_Headers : 'User-Agent: '; Remove_Headers : 'Date: '; Even once you have defined the variable as a string it will only hold one assignment at a time so each time you assign a new value it overwrite the previous one and will have the value 'Date: '. I think you need to have the var section to define the string variable then you need you if elses to set it's value. function OnBeforeSendingMessage():boolean; begin end; begin end. I tried exactly that above, which is as simple as I can make the program. It failed with the same error: http://i.imgsafe.org/83b4808676.jpg The simple script fails with a "duplicate identifier": http://i.imgsafe.org/83c1060a72.jpg program OnBeforeSendingMessage; const Remove_Headers = 'User-Agent: ,Date: '; Remove_Headers = 'User-Agent: '; Remove_Headers = 'Date: '; function OnBeforeSendingMessage():boolean; begin end; begin end. -- Faster, cheaper, quieter than HS2 and built in 5 years; UKUltraspeed http://www.500kmh.com/ |
#18
|
|||
|
|||
Request help with 40tude dialog program syntax
Op Sun, 01 Jan 2017 08:11:09 +0000 (GMT), Rodney Pont schreef:
program OnBeforeSendingMessage; var Remove_Headers : 'User-Agent: ,Date: '; No, that shouldn't work, the var section should be used to define variables, not to set them to a value, it needs the word String to tell it that the variable is a string type, see above. HAPPY NEW YEAR! My mistake. I thought you were writing pseudocode. I just tried your method, and, I was shocked. It was the first time I did NOT get an error! http://i.imgsafe.org/8e26e05534.jpg (Sorry for doubting you.) So this "variable" thing is where I'll head next to try to resolve the problem. Unfortunately, it still failed when I tried to define the string. http://i.imgsafe.org/8e27315499.jpg program OnBeforeSendingMessage; var Remove_Headers : String; Remove_Headers='User-Agent: ,Date: '; Remove_Headers='User-Agent: '; Remove_Headers='Date: '; Note that I'm just testing by redefining the string three times. If it's a variable, that should not cause any error. Later on, once I can redefine the string, I will put it in an ifthenelse statement, but if I can't redefine it, the ifthenelse won't work either. Unfortunately, that fails with the error below: http://i.imgsafe.org/8398770bfe.jpg "(Error) OnBeforeSendingMessage.ds(3.18): Identifier expected The actual syntax goal would be solved if I can do this: program OnBeforeSendingMessage; var Remove_Headers : 'User-Agent: ,Date: '; Remove_Headers : 'User-Agent: '; Remove_Headers : 'Date: '; Even once you have defined the variable as a string it will only hold one assignment at a time so each time you assign a new value it overwrite the previous one and will have the value 'Date: '. This is what I want since I'm only trying to simplify the test case. If it's a variable, it should be able to take on any value, right? I think you need to have the var section to define the string variable then you need you if elses to set it's value. Since I was taking this step by step, where I first try to change the value and then once I can change the value, I can put it in an ifthenelse construct, I have to ask this question. Why can't I just set its value, for test purposes, to anything I want, and then change its value? var Remove_Headers : String; Remove_Headers='foo'; Remove_Headers='bar'; That seems to be the critical syntactical problem that I think I need to resolve, otherwise the iftehnelse will have the same problem anyway. HAPPY NEW YEAR! |
#19
|
|||
|
|||
Request help with 40tude dialog program syntax
On Sun, 1 Jan 2017 12:13:16 +0100, Stijn De Jong wrote:
Why can't I just set its value, for test purposes, to anything I want, and then change its value? var Remove_Headers : String; Remove_Headers='foo'; Remove_Headers='bar'; That seems to be the critical syntactical problem that I think I need to resolve, otherwise the iftehnelse will have the same problem anyway. Try, I think assignment needs the := syntax: Remove_Headers:='foo'; Remove_Headers:='bar'; HAPPY NEW YEAR! Happy new year to you too. -- Faster, cheaper, quieter than HS2 and built in 5 years; UKUltraspeed http://www.500kmh.com/ |
#20
|
|||
|
|||
Request help with 40tude dialog program syntax
Op Sun, 01 Jan 2017 15:47:11 +0000 (GMT), Rodney Pont schreef:
Try, I think assignment needs the := syntax: Remove_Headers:='foo'; Remove_Headers:='bar'; The syntax for dialog scripts is utterly incomprehensible. I had already tried a half-dozen (hit or miss) attempts and all failed. http://i.imgsafe.org/94013af980.jpg program OnBeforeSendingMessage; var Remove_Headers : String; Remove_Headers:='foo'; Remove_Headers:='bar'; const RemoveFromEmails = true; RemoveFromNews = true; procedure RemoveHeaders ( Message : TStringlist; IsEmail : boolean ); Failed when compiling [Error] OnBeforeSendingMessage.ds(4:1): Duplicate identifier 'Remove_Headers' I think I'm going to give up because I don't want to run you ragged. It seems, for now, that it's impossible to define a variable and change it in 40Tude Dialog, unless n unknown but very specific Dialog syntax is used. |
#21
|
|||
|
|||
Request help with 40tude dialog program syntax
On Sun, 1 Jan 2017 18:52:09 +0100, Stijn De Jong wrote:
http://i.imgsafe.org/94013af980.jpg Try: program OnBeforeSendingMessage; var Rmv_Hdrs : String; Rmv_Hdrs:='foo'; Rmv_Hdrs:='bar'; const RemoveFromEmails = true; RemoveFromNews = true; procedure RemoveHeaders ( Message : TStringlist; IsEmail : boolean ); Then change Remove_Headers to Rmv_Hdrs in the RemoveHeaders procedure at line 19 in the jpg you linked to above. Failed when compiling [Error] OnBeforeSendingMessage.ds(4:1): Duplicate identifier 'Remove_Headers' I think I'm going to give up because I don't want to run you ragged. It seems, for now, that it's impossible to define a variable and change it in 40Tude Dialog, unless n unknown but very specific Dialog syntax is used. I suspect the problem is because Remove_Headers is being defined elsewhere, I doubt if the problem is with the assignment. That's why I've suggested using a different variable name. Do they have a forum or somewhere you can ask? -- Faster, cheaper, quieter than HS2 and built in 5 years; UKUltraspeed http://www.500kmh.com/ |
#22
|
|||
|
|||
Request help with 40tude dialog program syntax
Rodney Pont wrote:
Do they have a forum or somewhere you can ask? The site with the script library recommends: "Support for Dialog and Dialog scripting can usually be found on the "news.software.readers" Usenet group. Begin the subject line of your post with "[Dialog]" for the best response." Library: http://dialog.datalist.org/scripts/script_library.html -- Mike Easter |
#23
|
|||
|
|||
Request help with 40tude dialog program syntax
Op Sun, 1 Jan 2017 13:32:20 -0800, Mike Easter schreef:
"Support for Dialog and Dialog scripting can usually be found on the "news.software.readers" Usenet group. Begin the subject line of your post with "[Dialog]" for the best response." Library: http://dialog.datalist.org/scripts/script_library.html I didn't see this until now, but here is the current script, which no longer has syntax errors and it re-defines the Remove_Headers variable. It doesn't actually do anything though, so, the logic must be wrong. I think the problem is that the if-then-else that decides whether to use the personal or business headers isn't getting or putting back the re-defined variable (because its not showing up in the log file). Here's the current syntax-correct but logic-incorrect script which is simply these two scripts melded together: 1. Determine Identity (either work or personal): http://dialog.datalist.org/scripts/C...gIdentity.html 2. Remove Headers: http://dialog.datalist.org/scripts/RemoveHeaders.html The goal was simply to meld the two above so that the headers change depending on the identity (either work or personal). --------------- cut here ------------- // The goal is different headers for work use versus for personal use. // This script has no syntax errors. // Modify the following values to fit your setup // 1. Remove_Headers (one for work and one for personal) // 2. Identity (one for work and one for personal) // 3. Newsgroups (work newsgroups can be different than personal ones) // 4. Servers (work servers can be different than personal servers) // program OnBeforeSendingMessage; var Remove_Headers:string; Begin // These are just default values. // The real values are set in an if-then-else statement later. Remove_Headers := 'X-Scoring: ,X-Hamster-Info: '; Remove_Headers := 'X-Scoring: '; WriteLn(Remove_Headers); End. RemoveFromEmails = true; RemoveFromNews = true; procedure RemoveHeaders ( Message : TStringlist; IsEmail : boolean ); var i : integer; k : integer; s : string; CommaPos : integer; DelHeader : TStringlist; RemoveH : String; begin RemoveH := Remove_Headers; i := 0; if ((IsEmail=true) and (RemoveFromEmails=true)) or ((IsEmail=false) and (RemoveFromNews=true)) then begin If ( RemoveH '' ) then begin try DelHeader := TStringlist.Create; if ansipos ( ',', RemoveH) = 0 then begin DelHeader.Add ( LowerCase ( TrimLeft( RemoveH ))); end // if else begin CommaPos := 0; for k := 1 to length ( RemoveH ) do begin If RemoveH[k] = ',' then begin DelHeader.Add ( LowerCase ( TrimLeft (copy ( RemoveH, CommaPos + 1, k - ( CommaPos + 1 ))))); CommaPos := k; end; // if if k = length ( RemoveH ) then DelHeader.Add ( LowerCase ( TrimLeft (copy ( RemoveH, CommaPos + 1, k - CommaPos )))); end; // for end; // else s:=Message.text; while (Message.Strings[i]'') do begin k := 0; while k = ( DelHeader.Count - 1 ) do begin if pos( DelHeader[k], LowerCase ( Message.Strings[i] )) = 1 then begin delete ( s, pos(DelHeader[k], LowerCase (s) ), length ( Message.Strings[i] ) + 2 ); i := i - 1; k := DelHeader.Count - 1; message.text := s; end; // if k := k + 1; end; // while i := i + 1; end; //while message.text:=s; finally DelHeader.Free; end; // try - finally end; // if end; // if end; // RemoveHeaders function StrMatch(str: String; pattern: String):Boolean; var patternSize : Integer; subStr : String; compareRes : Integer; begin patternSize := Length(pattern); subStr := Copy(str, 1, patternSize); compareRes := CompareStr(pattern, subStr); if (compareRes = 0) then result := true else result := false; end; function From2Identity(var Remove_Headers TStringlist; from: String: String; begin if (StrMatch(from, 'First1 Last1 ')) then result := 'id1' Remove_Headers='User-Agent: ,Message-ID: ' else if (StrMatch(from, 'First2 Last2 ')) then result := 'id2' Remove_Headers='Message-ID: ,Mime-Version: ' else result := 'unknow'; WriteLn(Remove_Headers); end; function NewsGroup2Identity(newsgroup: String): String; begin if (StrMatch(newsgroup, 'news.software.readers') or StrMatch(newsgroup, 'alt.os.linux')) then result := 'id1' else result := 'id2'; end; // The server identity doesn't seem to play any role in the decisions though... function Server2Identity(server: String): String; begin if (CompareStr(server, 'aioe_119') = 0) then result := 'id1' else result := 'id2'; end; function BadIdentity(): boolean; begin result := false; end; function CheckIdentity(var message: TStringlist; servername: string; isEmail: boolean):boolean; var fromIdentity : String; newsgroupIdentity : String; serverIdentity : String; i : Integer; begin if (not IsEmail) then begin for i := 0 to Message.Count - 1 do begin if (strMatch(Message[i], 'From:')) then fromIdentity := Copy(Message[i], 7, Length(Message[i]) - 6); if (strMatch(Message[i], 'Newsgroups:')) then newsgroupIdentity := Copy(Message[i], 13, Length(Message[i]) - 12); end; fromIdentity := From2Identity(fromIdentity); newsgroupIdentity := NewsGroup2Identity(newsgroupIdentity); serverIdentity := Server2Identity(servername); WriteToLog(' fromIdentity = ' + fromIdentity, 7); WriteToLog(' newsgroupIdentity = ' + newsgroupIdentity, 7); WriteToLog(' serverIdentity = ' + serverIdentity, 7); WriteToLog(' Remove_Headers = ' + Remove_Headers,7); if ((CompareStr(fromIdentity, newsgroupIdentity) = 0) and (CompareStr(newsgroupIdentity, serverIdentity) = 0)) then result := true else result := BadIdentity(); end else result := true; end; function OnBeforeSendingMessage(var Message : TStringlist; Servername : string; IsEmail : boolean ):boolean; begin // Added the result line below: RemoveHeaders(Message,IsEmail); WriteLn(Remove_Headers); result := CheckIdentity(message, servername, isEmail); result:=true; end; // ---------------------------------------------------------------------- begin end. --------------- cut here ------------- |
#24
|
|||
|
|||
Request help with 40tude dialog program syntax
Op Sun, 01 Jan 2017 20:45:40 +0000 (GMT), Rodney Pont schreef:
Try: program OnBeforeSendingMessage; var Rmv_Hdrs : String; Rmv_Hdrs:='foo'; Rmv_Hdrs:='bar'; Then change Remove_Headers to Rmv_Hdrs in the RemoveHeaders procedure at line 19 in the jpg you linked to above. http://i.imgsafe.org/94013af980.jpg Thanks Rodney for the added help, as I'm close to giving up since I should have known that it's too difficult for a layperson like me to logically figure out a scripting language. I did, however, with help from an expert on the language, get past the stumbler of the syntax, which is that a "begin" statement had to be used to re-assign the variable. http://i.imgsafe.org/99dc6c0dbe.jpg Program setRemoveHeadersString; var Remove_Headers:string; Begin Remove_Headers := 'X-Scoring: ,X-Hamster-Info: '; Remove_Headers := 'X-Scoring: '; WriteLn(Remove_Headers); End. I posted separately the current version, which has no syntax errors, but which fails to do anything (not even what they did originally), where all I essentially did was try to insert the Remove_Headers definition into an if-then-else condition. The script would be generally useful to those who have different requirements for work versus for personal use of the Usenet, so my dissillusionment will do others a dissservice. I may try to tackle it again in the future, but I think I'm out of my league because I can't get the if-then-else to use the re-defined variable (or even spit it out to the log file). |
#25
|
|||
|
|||
Request help with 40tude dialog program syntax
On Mon, 2 Jan 2017 15:28:29 +0100, Stijn De Jong wrote:
Thanks Rodney for the added help, as I'm close to giving up since I should have known that it's too difficult for a layperson like me to logically figure out a scripting language. I think you were just taking on a bit too difficult a task for your experience. After all you did get to grips with the idea of if, then else :-) Good luck if you do come back to it. -- Faster, cheaper, quieter than HS2 and built in 5 years; UKUltraspeed http://www.500kmh.com/ |
#26
|
|||
|
|||
Request help with 40tude dialog program syntax
Op Mon, 02 Jan 2017 15:54:15 +0000 (GMT), Rodney Pont schreef:
I think you were just taking on a bit too difficult a task for your experience. After all you did get to grips with the idea of if, then else :-) Thanks for the kind words. I thought, at first, it would be easier to decipher what the program did, since a program is written, essentially, in intuitively syntactic english. However, the tyranny of the specific syntax vagaries defied intuition. I still (wrongly) thought that I could experiment my way through the syntactic vagaries, but they defied all intuitive logic. You simply had to know that a BEGIN statement was required to change the value of a variable. This is not in the least intuitive, and never will be. Good luck if you do come back to it. I think the two problems that still stumble me a 1. How do I pass the variable into and out of the procedure that contains the ifthenelse (because I think that's not working). 2. How do I call, in the final lines, the two procedures so that they work together. If/when I can figure that out, everyone with a work/personal account who uses different servers, newsgroups, or headers, will be able to use it (if they use dialog). |
#27
|
|||
|
|||
Request help with 40tude dialog program syntax
On Mon, 2 Jan 2017 19:22:47 +0100, Stijn De Jong
wrote: I thought, at first, it would be easier to decipher what the program did, since a program is written, essentially, in intuitively syntactic english. How intuitive a program is depends on what language it is written in. Some are very intuitive; other are not at all intuitive. |
#28
|
|||
|
|||
Request help with 40tude dialog program syntax
Ken Blake wrote:
How intuitive a program is depends on what language it is written in. Some are very intuitive; other are not at all intuitive. The developer has provided a wealth of scripts. One good way to learn how a language works is to read a lot of scripts provided by an expert in the language, which are available. -- Mike Easter |
#29
|
|||
|
|||
Request help with 40tude dialog program syntax
On Sat, 31 Dec 2016 21:01:15 +0100, Stijn De Jong wrote:
Op Sat, 31 Dec 2016 20:50:46 +0100, Stijn De Jong schreef: This is the code I am using which sets the identity. http://dialog.datalist.org/scripts/C...gIdentity.html This is the code I am using which removes the headers: http://dialog.datalist.org/scripts/RemoveHeaders.html All I'm trying to do is meld the two, where the outgoing headers to be removed depend on the identity of the sender. At the risk of confusing the issue, here is the current code that was used to send this message, which has no syntax errors, and which sort of works but which allows only a single static setting for the remove headers variable. All I'm trying to do is add the simple decision below: [snip] Please use below modified script. http://pastebin.com/9kBWDbU8 I've added some comments for reference. HTH. |
#30
|
|||
|
|||
Request help with 40tude dialog program syntax
Op Tue, 3 Jan 2017 23:07:15 +0700, JJ schreef:
Please use below modified script. http://pastebin.com/9kBWDbU8 I've added some comments for reference. test... |
Thread Tools | |
Display Modes | Rate This Thread |
|
|