Il martedì 9 giugno 2009 08:21:13 Doriano Blengino ha scritto: > Beren Scott ha scritto: > > The goal of my program is to keep an offline database and use it to plan > > out a series of actions which are html based and online. So, the > > database is accessed by my program, my program formulates with moderate > > user interaction the best course of action. The program copies a link to > > the clipboard, this link when pasted into a web browser will contain the > > decided action. > > > > There are a couple of ways I can do this, the first is to run a web > > browser and this program side by side and alt tab between them with the > > copy pasted link. > > > > If I cannot do this, then I have to incorporate the web browser directly > > into my program. I'd rather leave the browser part to the experts, but > > if possible it would be great to integrate them when I have a better > > idea of how to do this. > > > > Here is an example html link which I need entered into the clipboard: > > > > http://(server)/game.php?village=(villid)&screen=place&mode=command&targe > >t=(farmid) > > > > I can generate the string, that's the easy part, but getting it into my > > browser is going to be the hard part. There is issues with the SHELL > > option I believe due to the inclusion of "&", I don't think this is > > handled well. > > You can also start an external web browser from inside your program, > passing the URL to fetch on the command line; something like: > > SHELL "firefox http://www.yoururl.whatever" > > This way you avoid the burden to require the user to paste - in certain > cases this is a difficult operation. Moreover, if required, you can also > know when the external program terminates. > > Your problem about the URL passed on a command line, is because the > shell interprets some special chars like "?", "=" and "(" ")". > > You only have to surround your parameters with a couple quotes: > > fetchurl = villurl[z - 1] & farmid[c - 1] > SHELL "firefox \"http://" & fetchurl & "\"" > > Please note the --\"-- (backslash-doublequote) embedded in string > constants. These are required because otherwise the shell, invoked by > SHELL, would be confused from the above mentioned characters like question > marks and other. You can experiment from a terminal emulator to better > understand when and where quotes are required; then you replicate them > inside gambas. In this case, simply a couple quotes around the url passed > to firefox is required, or, only now I realize, even better is to use the > single quotes - it is even simpler in gambas: > > fetchurl = villurl[z - 1] & farmid[c - 1] > SHELL "firefox 'http://" & fetchurl & "'" > > > This is better because of the shell /bin/sh, which still can interpret > some things embedded in double quotes (for example, dollar signs), but > surely will do nothing inside single quotes. Sorry for this confusion. > > Anyway, knowing about this quoting is good for everytime you use the > SHELL command, so it is good also if you choose the xclip way. If you go > deeper in this topic of launching external programs, take a look at > EXEC, a little more complicated but more powerful. > > Regards,
Little info: Gambas provide a Quote class with few useful functions. One of them is Quote.Shell, that protects with quotes the argument you pass to SHELL. Examples: 1) SHELL "echo " & Quote.Shell("$PATH") WAIT 2) SHELL "echo " & "$PATH" WAIT Bye, Stefano ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user