Try this for the CSS problem:
In internet explorer:
Tools > Internet Options > Accessibility (bottom button in IE6)
and uncheck everything.
Try this for the CSS problem:
In internet explorer:
Tools > Internet Options > Accessibility (bottom button in IE6)
and uncheck everything.
That'll only work in Internet Explorer surely? :| Do Netscape have an XMLDOM object equivalent? I know you can use a XMLHTTP transaction in Windows AND Netscape... but that's possibly overkill.
Woah... if you're gonna post the HTML you may aswell include the CSS aswell so I can have a proper look :P
In general though, if you class something, you can write a CSS block that matches and affects only objects of that class, class and tag, or class and tag and id.
instead of using tag id=mainnav and having CSS like:
tag#mainnav{} or
#mainnav{}
use class=mainnav and have CSS like:
tag.mainnav{} or
.mainnav{} if tag-name is irrelevant
Validitors shoudn't spit that back at you.
But it IS invalid (and restritive) to have objects with the same ID. Why do you say it will only work if they have the same ID?
Use this replace block: s|((?<![\w\d])pi(?![\w\d]))|3.14|g
It has a negative lookbehind (?<![\w\d]) and lookahead (?![\w\d]) for characters preceeding and following the word pi. For more about lookahead/behinds:
http://www.perl.com/pub/a/2003/07/01/regexps.html
Proofs:
my ($in) = "8 * pie";
$in =~ s/((?<![\w\d])pi(?![\w\d]))/3.14/g;
#result: $in = 8 * pie
my ($in) = "epi * 7";
$in =~ s/((?<![\w\d])pi(?![\w\d]))/3.14/g;
#result: $in = epi * 7
my ($in) = "pi * 4";
$in =~ s/((?<![\w\d])pi(?![\w\d]))/3.14/g;
#result: $in = 3.14 * 4
my ($in) = "pi * 4 * epi + pi / pie";
$in =~ s/((?<![\w\d])pi(?![\w\d]))/3.14/g;
#result: $in = 3.14 * 4 * epi + 3.14 / pie
PS: You may want to do another replace for multiplication shorthand: on paper 3PI * 4 is valid math markup; but if your passing this through an eval block; 3[pi replaced] isn't going to be the same. The block I've given you will NOT replace instances like this: 3PI. but it would replace the PI in instances like this: 3 PI (the space between 3 and PI is the key here). On that capitilized note, you may want to replace the "pi" in the block with (pi|PI|pI|Pi) a-la: $in =~ s/((?<![\w\d])(pi|PI|pI|Pi)(?![\w\d]))/3.14/g;
or do:
$in = lc($in); #convert characters to lowercase
$in =~ s/((?<![\w\d])pi(?![\w\d]))/3.14/g;
if you're not particularly interested in expandability/multiple users/complex permissions/etc, and your hosted on an Apache server, and you have proper access to your hosting server; you can do it without any scripting atall...
see:
http://www.javascriptkit.com/howto/htaccess3.shtml
I can't say I've ever tried it; but I'll probably end up doing it in places.. If only for entertainment. :)
what is the shortest way of printing 1..10 in any language?
i can't see any being much shorter than this :
1.upto(10) { |i| puts i }
In perl:
print 1..10;
or even shorter:
die 1..10;
the best way to parse XML is to ensure it is always strict :) have you looked at methods like XSLT for rendering HTML pages? I reckon you COULD even build an entire BB solution in XSL, although it'll get hella hacky in certain places.
With strict XML in Perl though it's very easy to write data in certain places; assuming you are outputting a new file though rather than overwriting part of an old one. You can conditionally skip/preserve whole blocks of data, perform operations like counting topics/replies automatically, and import/embed unknown numbers of related files just by reading a whole glob of them. It may be worthwhile to act on/consider each tag rather than just looking for specific ones though, it'll make your core system more useful in future.
Consider the fact that your final rendering process may have to read and buffer a substantial amount of your record file before it can complete; I paginate/split multiple records to 5-per-file even if my final intention is to output 20 records at a time.
I use permanent files like this:
<board>
<btitle>General Games</btitle>
<bdesc>General Discussion Regarding Computer Games</bdesc>
</board>
But that becomes this temporary file:
<board>
<breadcrumbs>
<breadcrumb href="../../index.xrm" name="forum" linked="yes">FusionGroupUK</breadcrumb>
<breadcrumb href="../index.xrm" name="group" linked="yes">FusionGames</breadcrumb>
<breadcrumb name="board" linked="no">General Games</breadcrumb>
</breadcrumbs>
<btitle>General Games</btitle>
<bdesc>General Discussion Regarding Computer Games</bdesc>
<bhottopic>
<topic href="a_test/index.xrm">
<ttitle>Testing Scopes</ttitle>
<tauthor>Guest</tauthor>
<tlastposter>Matt</tlastposter>
<tfirstdate>1161306255</tfirstdate>
<tlastdate>1161306000</tlastdate>
<tsummary>hello hello</tsummary>
<tpicture>a picture</tpicture>
</topic>
</bhottopic>
<btopics count="3" perpage="2" pages="1">
<page number="1" href="topics_page_0.xml"></page>
<page number="2" href="topics_page_1.xml"></page>
</btopics>
<btopiccount>3</btopiccount> …
I need to open the file, append data to the end, then set the write offset to a particular point in the file and write new data over old data. The required offset will already have been found somwhere else in the program during a read-only open of the same file.
To elaborate on what Kevin said, you're gonna find working this ^ way to get more and more unworkable as your project gets bigger. I'm also working on some BB script in Perl at the moment, I've found that the best way to deal with data is using small interlinked XML files that can gradually be transformed closer and closer to an HTML page as and when data changes. This ensures important data can't get damaged/overwritten accidently, ensures data is only ever updated when it needs to be, and lets me do the final rendering process using different template files to get a different visual output depending on who is logged in. Plus it doesn't use databases, can be something other than a BB (blog, profile site, even a complex dynamic site), all the data/template files are easily (humanly) interperable, and is relatively fast, compared to XSL transforms and the like anyway.
Well. that wasn't a blatent plug or anything :)
Some advice though;
- Fuse your read-only and writing operation. read data in and write data out uptill the point where you want to write new data, write the new data, then write the old …
I had a quick look at some of the Inline package documentation yesterday... It seems like you have an effective equivelent of C++ when you are using the package, so to terminate a C++ process will involve holding reference to the process and terminating it exactly as you would if it were a C++ process.
However, I would assume that terminating the Perl thread that indirectly launched C++ threads (via Inline) would terminate those active C++ threads. If you can't create a new Perl thread that isn't going to help you much anyway, unless you want to terminate the whole program.
Creating a new thread in C++ should give you a process ID; but that will not necessarily be recognised by Perl's kill() method or comparable with a Perl process ID.
Forecefully terminating a thread is platform dependant... I know the Windows API functions but not the *NIX ones.
I would poll a Perl function that returns a finite state (running/active). Then each C++ thread can call that function periodically, check whether it should be running or not, and either die of its own accord or run as it should.
You should be able to pass a Perl function/object pointer to each C++ thread when you create it; using Inline appends certain #includes to the C++ source, includes that allow you to access Perl functions from your C source. Passing a pointer will ensure that you access the function in your running Perl process rather …
do you want to stop a perl thread or a thread in an unrelated process?
the exit command should stop a perl thread. die may kill all threads (although it probably shouldn't?) and kill can be used to kill a process by reference.
Wahey... I have got it working how I originally wanted without the problem I just mentioned..
It doesn't seem conventional certainly.. And there is a potential risk of the user hitting Refresh while the login script is executing, which I guess would abort the script... Although; does a script get killed if it's started processing and the user agent leaves it?
I suppose what i want to do is:
- user clicks login button
- script executes silently
- page refreshes
- user is logged inSince that is not normal CGI behavior I would suggest against it. Most people expect whan they click a form button something will happen pretty much right away. If it doesn't they will probably click the button again or hit refresh, which might defeat the purpose of what you intend. You may have good reason for what you want to do, but using a CGI form might not be the best way to go about it.
You're right! I've changed my methods somewhat, and all my pages are processed by a CGI script. A side effect of that is that now I can pass GET/POST requests through the current page; making it possible to cut out the good old "Logging In..." interim page.
But, it's veeery unsatisfactory, if the user clicks "Back" the page resends the query; and it has to be a POST query. So that results in a sucky "The page cannot be refreshed without resending information" type error, and that can potentially occur on any page (i.e. index.html)
It was a nice idea; but I'll go back to my "Logging In.... Click here if you're stuck here" page. Think I might be able to get around the referer query parameter now though.. ;)
The perl interpretter is written in C but .pl files aren't executable. You can't make them executable without using some kind of Perl-to-C translater.
I wouldn't advise translating them!
ah.. got it. disregard this!
%ENV->{REQUEST_URI} returns the path/file. that's useable.
I've just registered a MIME handler for a custom filetype; I've got the basic redirection sorted, all files of type XRM get sent to a 'dumb' perl script that echos predefined values.
But, how do I read in the contents of the XRM file that invoked the perl script? Does it come into STDIN? More importantly, how do I get the folder of the file that invoked the script? I need to read in both the XRM file and potentially a number of other files referenced in that file... i.e. if the file "index.xrm" contains the string "manifest='index.xmf'" in the correct place, "index.xmf" should be read from the same folder as "index.xrm".
cwd() echos the folder that my script is in; and essentially, I want to chdir() to the folder where the invoking file is in as soon as the script is executed. Can I do this without using the browser location environment variable?
Thanks for reading,
Matt
I've never seen segmentation faults in Perl apps, so I'd guess the problem is between the inline CPP code and the CPP program itself.
The "best debugger" is assuming everything's going to go wrong before you start and making adequate provision for real-time/recorded logging throughout your code.
Break the program apart and test the CPP application from command line/within a C environment; if it works as expected, the problem is in the inline CPP perl module/with your usage of the module.
That's good; thanks for that, it works as I'd expect it to.
However, going back to my example...
If this:
my(@DREF_A) = @$REF_A;
my(@DREF_B) = @$REF_B;
push(@DREF_A,"hippos");
Is changed to this:
my(@DREF_A) = @$REF_A;
push(@DREF_A,"hippos");
my(@DREF_B) = @$REF_B;
Shouldn't that change the contents of @DREF_B? (The data should now be copied after the array is changed) It doesn't though, I've just checked it (same output as before).
Also, the @DREF_B output doesn't match the @DREF_A output even if both @DREF_A and @DREF_B are sourced from the same pointer, as in:
my(@DREF_A) = @$REF_A;
push(@DREF_A,"hippos");
my(@DREF_B) = @$REF_A;
Although it does work as per your example:
push(@$REF_A,"hippos");
my(@DREF_A) = @$REF_A;
my(@DREF_B) = @$REF_B;
Seems strange though! Shouldn't @$REF_A evaluate to the same thing whether its a subroutine parameter or a variable assignment?
I suppose, anything I do is going to have a similar overhead; it's always going to be neccessary to re-allocate sequential space to the array when the size changes..
I'm used to silence/seamlessness when using array references.
Maybe I'll use chained objects or psuedo-fixed-length arrays if it turns into a problem.. It's good to have an encapsulated array just-in-case
Hmm, I have ended up wrapping the array in an object for now.. My actual project is somewhat more advanced than that example; I need to be able to manipulate a number of arrays from many different "angles" without defining any kind of notification..
I can get READ access to the array without derefencing it, but write access (even by explicit index) doesn't seem to work for me without doing something like this:
my(@array) = ();
$self->{arrayref} = \@array;
[B]then sometime later...[/B]
my($REF) = $self->{arrayref};
my(@array) = @{$REF};
push(@array,$data);
$self->{arrayref} = \@array;
That's pretty much what the object I'm using at the moment does at every access... Is this really the best way to go about it? Because it seems like there's an amount of uneccessary garbage being generated behind the scenes.
I'm not going to go into much detail here; I've knocked up a lil example application to show where I'm having trouble; I'd like to know why $REF_DREF_A != $REF_DREF_B (and equally why there isn't a "hippo" qualifier to the "hello" in @DREF_B)...
But more importantly, can I easily make them the same, without wrapping "the array" in an object? I want to dereference the array (and still use it like an array), not clone it.
INPUT:
#!/usr/bin/perl
my(@array) = ();
push(@array,"hello");
my($REF_A) = \@array;
my($REF_B) = \@array;
print "contents of source array:\n\n";
print @array;
print "\n\nreferences to the source array:\n\n";
print "A: ".$REF_A." B: ".$REF_B;
my(@DREF_A) = @$REF_A;
my(@DREF_B) = @$REF_B;
push(@DREF_A,"hippos");
print "\n\ncontents of A dereferenced source array:\n\n";
print @DREF_A;
print "\n\ncontents of B dereferenced source array:\n\n";
print @DREF_B;
my($REF_DREF_A) = \@DREF_A;
my($REF_DREF_B) = \@DREF_B;
print "\n\nre-references to the source array:\n\n";
print "A: ".$REF_DREF_A." B: ".$REF_DREF_B;
print "\n\n";
OUTPUT:
contents of source array:
hello
references to the source array:
A: ARRAY(0x35fb0) B: ARRAY(0x35fb0)
contents of A dereferenced source array:
hellohippos
contents of B dereferenced source array:
hello
re-references to the source array:
A: ARRAY(0x1831e90) B: ARRAY(0x1831ec0)
Press any key to continue . . .
Mm, this was/is the desired context:
- user clicks on login button,
- page refreshes with the user logged in.
and this was the actual context:
- user clicks on login button,
- page changes as the script that verifies the user executes
- user hits back button
- user hits refresh a few times
- user is logged in
This is how it goes now:
- user clicks login button
- page changes as the script executes
- page is refeshed after two seconds (meta refresh) to the previous page (passed via a query string)
- user is logged in
I still love the first context, but for now, seems to be ok. Although, it sometimes takes more than one refresh for the page to correctly update o_O. I was using SSI to get the userstate information, now I'm using CGI-generated XML through-XSLT, and I know some cachings going on somewhere undesired! I may go back to the SSI option for deriving the present userstate. Dunno!
Thanks though, I will certainly aim for it to be the first way!
I suppose what i want to do is:
- user clicks login button
- script executes silently
- page refreshes
- user is logged in
I also don't want JavaScript to be required. So the only thing to play with is GET/POST form actions, the CGI itself, and what …
do you know java, or have they just taught you AI theory?
look for some java/C reference material. the java.com site sucks if you don't know any java. C doesn't have an official site, but there'll (probably) be more hello-world-type C apps on the net.
don't start until you know some of the language, and don't start until you write down some things on paper.
the question is an easy one, but it requires some knowledge of a programming language to implement a solution, and I assume write some kind of report. you'll get better marks if you submit some kickass diagrams or notes about how you intend to implement the solution than if you spend your time getting a runtime/compiler/ide installed and working, and learning the basics of your chosen language.
Eww >_< i'll pass that up. I suppose I could launch a new window aswell; but that's going against what I want rather than towards it. Maybe it could work though...
I think using the referer address and going back there might be a better method though. Is there an automatically-available (environment) way to access that reliably? But I suppose that'd suck if a user bookmarked the CGI script.
It's gonna be referer-by-query-string methinks, and it's GOTTA be deeper than javascript O_o.
Thanks anyway,
Matt
If you need results in real time:
If, from Perl, the C++ spawn call is syncronous, you'll have to spawn the C++ app hundreds or more times, losing your speed advantage, and outputing the result in Perl each time. Alternatively, you'll need two SEPARATE Perl apps, one to launch the C++ app, and one to read in the data, in order to simulate asynchronisity.
If the call is asynchronous, you'll have to find a way from the C++ process to connect back to the Perl process; there is an easy way, named pipes. I've never experimented with them in Perl, the standard named piping package doesn't work in Windows apparently.
But the concept is simple; you have a named filehandle, that is connected at one end to the C++ program and at the other end to the Perl program, all data written by the C++ program can be read into the Perl program and outputted.
Effectively, it's polling a virtual file that is closed and opened very frequently; and that's the easiest way I can think to simulate it in a Windows environment. From the C++ app, open the file (watching for errors), write some data, close the file; if you hit errors, try to open it and write until no errors. At the same time, in the Perl app, in a loop, open the file (ignoring errors), if there's data, output it, then clear the file and close it. You may end up with some …
Woah. I found the solution, but not the cause. If I hover my mouse over an image, and press Shift+R, it appears properly. Well strange, I was on this forum, and the solution appeared while my mouse rested over an image, in the form of a tooltip text box. I thought maybe, it was specific to this forum (bandwidth saving), but nope, it works anywhere - but the tooltip text only seems to appear here; but maybe it's only on images which would have tooltip text anyway..
I dunno if it'll work on firefox aswell; the same thing was happening there.
Got FTP aswell ^_- t'was a firewall issue.
That's a valid use of threads; but try to recycle them or make sure they're destroyed when they've finished their work.
Also, make sure they're not repeating time/memory consuming operations; I'm assuming you want to log data, either to a Perl/C++ process or to a datafile/database. Don't open the database/file in every thread, and/or don't spawn a new process to handle the result of each ping :P
Why is that you need to start/monitor the process from Perl? try and keep both programs entirely separate (i.e. able to perform independantly) but connect-able via parameterised calls/active reference passing. Bear in mind, it's always going to be easier to start a new instance of a program with parameters than connect to an (unrelated) active process and pass parameters. Also, bear in mind, if you do that after every ping (to send data to a Perl script) it's gonna start a new Perl script each time.
Why can't you keep the whole program in C++?
Matt
perl can start new threads (in a unix environment) and so can C++ (in any modern environment)
you could write a perl program with multiple threads that launched a c++ program with multiple threads, each thread could launch another perl program (or connect back to the same process) and within 5 seconds you'd have a right big knot of threads.
with regard to "how" or "can" it be done; providing your c++ program can be executed, take parameters, do its threaded business, and then (optionally) return to perl, you'll be fine. I have no experience with the inline module, but important considerations are:
-whether or not a call from perl to a c++ program is syncronous or asyncronous, if it's asyncronous, then the perl program will run the c++ program, then exit or continue whatever it was doing. (this is always an issue in any threaded/spawning system, particularly if the system is implemented in a language/environment not designed with threading specifically in mind. INFACT it's more of a consideration when creators of the environment decide that developers don't need control of threading, and that it'd be 'helpful' to manage such things automatically o_O) the reason i say that, is because it's highly possible that perl's spawning of a c++ program creates a new thread for that process. in that case, you'll need to be able to call a routine in an active perl process (or call a new perl process) from c++; if you want to tell …
When I was learning the basics of Perl CGI (well, any CGI) I vaugely remember something regarding a header or command that would invoke CGI script (using a standard GET request) WITHOUT changing the page that a user was on.
Googling hasn't been fruitful, I only remember a brief mention, and maybe it wasn't exactly what I'm thinking...
I can get around it, but it'll involve editing more than one document >_< I guess (for more than one reason) that it'd be a good idea to edit those documents anyway.
But; does anyone know what this mystical line is? or if it even exists?
So, I got a GPRS/UMTS modem for my laptop 2 days ago. It's extremely cool, maybe I'm only posting this message to show off that I have one.
But I'm honestly intriuged by an aspect of it.
It renders pages (layout, style etc) exactly how a wireless modem would, and for the most part, it seems like I'm using the Internet on a "normal" connection.
Until I hit GIF and PNG images that is. Transparent backgrounds = no way, and it insists on going to what looks like the Websafe pallete for all GIFs.
This never happened on a "normal" connection. Where's that happening? The ISP (T-Mobile) filter certain content; would they be likely to reduce the quality of images somewhere along the route? (which would actually save me money). Or is it a latency issue? Or is it something in Windows? Is it specific to the protocol? (I'm used to wireless broadband, I haven't been on a "dial-up" connection for years)
Alot of questions. I need to call T-Mobile anyway to cancel the WAP on my mobile phone, maybe they can give me an answer.
Actually, pictures render more "usually" on my mobile phone over WAP (oldschool GPRS not UMTS).
But anyway, I'm honestly not affected by it as an issue, I'd rather have FTP working :P
It's a good deal actually, if you need mobile WWW access anywhere with 3G or GPRS coverage, it's £19.99 a month; on an 18 …
It was very simple actually. I didn't need to use SSI #ifs atall! The file gets parsed before the XSLT does any work, so:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="[URL]http://www.w3.org/1999/XSL/Transform[/URL]" version="1.0">
<xsl:template name="logincontrols">
<xsl:variable name="userID"><!--#include virtual="../../cgi/sustain.cgi"--></xsl:variable>
<xsl:choose>
<xsl:when test="$userID = '-1'">
[Display some login-related info here]
</xsl:when>
<xsl:otherwise>
[Display some user-specific info here]
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
works just fine, because by the time the template is called, the user's id number (or -1) for null is in that variable. Pretty cool, pretty cool. I have a custom MIME type "SSIXSL" to avoid parsing every XSL file every time...
XSL is pretty fantastic.
This isn't an SSI or a CGI board, but I hear ColdFusion is quite SSI related, and it's the best place for this question I hope.
I'm wondering if it's possible to do something like this:
"html" page (actually XSL transformed XML page) has an SSI #include or #exec, then an SSI #if statement that does "something" based on a computation in the CGI...
Here's my questions with relation to that..
If I nest SSI functions will they be called in child > parent order or parent > child order? Can I read/write form/environment parameters in the CGI and read them back in the SSI #if?
I may have no need to do this eventually, but I only want my target modder-base to need to alter XSL files (to change style etc) and not look at CGI scripts... CSS is ok but not quite good enough, and I don't want to "read" XSL files in the CGI to simulate seamlessness... :( Any helper will get big shouts on my new site!
^_-
Matt
does it give an error or does it just hang indefinately? does it crash when you drop the control or when you try to use it?
it may be the case that your school computers have firewalls and your application isn't in the list of programs trusted to use the internet.
i just tried it out (i use Norton Internet Security) and; while you're developing/debugging, VB6.0 needs to be granted permission to use the net (gives a low warning), and when you build the app (and i expect everytime you rebuild the app) it needs to be given the same permission (but gives a high warning).
you can test if that's the problem by trying to open a local file, but with regard to connecting to actual webpages, this'll probably be the case with any software you write in any language!
Matt
Yes, but in the .NET framework you can just drag an internet browser in...
You can certainly drag on a web browser in VB6.0. Look in the extended/full control list.. I'll walk you through because I don't remember exactly myself..
Right click your toolbox and hit components, or go to project > components; then browse through the list until you reach "Microsoft Internet Controls", check the box, and you'll have a new component in the toolbox called WebBrowser. Use it like this: WebBrowser1.Navigate("AN_URL")
Matt
By programming myBrain (in real-time) to use the "handwriting" library : system requirements included "pencil" and "paper" : tested in the "my kitchen" environment only.
Yep that's right, I wrote down the numbers 1 to 10 on a piece of paper. It had a very short implementation time, and I even drew a squiggly line around the numbers when I'd finished.
I unfortunately can't provide any evidence to support this feat - you'll just have to trust me.
Matt
XML/XSLT
I guess XML isn't a language, and XSLT doesn't have to be, but this is certainly programmatic. It requires an input XML file and produces an HTML output file with the numbers one to ten separated by line breaks. The elements in the XML input file are irrelevant, as long as the root element is called "lots", and every "lots" element contains one more "lots" element than its parent. Until you get to ten of course.
Here's the input file (lots.xml)
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="countem.xsl"?>
<lots>
<lots><lots><lots>
<lots><lots><lots>
<lots><lots><lots>
<right /><what /><we /><are /><going /><to />
<do /><here /><is /><create /></lots><of />
<elements /><infact /><they /><are /><xml />
<elements /><and /></lots><of /><them /><are />
<in /><this /><file /><yes /></lots><of /><em />
<doesnt /><matter /><whats /><in /></lots><of />
<them /><because /><most /><infact /></lots><of />
<them /><are /><just /></lots><and /><thats />
<got /></lots><of /><importance /></lots><and />
</lots>
</lots>
And heres the XSLT stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="[URL]http://www.w3.org/1999/XSL/Transform[/URL]" version="1.0">
<xsl:template match="/">
<html>
<head><title>Count to ten!</title></head>
<body>
<xsl:apply-templates select="lots"/>
</body>
</html>
</xsl:template>
<xsl:template match="lots">
<xsl:value-of select="count(*)"/>
<br />
<xsl:apply-templates select="lots"/>
</xsl:template>
</xsl:stylesheet>
Matt
Delphi 7 is cross platform, more forgiving than C, and IMHO superior to VB for a number of reason; cross platform-ness being the first, automatic "relative" layout (applicable to GUI only) being the second, faster execution being the third, better (included) libraries being the fourth. Well. i could go on, but I wont. Try it out, although you'll need to find a version/IDE - Borland don't want to give out Delphi 7 IDE for free and have stopped providing version 6 for free...
EDIT: Thinking about it, I'm making this comparison with VB 6.0 rather than VB.NET, maybe .NET would beat Delphi on some of those.
Otherwise, go with C unless you wanna build an app and then find out it'll only work in a Windows environment. If on the other hand, you're learning programming from the begining; go with VB. By no means do I view spending 2 yrs of my teenage life finding out just how bad VB really is as a waste of time!
Matt
You should know when the data is going to change. Encapsulation isn't the best thing in the world, but it does let you notice changes in things. Your "data structure" should have methods that allow users to write to it, when these methods occur you can invoke an action in something "listening" to it. The observer class doesn't really do (or observe) anything!
If your data is modified outside the application you have to poll it for changes... or add some kind of OS hook that notifies your app; better still, only let your data structure be changed using a self-agreed protocol that involves notifying your "observing" program.
I have no idea why you'd wanna do this! and yeah, Java != JavaScript, although clearly some copying went on, on more levels than just name... JavaScript is NOT the same on all browsers though.
The code below is tested in Firefox and IE - it's a bit hacky to get the window width on a browser that doesnt define the window.innerWidth property by using an absolutely placed div element and measuring it.. but it works nonetheless.
Be careful what you put in the h1 tag; if it's short, then it'll take up most of the vertical page estate at reasonable page sizes, don't put page breaks in it either :|.
This only affects one id-ed element. "factor" is an arbitrary value, 2 is probably a little too big...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
var factor = 2;
function adjustSize(txt){
var target = document.getElementById(txt);
var charCount = target.innerHTML.length;
var docWidth;
if(window.innerWidth){
docWidth = window.innerWidth;
}else{
docWidth = document.getElementById('ruler').style.pixelWidth;
}
target.style.fontSize = (docWidth * factor)/charCount + "px";
}
-->
</script>
</head>
<body onResize="adjustSize('header')" onLoad="adjustSize('header')">
<h1 id="header">hello!</h1>
<div id="ruler" style="position: absolute; width: 100%"></div>
</body>
</html>
do you run the thread?
You need a way to connect the games in real time; painting the image is really the last of your concerns!
As jwenting said, you only need to pass player moves across the network; either as a stream of events or a sequence of moves that the client side program(s) can interpret into the present position of each piece.
You can use a port listening/telnet type system to connect the two games, or have them connect to a data resource on the internet and use it like a pipe.
The methods you use will influence the way users start a game, and the overall latency; I'd suggest using an online/text database that represents the actions of a single game rather than connecting clients directly (it doesn't require IP trading) and storing/sending the whole sequence of moves rather than a stream of moves (it's quite important that all data sent between users arrives at the other end in a game like checkers).
The actual means of sending the data over the Internet is maybe too flexible, you could connect to an FTP server to read/write the file, connect to a port on your server and send it a message to write/return the contents of the file, write a CGI script that the applications can execute... hmm, can't think of another raw method.
Java maybe (probably) has an interface that simplifies this kind of thing. Look in the java.net package or google something like... "java …
make sure you are uploading the file in ASCII (text) format and not binary format.
Hm; using Windows XP FTP you don't have a choice, and the files always read as ASCII when I view at them. Would I see a visible difference (in the file contents) if it was uploaded in binary mode? Surely there'd only be a problem uploading binary-type files as ASCII?
Komodo's remote save should certainly be ASCII though!
Loading an ftp client other than Windows XP is as much of an inconvenience as opening up cpanel..
It seems arbitrary sometimes; I've had success with XP FTP sometimes, and Komodo remote save sometimes : but the only way at the moment that I can guarantee 500 errors arent a result of my own mistakes is to create the files in cpanel and overwrite the contents...
It took me hours to figure out that that would work. Certainly seems strange!
my webserver's well wierd, i have a cpanel frontend i can login to plus various ftp clients on my pc; if i upload a perl script and set the permissions correct i get a 500 error, if i overwrite a working perl script (using ActiveState Komodo) i get a 500 error (of course i check the permissions afterwards!) if i upload a file then change the permissions using cpanel, guess what! i get a 500 error.
infact, the only way i can get a perl script up, is to use my cpanel to create a new perl file, then set the permissions, then overwrite the contents of the file; but only in cpanel.
what's with that?! :eek:
Ahh.. the problem was simple, the .htaccess redirect went to an index.html page with the above html; I think that page was provided with YaBB; because I don't remember writing it.
Still, problem solved, I just changed the redirect.
Matt
The index page of my site is redirected permanently to another page on my site using .htaccess, I'm messing about with IBP9's spider simulator to see how a search engine would see it; apperently this is what they'd see from the index page:
<html>
<head>
<meta http-equiv="refresh" content="0;url=./YaBB.pl">
</head>
I've changed the index page (it was totally blank) to have a hyperlink and note to the redirected page, still, the HTML above is all a spider sees.
If I spider the redirected page it's alot more fruitful, but most of my hyperlinks elsewhere (like the one in my signature :P) link directly to the root directory, so as they hit the redirect.
Is this ACTUALLY what the spider is seeing? and can I fix this problem without not using .htaccess?
Matt
B.t.w., did anyone here ever experimented with Brainfuck ?? It only has 8 commands, and looks a lot like a turing machine...
i was intrigued, so had a look on google, turned up alot of related material. For comedic value, this is a good contender for coolest programming language:
http://esoteric.voxelperfect.net/wiki/Hello_world_program_in_esoteric_languages#DOGO
EDIT : nope, i changed my mind; this is the coolest:
http://esoteric.voxelperfect.net/wiki/Hello
/EDIT
and this looks pro:
http://www.safalra.com/programming/gravity/specification/
I have been working on something like this recently; but the opposite, trying to implement real-time gravity in a matrix space based on the "accumulation" of mass. It's far too slow though :P
Matt
If you read it, don't assume you'll know C++ in 24 hours; I have learn C++ in 21 days sitting at home somewhere, and I don't really "know" C++. Still, I never finished the book.
But, from that I learnt enough to get a 2D playable demo (was zelda: a link to the past style, with movement, animation and table-based collision detection) up and running within about a week. But I knew quite a bit of DirectX anyway.
Learn C++ in 21 days is quite a sizeable book tho, has quite alot of reference material. I'd say reference material is more important than step-by-step guides in any case, they usually start with "Hello World".. anyway, and if you're running Visual Studio C++; it does "Hello World" for you :P
Look for a book that has an even amount of relevant code examples/explanations and reference material. It'll last you longer and ultimately be more helpful.
Still; learn C++ in 24hours might be the best book ever, I've never read it.
Matt
hm it might not automatically give a dedicated thread to processes; have you tried using an actionlistener that isn't the JFrame's action listener? that shouldn't make a difference tho.
Matt
The first language I learnt was QBASIC (actually, thats a lie, the first language I learnt was english..)
But yeah, QBASIC all the way, I was about 11 and I didn't even know what a pointer was, I don't think I even knew what an array was. My code must have looked horrible.
we should make a poll.
Matt
Then create an anonymous inner class' with these buttons...
you learn something new everyday. knowing that would have saved me alot of extension/workarounds in previous work.
Matt
really? i use it on jframes that don't really have uis (just a big Canvas/Cavnas3D); what does it mess up specifically?