[fpc-pascal] sentinels, "marks", enumerations
[follow-up from the thread about "void"] To favor the use of custom sentinels, I'm thinking at a Mark type. This is not strictly necessary, since the user can build individual marks or series of them easily. Either as distinct referenced objects or as plain values (logical, number, string...). This type would be make explicite the user's intention by using a dedicated type. Marks are basically value-less things. So they could simply be made distinct things. Like when creating a sentinel with "NOT_FOUND = Object()". (In my case it would then use Mark instead of object.) But giving them a distinct value can also be useful, so I could use nominals (http://en.wikipedia.org/wiki/Nominal_number), *arbitrary* numbers used to identify value-less things. A mark would then have a name for output and a number as ID. The type Mark would automatically increment numbers. But the user can also set the number if useful. This idea leads me to a feature similar to Pascal-like "enumerations" (weirdly called, imo): a set or sequence of marks, like for card suites. This would be done by the user subtyping Mark: then the nominals restart at 0 or 1. I just need a nice syntax to define all marks of a given type together, in both cases where the user sets the numbers or not: Suite : Mark.subType ["CLUB" "DIAMOND" "HEART" "SPADE"] Suite : Mark.subType ("CLUB":1 "DIAMOND":2 "HEART":3 "SPADE":4) Actually, new marks would be made slots of their type, under their own name, so that one would then write eg "Suite.SPADE". I prefere this than having SPADE in the global scope. Since the nominals are ordered, marks of the same type inherit this quality and can be compared for '<' (like in the game of bridge where card suites have different strength). Also, since the user can explicitely set the number of a given mark (which then is no more a nominal), this can be used in the app. Eg a user can make a CardValue subtype of Mark, to identify cards in a suite. And later use the card values to count points. The here missing feature Pascal offers is that a Mark subtype is not an ordinal type. It makes an ordered set in the sense marks can be compared for inequality; but it cannot be used eg to define an interval like highFigures : CardValue.J..CardValue.A (I don't know the card names in english, only their initial ;-) Equivalent marks are then simply set equal nominals. But I wonder if I shouldn't make marks referenced values (things) instead... (meaning test of equality doesn't even check the value number). Then, equivalent marks must be aliases of the same thing. Denis vit esse estrany ☣ spir.wikidot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] CGI application
This may not be the right place to ask, but I'm really stumped and would much prefer FPC over PHP. Can someone point me to how I can make a CGI app that outputs the fields in the query? ie. my.cgi?q=hello and my.cgi then outputs whatever q is? I'm using Lazarus but the deprecated CGI doesn't have any obvious way of getting the URL So I tried weblaz but got nowhere with it - TCustomCGIApplication's AResponse.Fields don't get filled with the query and AResponse.URL doesn't contain the URL for me to parse myself :( Thanks. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] CGI application
On Wed, 19 May 2010, Vannus wrote: This may not be the right place to ask, but I'm really stumped and would much prefer FPC over PHP. Can someone point me to how I can make a CGI app that outputs the fields in the query? ie. my.cgi?q=hello and my.cgi then outputs whatever q is? I'm using Lazarus but the deprecated CGI doesn't have any obvious way of getting the URL So I tried weblaz but got nowhere with it - TCustomCGIApplication's AResponse.Fields don't get filled with the query and AResponse.URL doesn't contain the URL for me to parse myself :( You need to look at "request", not at "response". Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] CGI application
Vannus het geskryf: > Can someone point me to how I can make a CGI app that outputs the fields in > the query? Think of CGI apps as simple Console applications (that's pretty much what they are). Everything after the ? is simply passed in as a parameter to your program. In it's simplest form you can write results back to the user using writeln() statements. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] CGI application
eh - im pretty sure im using ARequest and not AResponse (im on differnt pc just now, can't check) - but i'll definetly double check when i get back! How do i get command line vars? i tried GetENV() but it didn't understand GetEnv() (which unit is it in?) Cheers. On 19 May 2010 13:55, Graeme Geldenhuys wrote: > Vannus het geskryf: > > Can someone point me to how I can make a CGI app that outputs the fields > in > > the query? > > Think of CGI apps as simple Console applications (that's pretty much what > they are). Everything after the ? is simply passed in as a parameter to > your program. In it's simplest form you can write results back to the user > using writeln() statements. > > > Regards, > - Graeme - > > -- > fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal > http://opensoft.homeip.net/fpgui/ > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] CGI application
Vannus het geskryf: > > How do i get command line vars? i tried GetENV() but it didn't understand > GetEnv() (which unit is it in?) ParamCount() and ParamStr() is part of the System unit, so is always available. GetEnvironmentVariable() is in the SysUtils unit. Note that CGI apps use a lot of environment variables as well, so it might be beneficial if you loop through all of them and print them out so you can see what is available to you. I'm pretty sure Apache also comes with a sample CGI app which does this. Values stored are things like document root directory, server name, cgi application name etc.. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] CGI application
> How do i get command line vars? i tried GetENV() but it didn't understand > GetEnv() (which unit is > it in?) Here is a small cgi program. Comments are in Danish but I hope you can get the meaning. Carsten {Program version 1.00} program listdir2html; {LONGSTRINGS OFF} {$INFO +-+} {$INFO | Statistik projekt til Oegendahl |} {$INFO +-+} uses dos, classes, uInit, sysutils,{System} uSpStatus, testbruger; var QUERY_STRING:shortstring; Procedure PrintHeader(title:shortstring); Begin Writeln('HTTP/1.0 200 OK'); Writeln('Server: Netscape-Communications/3.0'); Writeln('Content-type: text/html'); Writeln; Writeln; Writeln(''); Writeln(''); Writeln(' '); Writeln(''); Writeln('',title,''); Writeln(' '); Writeln(' '); Writeln(''); Writeln(' '); Writeln(''); Writeln(' '); Writeln('',cFaellesOverskrift); Writeln(' '); Writeln(''); Writeln(' '); Writeln(''); Writeln(''); Writeln(' ',title); Writeln(''); End; Procedure PrintFooter; Begin Writeln(''); Writeln(' '); Writeln(''); End; Procedure FindOgListFiler(title,PartFileName:shortstring); var Info:TSearchRec; flist:tstringlist; p:integer; date,s:shortstring; Begin flist:=tstringlist.create; If FindFirst (PartFileName,faAnyFile,Info)=0 then {Find f°rste fil} begin Repeat flist.add(Info.Name); {Find de f°lgende filer} Until FindNext(info)<>0; end; flist.sort; {Soter filer} p:=flist.count; while p<>0 do {Print fil navn til HTML side} begin dec(p); s:=flist.Strings[p]; date:=copy(s,succ(length(QUERY_STRING)),12); date:=title+ copy(date,1,4)+ ' d. '+copy(date,7,2)+ '/'+copy(date,5,2)+ ' Kl. '+copy(date,9,2)+ ':'+copy(date,11,2); // WriteLn('',date,''); WriteLn(''); flist.delete(pred(flist.count)); end; flist.free; End; begin if not uSpStatus.InitShaerdMemory(InitShaerdMemoryStr,false) then begin PrintHeader('Beas login'); writeln ('Kan ikke initialisere shared memory'); PrintFooter; halt; end; if not ErBrugerOk then halt(1); QUERY_STRING:=getenv('QUERY_STRING'); if debug.Listdir2html then begin writeln(stderr); writeln(stderr,'QUERY_STRING= ',QUERY_STRING); end; chdir('..'); if pos('Statistik',QUERY_STRING)<>0 then begin PrintHeader('Historiske statistik data fra blandeanlµg'); FindOgListFiler('Statistik fil fra ','./log/statistik*.html'); PrintFooter; end; if pos('Blandelog',QUERY_STRING)<>0 then begin PrintHeader('Historiske log data fra blandeanlµg'); FindOgListFiler('Log fil fra ','./log/blandelog*.html'); PrintFooter; end; if pos('Program',QUERY_STRING)<>0 then begin PrintHeader('Historiske program data fra blandeanlµg'); FindOgListFiler('Program fil fra ','./log/program*.html'); PrintFooter; end; if pos('AlarmLog',QUERY_STRING)<>0 then begin PrintHeader('Historiske alarm log data fra blandeanlµg'); FindOgListFiler('Alarm log fil fra ','./log/alarmlog*.html'); PrintFooter; end; end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] TComponent with Corba Interfaces
Hi, I'm using TComponent has one of my base classes, but extending my classes with Corba style Interfaces. Will this not conflict with TComponent which already uses IUnknown (COM style interface)? Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TComponent with Corba Interfaces
On Wed, 19 May 2010, Graeme Geldenhuys wrote: Hi, I'm using TComponent has one of my base classes, but extending my classes with Corba style Interfaces. Will this not conflict with TComponent which already uses IUnknown (COM style interface)? Why should it ? The style of the interface only affects the interface. There is no reason why a class cannot implement interfaces of both types, independently of one another. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TComponent with Corba Interfaces
Michael Van Canneyt het geskryf: > > Why should it ? The style of the interface only affects the interface. I haven't noticed any issues, but was a bit concerned. I don't know how different the internal workings are between COM and Corba interfaces. So I thought I would ask before I got to far ahead with my current code. So I'll just continue coding as normal then - thanks for the quick response. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TComponent with Corba Interfaces
On Wed, 19 May 2010, Graeme Geldenhuys wrote: Michael Van Canneyt het geskryf: Why should it ? The style of the interface only affects the interface. I haven't noticed any issues, but was a bit concerned. I don't know how different the internal workings are between COM and Corba interfaces. So I thought I would ask before I got to far ahead with my current code. So I'll just continue coding as normal then - thanks for the quick response. With COM interfaces, reference counting mechanisms are inserted, with initialization/finalization and whatnot. With CORBA interfaces, no such 'extra' code is generated. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] CGI application
Thats me up & running now - thanks for your help guys, I'll certainly poke around those CGI vars. On 19 May 2010 14:19, Carsten Bager wrote: > > How do i get command line vars? i tried GetENV() but it didn't understand > GetEnv() (which unit is > > it in?) > > > Here is a small cgi program. Comments are in Danish but I hope you can get > the meaning. > Carsten > > > {Program version 1.00} > program listdir2html; > {LONGSTRINGS OFF} > > {$INFO +-+} > {$INFO | Statistik projekt til Oegendahl |} > {$INFO +-+} > > uses > dos, > classes, > uInit, > sysutils,{System} > uSpStatus, > testbruger; > > var > QUERY_STRING:shortstring; > > > Procedure PrintHeader(title:shortstring); > Begin > Writeln('HTTP/1.0 200 OK'); > Writeln('Server: Netscape-Communications/3.0'); > Writeln('Content-type: text/html'); > Writeln; > Writeln; > Writeln(' Transitional//EN">'); > Writeln(''); > Writeln(' '); > Writeln(' http-equiv="Content-Type">'); > Writeln('',title,''); > Writeln(' '); > Writeln(' '); > Writeln(''); > Writeln(' '); > Writeln(''); > Writeln(' '); > Writeln('',cFaellesOverskrift); > Writeln(' '); > Writeln(''); > Writeln(' '); > Writeln(''); > Writeln(''); > Writeln(' ',title); > Writeln(''); > End; > > Procedure PrintFooter; > Begin > Writeln(''); > Writeln(' '); > Writeln(''); > End; > > > Procedure FindOgListFiler(title,PartFileName:shortstring); > var > Info:TSearchRec; > flist:tstringlist; > p:integer; > date,s:shortstring; > Begin > flist:=tstringlist.create; > If FindFirst (PartFileName,faAnyFile,Info)=0 then {Find f°rste fil} >begin > Repeat >flist.add(Info.Name); {Find de f°lgende filer} > Until FindNext(info)<>0; >end; >flist.sort; {Soter filer} >p:=flist.count; >while p<>0 do {Print fil navn til HTML > side} >begin > dec(p); > s:=flist.Strings[p]; > date:=copy(s,succ(length(QUERY_STRING)),12); > date:=title+ >copy(date,1,4)+ >' d. '+copy(date,7,2)+ >'/'+copy(date,5,2)+ >' Kl. '+copy(date,9,2)+ >':'+copy(date,11,2); > > // WriteLn('',date,''); > WriteLn(' ONCLICK="window.location.href=''http:','../log/',s,'''">'); > flist.delete(pred(flist.count)); >end; > flist.free; > End; > > begin > if not uSpStatus.InitShaerdMemory(InitShaerdMemoryStr,false) then > begin >PrintHeader('Beas login'); >writeln ('Kan ikke initialisere shared memory'); >PrintFooter; >halt; > end; > if not ErBrugerOk then >halt(1); > QUERY_STRING:=getenv('QUERY_STRING'); > if debug.Listdir2html then > begin >writeln(stderr); >writeln(stderr,'QUERY_STRING= ',QUERY_STRING); > end; > chdir('..'); > if pos('Statistik',QUERY_STRING)<>0 then > begin >PrintHeader('Historiske statistik data fra blandeanlµg'); >FindOgListFiler('Statistik fil fra ','./log/statistik*.html'); >PrintFooter; > end; > if pos('Blandelog',QUERY_STRING)<>0 then > begin >PrintHeader('Historiske log data fra blandeanlµg'); >FindOgListFiler('Log fil fra ','./log/blandelog*.html'); >PrintFooter; > end; > if pos('Program',QUERY_STRING)<>0 then > begin >PrintHeader('Historiske program data fra blandeanlµg'); >FindOgListFiler('Program fil fra ','./log/program*.html'); >PrintFooter; > end; > if pos('AlarmLog',QUERY_STRING)<>0 then > begin >PrintHeader('Historiske alarm log data fra blandeanlµg'); >FindOgListFiler('Alarm log fil fra ','./log/alarmlog*.html'); >PrintFooter; > end; > end. > > > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] ftp server
Hi May I know if there are classes to implement an ftp server using fpc on Windows? Warm regards Nataraj ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] ftp server
Nataraj S Narayan het geskryf: > > May I know if there are classes to implement an ftp server using fpc > on Windows? I know the Indy components comes with clients and servers for just about any tcp, udp and raw sockets as well as over 100 higher level protocols. FTP Server being one of them. http://www.indyproject.org/Sockets/fpc/index.EN.aspx http://wiki.lazarus.freepascal.org/index.php/Indy_with_Lazarus Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal