Wikipedia:Reference desk/Archives/Computing/2009 July 26
Computing desk | ||
---|---|---|
< July 25 | << Jun | July | Aug >> | July 27 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
July 26
[edit]latest version of IE
[edit]Why does the lastest version of IE not support Unicode in the bottom at the status bar and in the address bar too? Firefox can display proper characters instead of escape codes! Is it because the folks at Microsoft just can't be bothered? I mean, how much effort could it possibly take to do that???
Duomillia (talk) 01:00, 26 July 2009 (UTC)
- No, you screwed something up on your system, not Microsoft. Unicode characters display great in my browser. For example, when I type this into the address bar, it loads fine: http://ουτοπία.δπθ.gr. But why are you asking us, anyway? Start a thread in a Microsoft Technet or Connect forum, if you're so sure that it's a bug. They're actually pretty good with fixing bugs if you make any kind of effort to contact them. By the way: In my experience, most people don't even know the status bar is there. The latest version of Internet Explorer is actually over-engineered in my opinion -- not the opposite.--WinRAR anodeeven (talk) 02:59, 26 July 2009 (UTC)
- This is a deliberate feature intended to prevent phishing attacks. See IDN homograph attack. Internationalized domain names were not designed very well. Firefox also displayed decoded names in the address and status bars for a while. According to the article they now use a top-level domain whitelist. There's an IE option "always show encoded addresses", but I recommend you leave it off unless you use IDNs a lot. -- BenRG (talk) 11:03, 26 July 2009 (UTC)
J2EE programing
[edit]please suggest me a wonderful book or a good tutorial or website or anything which can teach me J2EE programming and HTML thoroughly...assuming that I have a basic knowledge of C,C++,JAVA.I am in great need to learn it.pl help —Preceding unsigned comment added by 117.193.128.204 (talk) 04:26, 26 July 2009 (UTC)
- Java EE, like the rest of the Java technology platform, has no better resources than the Official Sun Java EE technology guide, including source code, example projects, tutorials, and all the software and tools you need to make a project. Download GlassFish and run the PetStore example application. You can find tutorials here: Java Pet Store. You can download all the tools here (check for your operating system and language version). Nimur (talk) 05:26, 26 July 2009 (UTC)
- Regarding HTML, I use the W3 official specification as my preferred reference. If I were just starting out, I would try reading the HTML article on Wikipedia, which is a little more user-friendly. In general, HTML is best learned by viewing examples; once you have the basic tags, simply start viewing source for web pages you are browsing to take a peek under their hood. A lot of modern web pages use very complicated HTML combined with scripting and embedded plugins, so they can be intimidating source to read; but it's a good idea to get a feel for how the pages are put together. Nimur (talk) 05:32, 26 July 2009 (UTC)
Annoying Freeze
[edit]Every now and then I get sudden freezes. The computer completely locks-up. I cant move the mouse or use keyboard everything is frozen, you know what I mean. ALL i can do is restart pc. Another problem is desktop icons, start menu, images (also in internet image) gets broken into pieces and I can't see image properly. It looks like image gets scratched.
First I thought this was a cpu problem, then motherboard, then graphics card, then ram, hard drive etc. I just cant figure it out. It happens when I am on minefield, IE (latest version) firefox 3.5, when I am logging in at facebook. Even this problem persist after closing browser ! This was an issue before as well I don't know what is causing this freezes. If I play any music when I'm on browser the sound also gets crashed (screaming like carrrrr...). These are happening after upgrading my hardware. I am using XP SP 2. My processor is Core 2 Quad 9400 (which requires Vista 64 bit SP 1 though) and motherboard 750i SLI Nvidia Geforce, RAM 2 GB (800MHz), Sapphire ATI 4890 1 GB, Full tower Chassis (Tharmaltake Xaser VI). I have several XP SP 2 OS. The Current XP SP2 that I'm using, bought it 4 years ago.
How can I rectify this problem?--119.30.36.47 (talk) 14:36, 26 July 2009 (UTC)
- The problem sounds like a hardware crash due to overheating. I would perform any available BIOS and/or graphics driver updates, then use a hardware monitoring tool like HWMonitor (there are various free ones) to track down the problem. Rjwilmsi 17:28, 26 July 2009 (UTC)
- But Sometimes I can move mouse for a while then it suddenly stopped again. You said"I would perform any available BIOS and/or graphics driver updates. My BIOS and graphics card are already updated (Correct me if I am mistaken). I have used HWMonitor. It shows only temperature after the crash. GPU Core is 61 *C to 63 *C. My full tower chassis has 5 collar fan (including two 140mm turbo fan) inside to provide sufficient airflow. What else I can do?--119.30.36.33 (talk) 18:17, 26 July 2009 (UTC)
- 63C is too hot. Try this - open your case and blow an ordinary room fan into the case to cool it down further. Your GPU should get below 50C... see if that helps. Either your case airflow is not optimal or helping the GPU, or there's something faulty with your graphics card. Sometimes these weird freezing/rebooting problems are due to the power supply which is faulty or dusty and your CPU is not receiving clean power from it. My last two PC problems were: playing video rebooting PC (replaced GPU) and random rebooting doing anything (replaced and upgraded power supply). Good luck. Sandman30s (talk) 09:55, 27 July 2009 (UTC)
- I forgot to mention that this freezing problem occurs only when I run my system for 8 to 12 hours or sometimes 5 hours.You said, "blow an ordinary room fan into the case to cool it down further". Are you suggesting me to add another GPU Cooling fan in additional slot (sorry for my English)? The chassis contains some extra slot for fans. One more thing is that my motherboard contains two GPU Slots. The First slot (where graphics card is attached) is located a bit above to turbo VGA cooling fan and does not get proper air. Second slot is closely located to the cooling fan and gets much air flow. I am thinking to remove Graphics card from first slot and attach it to second slot. I notified the hardware technicians (where I assembled my systems) about my intention but warned me not to do that as the second slot is for another graphics card and if the first slot does not work. They also suggested me to disable system restore point and schedule scanning of internet security to prevent this freezing state. Should I proceed to second slot? Suggestions ? --119.30.36.39 (talk) 13:32, 27 July 2009 (UTC)
Update: I have checked the BIOS. It shows CPU temperature is 30 to 31 *C and System temperature is 40 to 41*C.--119.30.36.42 (talk) 15:01, 27 July 2009 (UTC)
- No, I mean: open the case. Take an ordinary electric powered fan that plugs into the wall socket. Plug it in. Turn it on. Face it towards your open case and your computer will get the benefit of cool air blowing directly onto the GPU's and everything else. This is a TEST. If it works, it means you have a heating problem and then you either need to swap your card/s or get better cooling in your case. Sandman30s (talk) 15:41, 27 July 2009 (UTC)
Ok. But is temperature from BIOS Ok or not. I should have mentioned that this freezing problem usually occurs when I am on online (after 12 pm) for 5 to 8 hours. Yesterday I run my system for 10 hours and nothing was happened. It seems that it only happens while I'm on online (I tested with all browser). I use Modem for net connection. If It's not overheating issue what else can it be? Is modem incompatible with system (which causes this freezing)? --119.30.36.53 (talk) 12:15, 28 July 2009 (UTC)
Windows 7 Torrent
[edit]I've been having a discussion with some friends and they don't believe that Windows 7 is already up on torrent sites (a full version) and I'm sure it must be. Though at the moment we're unable to access those sites ourselves. I was curious if someone could confirm whether it appears that full versions of Windows 7 are available to torrent. Of course, I wouldn't ask someone to link to them, just a confirmation that they themselves have seen it (and if you have used it, if it was for real). Thanks! 71.75.71.102 (talk) 14:47, 26 July 2009 (UTC)
- Since even before the beta of Windows 7 became publicly available there have been versions of Windows 7 leaked to torrent sites. However, some of these leaked versions are known to have been tampered with or to contain malware and I would not recommend anyone try to download and use any of the leaked versions. Consider trying out the Release Candidate instead (Which expires June 1, 2010, with bi-hourly shutdowns beginning on March 1, 2010) or waiting for the final version of Windows 7 which you can pre-order now.--Xp54321 (Hello! • Contribs) 17:05, 26 July 2009 (UTC)
- You could also use this[1] Mac Davis (talk) 00:45, 28 July 2009 (UTC)
Is this the end of my Nintendo DS?
[edit]As the title suggests, I'm worried that my DS going to become unplayable and I need some links or advice if the thing is on it's last legs or not. My problem is that when turning the DS on, it will be okay for a bit, then have some odd display problems (I can see something that looks like a brownish circuit board through the screens) I took out both of the games I was playing to see if they were the problem, but they weren't, the problem persisted even with both slots empty. If I plug in the headphones, the top display stops being wonky, but the bottom screen remains odd.
Another thing about the DS is that it got fried once by getting drenched by an exploding pop bottle, but when it dried out it worked just fine for a few months. Suddenly the speakers stopped working. I didn't really care, it worked fine with headphones plugged in so I left it and enjoyed it for no problems . Two days ago, the speakers suddenly began working again. And now today I'm getting these display problems. I'm not sure if the display and speaker problems could be linked, but it might explain why the display is okay on the top screen with the headphones plugged in.
So really, all I want to know is if my DS is doomed to die and I need to start looking for a new one. The display doesn't bug me that much, so if it'll be okay how it is and not die, I won't bother replacing it. Also, I can't really send it in for repairs because I have a feeling the pop explosion a year ago is what caused it. Also this DS is an original one (Not a Lite nor a DSi) and is about 4-5 years old now, it's warranty is probably gone by now. Thank you for your time. 69.157.106.254 (talk) 14:54, 26 July 2009 (UTC)
- It is very likely that the circuits are corroding, and will die a slow death. Sorry. You could try cleaning its innards with distilled water or alcohol. (Do not use tap water.) That may help, but it would have helped more back when the accident first occured.
- It's also possible that there is still soda on the board and it's causing intermittent short circuits. Again, that might be helped by cleaning it.
- There is no way to know for sure, but either way I suspect that if you don't take it apart and clean it (No tap water!) it will slowly get worse. APL (talk) 17:54, 26 July 2009 (UTC)
- Oh well. I wished I'd known about cleaning it when the whole thing happened a year ago. Thanks for your help. I'll give cleaning it a shot and start looking around for discounts for when the poor thing kicks the bucket. I'm just glad it managed this long, now with the DSi out, getting a DS will be cheaper. Thanks again! 69.157.106.254 (talk) 18:10, 26 July 2009 (UTC)
Resources for a beginning teenage programmer
[edit]I'd like to get my Nephew into development, probably with an ultimate goal of working in a MS or web environment (.NET I suppose?). He's a beginner so I guess the question is what's a good starting point or general introduction. Are there any interactive tools you can buy that can take you through lessons/labs? I don't know much about development but I'd be interested in something that's more focused on doing rather than reading...he's 14 so I'm nor sure how much time he'd spend sitting around just reading. Thought? Thanks...RxS (talk) 15:09, 26 July 2009 (UTC)
- I'm 21, and I learned in Visual Basic around 14, but that's on the decline now. I'd recommend something like Java, and this is a tutorial I particularly enjoyed because it's more interactive. [2]. Hope that's useful. 71.75.71.102 (talk) 15:29, 26 July 2009 (UTC)
- I'd suggest one of the Game engines, such as Game Maker. I've used them with teenagers before, and they have the advantage of being interesting to program in quickly. While the language isn't much use itself, the principles are. Alice is a good beginner's language as well, with quick rewards, but I'm not sure if it has a clear path for where to go once you get the hang of it. It does have nice tutorials, though. For serious languages, I'd go straight to C# or Java. I'd add that the main aim is to keep it interesting from early on, and part of that is making the projects interesting. - Bilby (talk) 15:44, 26 July 2009 (UTC)
- That's what I'm mainly interested in, fairly quick engagement/visible results that provide a good foundation and path to more advanced concepts in current technology. Thanks! RxS (talk) 15:54, 26 July 2009 (UTC)
- I'd suggest one of the Game engines, such as Game Maker. I've used them with teenagers before, and they have the advantage of being interesting to program in quickly. While the language isn't much use itself, the principles are. Alice is a good beginner's language as well, with quick rewards, but I'm not sure if it has a clear path for where to go once you get the hang of it. It does have nice tutorials, though. For serious languages, I'd go straight to C# or Java. I'd add that the main aim is to keep it interesting from early on, and part of that is making the projects interesting. - Bilby (talk) 15:44, 26 July 2009 (UTC)
- It sounds like Java is a good starting point, are there any other resources available? The one linked above seems to give Vista/IE 7 fits. Thanks again...RxS (talk) 17:05, 26 July 2009 (UTC)
- http://math.hws.edu/javanotes/c3/index.html this link causing problems - I'm on IE7 and it seems to work perfectly.? Seems such an innocuous site.
- Resources for learning java? - sun has one - tutorials, plus lots of documentation - just search for "sun java", and you should find it. I believe they have a 'young programmers' section or program as well. Here's a start page http://java.sun.com/new2java/learning/young_developers.jsp Possibly the first few sections are aimed at younger children.83.100.250.79 (talk) 22:10, 26 July 2009 (UTC)
- If they have no programming experience before I would probably recommend something else - probably python (programming language) (since everyone else does) - it's pretty much the equivalent of what BASIC was 20 years ago - it's easier to get into for a first language (yet it's still a proper language - with real world uses). Though it might be just as good to start in a slightly harder language straight away - I certainly found it hard going from 'beginners or educational' languages to 'proper languages' - the easy ones can cause laziness.83.100.250.79 (talk) 21:25, 26 July 2009 (UTC)
- Most Universities (in US/Canada) seem to start off with Java, as did my high school; it really wasn't too bad as a starting language. As far as visible results go, Robocode is pretty fun. -- Consumed Crustacean (talk) 01:16, 27 July 2009 (UTC)
- I'd like to recommend Robocode as well - it's a good system for learning some prinicples fast. I recommend it to the first years as something for them to practice with. Just keep in mind that Java itself requires a fair bit of theory before you can code anything of value. The language is very nice, but unless you use something like NetBeans the GUI can be complex to learn, and the OO side of things is tricky. Which, of course, is part of why we teach it. :) I normally recommend BlueJ as a first IDE, but that's mostly because of its educational value, so it might not be useful at home. - Bilby (talk) 01:29, 27 July 2009 (UTC)
- Most Universities (in US/Canada) seem to start off with Java, as did my high school; it really wasn't too bad as a starting language. As far as visible results go, Robocode is pretty fun. -- Consumed Crustacean (talk) 01:16, 27 July 2009 (UTC)
- It sounds like Java is a good starting point, are there any other resources available? The one linked above seems to give Vista/IE 7 fits. Thanks again...RxS (talk) 17:05, 26 July 2009 (UTC)
Parallel Port Programming
[edit]I would like to know what a parallel port programming is and how to use it in programming of microcontrollers.i.e.in robotics.Pl suggest some good ebook or website where I can get all the info on this. —Preceding unsigned comment added by Gd iitm (talk • contribs) 16:43, 26 July 2009 (UTC)
- Perhaps this web site can help. 91.32.118.182 (talk) 18:13, 26 July 2009 (UTC)
- See the article Parallel port. But note that manufacturers have stopped providing parallel ports on their PCs. Cuddlyable3 (talk) 21:14, 27 July 2009 (UTC)
Equivalents of pointers and/or dereferencing in scheme ?
[edit]I'm doing things like this:
> (define a 10) :ok > a :10 > (define b '(1 a 2)) :ok > b :(1 a 2) > (cadr b) :a
Basically I can't work how to make the "a" in (1 a 2) act as a variable, and by extension how to control whether it's evaluated, or left as "a" e.g. Are there commands to do stuff like this in scheme? e.g.:
> (define a 10) > (pointer a) ie the command I'm looking for :a > (dereference (cadr '(1 a 2))) the other command I'm looking for :10
?I must be conceptualising the whole language wrong I suspect?83.100.250.79 (talk) 19:31, 26 July 2009 (UTC)
- I think what you're looking for is quasiquote and unquote:
1:=> (define a 10) a 1:=> (define b `(1 ,a 2)) ; equivalent to (define b (quasiquote (1 (unquote a) 2))) b 1:=> b (1 10 2) 1:=> (cadr b) 10
- 24.76.174.152 (talk) 20:10, 26 July 2009 (UTC)
- Nearly (or possibly) - however if I do
> (define a 99) > (define b `a) > b a
- Which is better than before (ie not 99)
- But how do I get
> (func b) 99 and not a
- That step eludes me (I was trying force and delay before as well - with not total success).83.100.250.79 (talk) 20:52, 26 July 2009 (UTC)
- If you write (quote a) then you get a quoted symbol a, which has nothing to do with any variable named a in the environment—it's like the string "a" in other languages. (Modern Scheme also has strings, but earlier versions just had symbols doing double duty.) If you write (quasiquote a) then you get the same thing because quasiquote quotes everything that isn't wrapped in unquote. You could write (quasiquote (unquote a)), but that's the same as just a.
- If you want to update a and have b reflect those changes "on the fly" then that can't be done directly—there's no way to make a data structure incorporate the current contents of a variable by reference. Variables (like a and b) point to objects (like numbers and pairs), and some objects (like pairs) can point to other objects, but objects can't point to variables. This is similar to Java, where you can only have references to heap objects, but different from C++, where you can also have pointers to variables and object fields. But you could write a function that makes the appropriate change to both a and the corresponding part of b explicitly:
(define (change-a! new-value) (set! a new-value) (set-car! (cdr b) new-value))
- -- BenRG (talk) 20:59, 26 July 2009 (UTC)
- Thanks, Yes it's exactly the type of thing you describe in the second paragraph that I'm trying to do (though I read that set-car! is to be 'banished' in v.6 scheme)
- Maybe I'm using the wrong tool - I'm looking for a language with strong support for nested lists (ie like lisp or scheme), but with pointers to objects as well (the easy way) - does such a thing exist?83.100.250.79 (talk) 21:10, 26 July 2009 (UTC)
- But every value in Scheme is already a pointer. (It's like Python.) That's why you can do stuff like this
- -- BenRG (talk) 20:59, 26 July 2009 (UTC)
(define a (car 1 2)) (define b a) (set-car! a 3) (car b) ; evaluates to 3
- --Spoon! (talk) 07:15, 27 July 2009 (UTC)
- As Spoon said, if a refers to a pair and you incorporate a into b, then change the members of the pair, that change will show up in b. But you can't do that with numbers like 10 (they are immutable) and you can't replace the whole pair "in place" with a number or vice versa—you have to do two assignments to the two pointers that reference the pair in that case. People often solve this kind of indirection problem with extra levels of indirection. A common trick in Scheme is to create a pair with a dummy symbol in the car (like '*my-mutable-thing*) and the payload in the cdr. That does require extra indirection when reading, though. Even in C++ you can't indirect via a variable without an extra * when reading.
- ML is a Scheme-like language (it shares the emphasis on lists and recursion) that handles mutation in a cleaner way than most other languages. It avoids all these funny rules about variables versus objects versus parts of objects, but it may not be more convenient in practice if you already understand those rules. You could also look at dataflow programming. In dataflow languages, when a changes, not only does b automatically change but also any other computation whose value depended on a. For example if you had written (define c (+ a 10)) then incrementing a would also increment c. The DrScheme system includes a dataflow extension called FrTime. But hardly anybody uses dataflow languages, so if you need the support and future-proofing that you would get from a mainstream language then you probably can't use dataflow. If you give details on what you're trying to do we could probably give better suggestions. -- BenRG (talk) 09:06, 27 July 2009 (UTC)
- (edit) I'm going to have a look a FrTime, and see what it does83.100.250.79 (talk) 12:03, 27 July 2009 (UTC)
- (edit) It sounds like FrTime does too much - it sounds like it re-evaluates the whole data structure when a field changes - I just want it to evaluate what is necessary for an imperative instruction.83.100.250.79 (talk) 12:08, 27 July 2009 (UTC)
- (edit) I'm going to have a look a FrTime, and see what it does83.100.250.79 (talk) 12:03, 27 July 2009 (UTC)
- Thanks, your description of dataflow programming sounds like what I was thinking about.
- Basically I was just exploring the features of programming languages without any particular application in mind.
- Specifically if a is a variable I would have been incorporating it into many different lists - so the scheme method listed above by BenRG wouldn't really be suitable. - I wouldn't be able to (or expect to) keep track of all the instances of a. So the equivalent of a pointer data type would have been the way to go - However I only needed the data to update on imperative resolution eg not sure if this is the same as 'dataflow'.
- I was also hoping to mix functions and data in a list in a similar fashion - but noticed that if a function returns differently sized or structured lists then this could really mess up the whole thing - requiring functions to be run (with the wrong state information) just to attempt to get the size of the list. eg if a=(0 fn(x) a ) and fn(x) can return 0 or 1 or (0 1 2) or even +{0 1 2}+ ie inserted flat into the list, not nested then I can't find/think of a solution for that as yet. I could probably implement the list with pointers myself though.83.100.250.79 (talk) 11:21, 27 July 2009 (UTC)
- --Spoon! (talk) 07:15, 27 July 2009 (UTC)
- I was just reading what Spoon! said - it looks like I didn't understand the data structure - I was expecting everything to be a pointer (as they say)- the language has to be intrinsically 'pointy' for those lists.
- What I don't get is why Spoon!s example works, but when I just do (define a 10) , (define b a) , (define a 20) ; b gives 10 ie it immediately dereferences b and a, but when using a pair it does something different. Is there an exaplanation for this apart from 'that's the way it was designed' (Isn't 10 a list too, with the second field null?) 83.100.250.79 (talk) 11:31, 27 July 2009 (UTC)
- 10 is not a list. In C++ terms, all variables have type Object*, numbers look like
struct Number : Object { const int value; // or double or complex or ... full numeric tower };
- pairs look like
struct Pair : Object { Object* car; Object* cdr; };
- and the empty list is like the null pointer. So when you write (define a 1) (define b a) (set! a 2) it's like
Object* a = ONE; // where ONE is a global that points to a Number with value 1 Object* b = a; a = TWO;
- which doesn't change b. But when you write (define a '(1 2)) (define b a) (set-car! (cdr a) 3) it's like
Object* a = new Pair(ONE, new Pair(TWO, NULL)); Object* b = a; a->cdr->car = THREE;
- which leaves b->cdr->car also equal to 3. (Note that you shouldn't use define to change the value of an already-defined variable, though it's supported. You should use set! for that.) If I understand you correctly, the problem you're having would also exist in C++. If a is a pointer and you incorporate that pointer into a bunch of data structures, changing a won't change the data structures—you would have to track them all down and update them individually. -- BenRG (talk) 15:53, 27 July 2009 (UTC)
- (First Note: you shouldn't use define on a variable twice in the same scope. Use set! to assign to a defined variable.) set! only changes where a pointer is pointing to. It does not affect the thing that is pointed to. So when you do
(set! a 20)
, it just redirects the pointer to point to another number object. Whether you can modify an object pointed depends on the type of object. There is no mechanism to modify a number object (i.e. they say it is immutable). However, there is a way to modify pair objects, with set-car! and set-cdr!. That's why you can modify a pair object and be able to see the changes through another pointer that points to the same pair object. --Spoon! (talk) 19:49, 27 July 2009 (UTC)
- (First Note: you shouldn't use define on a variable twice in the same scope. Use set! to assign to a defined variable.) set! only changes where a pointer is pointing to. It does not affect the thing that is pointed to. So when you do
Thanks for your responses - I've found something that almost does what I want :
(define a 200) (define b (lambda() a)) (b) result 200 (define a 300) (b) result 300
this always evaluates to the current value of a, which is good, but I have to bracket b to get the number, if anyone can suggest a better way, please, as I'm still working out if I can utilise this method easily.83.100.250.79 (talk) 15:15, 27 July 2009 (UTC)
- I was going to suggest that, but I'm not sure it's really what you want. -- BenRG (talk) 15:53, 27 July 2009 (UTC)
- You shouldn't define something twice. Use
(set! a 300)
. --Spoon! (talk) 19:44, 27 July 2009 (UTC)
Another mystyfying thing about scheme
[edit]As mentioned above I was trying things like (define a 10) , (define b a) , and (cadr (1 a 3)) - now in the first two examples it treats a as a variable, whereas in the third it seems to just think a is "a" ie text. How does it decide? And does ML (mentioned above) or another language (in the family) support a more explicit of distinguishing variables and text?
I know this is very similar to sticking beans up my nose as a hobby , but if anyone end my curiousity I would thank them. :) 83.100.250.79 (talk) 11:47, 27 July 2009 (UTC)
- (cadr (1 a 3)) is an error—it attempts to call the number 1 as a function. You mean (cadr '(1 a 3)). That gives you a quoted a because quote (') quotes everything underneath it in the expression tree. define is a so-called special form (as is quote). It's magical and can't be implemented as a Scheme function. You should read a Scheme tutorial, which will explain all of these things better.
- In ML everything is read-only except for refs. A ref lives on the heap and holds a value that you can get or set. Instead of a mutable variable you use a constant variable that refers to a ref on the heap. This means that every mention of a variable is a mention of its value, not a reference to its location, so you don't need a special form like set!. If you incorporate the variable's value into a data structure then the data structure refers to the same ref and setting it will affect the data structure too. You could get the same effect in Scheme by defining
(define (make-ref val) (cons '*ref* val)) (define ref-get cdr) (define ref-set! set-cdr!)
- and then never using any mutation functions other than ref-set!. -- BenRG (talk) 15:53, 27 July 2009 (UTC)
- Thanks, (yes I missed the ' ) - I think my exectations may have been wrong - I read that scheme/lisp stores program/data in the same form and that a program was a list too - from this I inferred (wrongly) that lists created by the program could contain executable programs as well ('out of the box' so to speak).
- I have been reading scheme tutorials (possibly not very good ones - they didn't explain that '(+ 1 2) destroys all type formatting and renders function names as text)- I suppose the reason they didn't have the answer was that what I was looking for didn't exist - oh well!. So there's not a way to force an evaluation on a list eg
(try-this-list-as-a-program '(+ 1 2) )
83.100.250.79 (talk) 16:29, 27 July 2009 (UTC)
- because + has been convereted forever to a char, and can't be got back into a proceedure type. —Preceding unsigned comment added by 83.100.250.79 (talk) 17:16, 27 July 2009 (UTC)
- There is eval in R5RS Scheme:
(eval '(+ 1 2))
- :-) --Spoon! (talk) 19:37, 27 July 2009 (UTC)
- Cool. (I did try eval on the off chance - but it didn't quite work..)
- I'm using "DrScheme" R5RS and eval doesn't work - gives the curious error message "procedure meval: expects 2 arguments, given 1: (+ 1 2)" (yes it spells eval wrong as well), must be a bug. Curiously in MrEd (same distribution) eval works as planned. Anyone familiar with PLT Scheme and know what's going on? 83.100.250.79 (talk) 20:21, 27 July 2009 (UTC)
- Here's the spec. eval takes two arguments, an expression and an environment. There's no standard way to get the current environment (it would require a special form because of lexical scoping). Supposing a (current-environment) special form exists in your Scheme, (eval 'a (current-environment)) does the same thing as a but is very inefficient. Storing an expression in a data structure and then evaling it does the same thing as putting it in a (lambda () ...) and then calling it, except that it's much slower, less convenient to call, and violates lexical scoping (because it will see the variables at the call point instead of the variables at the definition point). There's no reason to use it. Code and data are not the same in Scheme, they just look alike because they have the same syntax (s-expressions). -- BenRG (talk) 08:58, 28 July 2009 (UTC)
- Yes thanks, I got the feeling it was the same as going through the command line interpreter ie it has to convert what is effectively an ascii string to whatever code scheme uses. I wan't to avoid that.
- I think I'm getting it to do what I want now :eg
- Here's the spec. eval takes two arguments, an expression and an environment. There's no standard way to get the current environment (it would require a special form because of lexical scoping). Supposing a (current-environment) special form exists in your Scheme, (eval 'a (current-environment)) does the same thing as a but is very inefficient. Storing an expression in a data structure and then evaling it does the same thing as putting it in a (lambda () ...) and then calling it, except that it's much slower, less convenient to call, and violates lexical scoping (because it will see the variables at the call point instead of the variables at the definition point). There's no reason to use it. Code and data are not the same in Scheme, they just look alike because they have the same syntax (s-expressions). -- BenRG (talk) 08:58, 28 July 2009 (UTC)
- :-) --Spoon! (talk) 19:37, 27 July 2009 (UTC)
(define a (lambda () '(1 2 3))) (define b (lambda () (cons 4 (cons (a) 6))))
- Which makes the 'a' in function b act like a pointer to the function 'a', and 'b' changes with a. this is the reason I was originally interested - because I got the impression scheme/lisp could do thinks like this easily - thank god it does :)
- I'm just trying to work out the difference between '(4 (a) 6) and (cons 4 (cons (a) '(6) )corrected once - initially I got the impression that the structures created by both were the same ,with (list 1 2 3 etc) just being a shorthand avoiding doing a lot of cons.
Also does anyone know what I type in for 'null' - it rejects null , nil, ()I can't find it in the manual except what seems to be a suggestion that typing "null" should workfound it '() 83.100.250.79 (talk) 10:45, 28 July 2009 (UTC)- I'm glad you found something that works. Writing (define a (lambda () '(1 2 3))) and (a) is slightly different from writing (define a '(1 2 3)) and a because the former conses together a new list every time you call it, which matters if you use set-cdr! and the like—but maybe you don't need those any more. Everything in '(4 (a) 6) is quoted, including the (a), whereas in (cons 4 (cons (a) '(6))) the (a) is unquoted so it's a function call. The 4 is also unquoted but it doesn't matter because it evaluates to itself. -- BenRG (talk) 22:41, 28 July 2009 (UTC)
![](http://upload.wikimedia.org/wikipedia/en/thumb/f/fb/Yes_check.svg/20px-Yes_check.svg.png)
OK thanks for your help , and your patience. I think I can call this resolved, the engine starts, and I've stopped putting sand in the tank unless somebody notices that I'm doing things the wrong way, or knows a more sophisticated solution.. In which case please say. Thanks again.
- This isn't so much an answer as a further question, but nonetheless: does Scheme really not have
symbol-value
or any equivalent? I guess that it sort of makes sense, since it has only lexical scoping and no use ofa
appears lexically in(symbol-value 'a)
. But ifeval
exists (even if it's crippled by the lack of a standardcurrent-environment
special form), it seems silly not to also provide this simplest part of what it does (resolve symbols into variables). --Tardis (talk) 21:49, 28 July 2009 (UTC)- Scheme symbols (unlike Common Lisp symbols) don't have values. They're just like C identifiers. All variable references are lexical and hence are supposed to be unaffected by alpha renaming. You could write a value-at-top-level that used eval, but it would be a weird thing to standardize because it's not something you really want to encourage. Lexical scoping and eval interact badly. Aside from the theoretical issue (alpha renaming), you have to maintain a bunch of metadata at runtime that wouldn't otherwise be necessary and you have to inhibit various compiler optimizations because you can't predict at compile time what variables will be read or written by the eval. It's basically the same problem as doing it in C. I'm somewhat surprised they included eval at all. -- BenRG (talk) 22:41, 28 July 2009 (UTC)
How can I extract individual images from video-slideshow?
[edit]I have a video-slideshow created by Photo Story 3 using the Windows Media Video 9.1 Image v2 codec. How can I extract the static images from this file? --Me (talk) 20:01, 26 July 2009 (UTC)
- Perhaps the Gom player could do it. 78.144.197.8 (talk) 17:00, 30 July 2009 (UTC)
Elevator logic control
[edit]Hi there, I'm in the process of creating an app/game/sim/whatever you want to call it that emulates a lift (elevator). I've got the thing working pretty well but am stumped at getting the logic right for handling calls. (Originally asked this on the science desk but this is probably a better place to ask it.)
At the moment, there are two objects: DRUp and DRDown that both contain a variable which can be set to 0 or 1 (0=off, 1=on), this simulates a pair of switches that control the direction. The lift operates a 'mechanical' floor selector (a moving object that triggers events when it touches other objects) that makes contact with various switches to tell the lift where abouts in the shaft it is. When the top floor and bottom floor switches are triggered, it toggles the direction switches so if it's at the top floor then DRUp=0 and DRDown=1, because the lift cannot go up from the top floor! The ground floor switch does the opposite.
This works fine for going in the same direction, however if the lift car is on the ground floor and I am on the second floor and want to go to the ground floor, the lift goes all the way to the top, reverses direction and then stops at the second floor. I need a way of resetting the direction switches from other floors but ONLY if there are no further calls in the original direction.
Example: Lift on ground floor Call from 2nd floor Lift goes UP to second floor Are there any more calls going UP? If yes, continue up, if no, reverse direction.
I can probably do it a long-winded way by setting up a long and protracted if statement along the lines of:
If Floor=1 and LR2Up and LR3Up and CR2 and CR3 and CR4 = 0 then DRUp=0 and DRDown=1 (LR being landing call switches and CR being lift car call switches)
However I'm sure there must be a simpler way of doing it (probably something to do with the floor selector). I can't see how old-fashioned lifts with relay logic could evaluate complex if statements. I think from looking at old and very complex documents about electromechanical lift controllers, the floor selector has three parts on top of each other that tell it which way to go but not sure).
Anyway, if you're interested, I've put the project so far online: http://www.arthurflowers.co.uk/games/Lift2_1.exe , any comments would be good.
Thanks in advance for any information. GaryReggae (talk) 21:44, 26 July 2009 (UTC) —Preceding unsigned comment added by GaryReggae (talk • contribs)
- May I suggest that you re-ask this question on the computing ref desk - you'll get a much better answer there. SteveBaker (talk) 21:55, 26 July 2009 (UTC)
- It was not clear to me whether your lift has a single call button at each floor, or two buttons for a user to call to go up or down. There may be security problems about your link to an executable. Consider showing pseudocode instead. Cuddlyable3 (talk) 22:20, 26 July 2009 (UTC)
- Thanks - I have posted this on the Computing desk too. I only posted it here in the hope that somebody that knows about electronics and engineering might know how these things work in the real world. I have been looking on Google patents about old lift controllers and it seems that the floor selector has three parts that control the direction but it's all incredibly technical and goes into too much detail.
- The lift has two buttons on each floor, each one activates either an up call request switch (LRUp or a down call request switch (LRDown). Buttons pressed in the lift car itself activate a third switch for each floor (CR). At the moment, the lift will answer all the calls going down then all the calls going up but as I said, the lift currently travels to the top and bottom floors to change direction, so if I were to only want to go between two of the middle floors, I would have to go all the way and then back.
- I don't know how to do pseudocode but I will try blockquoting the link:
http://www.arthurflowers.co.uk/games/Lift2_1.exe
- There are many articles that contain examples of pseudocode. Loading executables from the Internet is forbidden in many computer environments e.g. school networks, because of the potential for virus attack. Cuddlyable3 (talk) 22:58, 26 July 2009 (UTC)
- --- end of answers from Science Desk ---
- minor point (Did you realise that by directly linking to the file you have allowed users to circumvent your draconian user aggreement? eg http://www.arthurflowers.co.uk/ ?) —Preceding unsigned comment added by 83.100.250.79 (talk) 22:55, 26 July 2009 (UTC)
- What language? (may help in the answers)
- Another thing I have to ask is "can there be multiple people requesting the lift" - it's a lot simple if only one person uses the lift at once.
- Basically don't you need two variables "LiftFloorRequest" and "LiftFloorRequestDestination" - first the lift goes to "LiftFloorRequest", then it can contine (or change direction) to go to "LiftFloorRequestDestination". You could add an additional flag for "LiftMode" - which would be either "seeking customer" or "delivering customer" which might help keep things clear.
- (If more than one person is using the lift then I think real world practice is for the lift to go up to the highest request, and down to the lowest request - ie when more than one button is pressed the lift reverts to the mode you already have - ie straight up and then down.)
- Also it's probably more use if you can link to the program code, rather than the program - otherwise we won't really know how you are doing it.)83.100.250.79 (talk) 22:36, 26 July 2009 (UTC)
- In terms of the actual electrics, rather than a simulation - I'd guess that there would have to be a wire for each level if you want to go to the highest selected level rather than the top - though it's possible to do it with only a couple of wires. I'm no lift expert - it's not clear if you're trying to simulated the original mechanism or just making an lift program that works.
- (Actually I think I can describe a very simple relay circuit for what you are describing - which would convert into two program variables - the self explanatory "HighestButtonPressed", and "LowestButtonPressed" - it's probably clear from those words that all you need to do is work out the two values, and let the lift oscillate between the two. (I imagine there are many implementations)83.100.250.79 (talk) 22:42, 26 July 2009 (UTC)
- Yeah, I'm trying to simulate the original mechanism as far as is possible. There is only one person calling the lift at any time. I can't put the code in as I have built this thing using 'GameMaker', a GUI that allows you to create games. You can use variables, as indeed I have but each 'object' has its own set of 'events', such as MouseClick and Step (runs the same procedure constantly). I have an object that controls the motion of the lift car - if there are no calls then it exits the event, if there are calls then it moves the lift car in whichever direction is specified by the direction switches DRUp and DRDown. The DR switches are toggled when the 'mechanical' floor selector touches the ground or top floor switches.
- Here is a screenshot: http://img188.imageshack.us/i/atflift2.jpg/
- With regard to the draconian user agreement, yeah, I put it there out of sarcasm after I got in trouble at work for posting technical stuff on that website but it was nothing to do with them really.
GaryReggae (talk) 22:56, 26 July 2009 (UTC)
- This doesn't address your specific issue, but you might be interested in looking at SimTower. This game evolved from an earlier elevator simulator and ended up being fairly commercially successful. Nimur (talk) 23:04, 26 July 2009 (UTC)
- I'm not sure that I can help you much more, but I think I can explain how the relays simulate the logic if you need that (you mentioned above that you didn't see the connection) - if there are two wires coming from the top, one 'power', and one 'signal' - then pressing the button on a floor will connect power to signal by activating a relay. By doing this power is routed to the signal wire (going down) - thus the power wire below this floor is now not connected... The relays on each floor have to be set up so that the signal cannot go upwards at the point were power is routed to signal. (probably a double throw relay) this has 3 effects:
- thus the signal wire is only live below the highest floor on which a button has been pressed.
- power wire is disconnected on floors below. (therefor pressing the button does nothing)
- pressing a button higher up still works
- I'm not sure that I can help you much more, but I think I can explain how the relays simulate the logic if you need that (you mentioned above that you didn't see the connection) - if there are two wires coming from the top, one 'power', and one 'signal' - then pressing the button on a floor will connect power to signal by activating a relay. By doing this power is routed to the signal wire (going down) - thus the power wire below this floor is now not connected... The relays on each floor have to be set up so that the signal cannot go upwards at the point were power is routed to signal. (probably a double throw relay) this has 3 effects:
(If the power is off then the switching relays need to reset themselves.)
- Combine this with the same mechanism going upwards instead of downwards (another 2 wires plus 'ground')
- The lift only runs where both the signal wires are live - additionally losing one of the signal wire connection means the lift needs to change direction - this can be acchieved with relays too. ie connect the two signal wire feeds to another relay - if one is absent the relay will switch (in one of 2 directiosn)- which in turn can be used to switch the motor power.
- Obviously getting the lift to stop exactly at the floor makes this more difficult.
- I think it would be quite possible to emulated this in your program if you haven't already - ie you could have close up images of the relays switching, or mabybe even colour the wires where they are live.83.100.250.79 (talk) 23:21, 26 July 2009 (UTC)
- By the way I think the technical term is Interlocking - but all that article is about trains and not lifts - though a lot of the principles are the same.83.100.250.79 (talk) 23:24, 26 July 2009 (UTC)
Elevator Logic The number of floors in the building is Nf. The following are independent on/off states. Each could be a latching relay (relay controller), a set/reset latch (logic controller with MSI chips or FPGA), or one-bit flags in memory (µP controller). - For each floor i = [1...Nf] there are 3 state bits: Cdi = Call to descend Cai = Call to ascend Di = Directed to floor Cdi and Cai are set by pushbutton call switches at each floor. Cdi and Cai illuminate their respective call button so the caller gets immediate confirmation. Di are set by pushbuttons inside the elevator and illuminate their respective buttons so riders get immediate confirmation. - For the elevator there are state bits: Kdi = Commit to descend from floor #i Kai = Commit to ascend from floor #i (Kdi AND Cdi) and (Kai AND Cai) are AND functions that illuminate arrows at the respective elevator doors. These give further confirmation to a caller that s/he will soon be served, and they show which of Cdi/Cai will be answered first when both call buttons have been pressed. A "ping" sound is given at the floor when either arrow lights. The elevator logic monitors the location of the elevator f = [1...Nf]. This can be done in various ways such as by a rotary optical encoder in the lifting gear, or interlocking microswitches at each floor. It could be done using a momentary contact switch at each floor thus: as the elevator touches each switch the controller increments or decrements a floor counter, depending on whether the elevator is ascending or descending. Floor #1 has an extra contact switch that keeps the floor counter synchronised to the actual floor numbers. Number f is displayed to riders inside the elevator. Initialisation at switch on and after a power break: All (5 x Nf) - 2* state bits reset. Bring elevator to f = 1 (ground floor) to synchronise floor counter. Self test routine (in µP) may include testing all lamps. The elevator logic executes the following. ----------------------------------------- SCAN UP CALLS Pa = 0 pending ascend flag for i = f to Nf Kai = Cai OR Di if Kai=1 and Pa=0 then fd = i destination floor Pa = 1 next i if Pa=0 goto SCAN DOWN CALLS while f<fd raise elevator (At floor fd) Open doors, Caf = 0, Kaf = 0, Df = 0 (After delay 5 seconds) Close doors. If door is blocked, open and repeat. goto SCAN UP CALLS SCAN DOWN CALLS Pd = 0 pending descend flag for i = f to 1 step -1 Kdi = Cdi OR Di if Kdi=1 and Pd=0 then fd = i destination floor Pd = 1 next i if Pd=0 goto SCAN UP CALLS while f>fd raise elevator (At floor fd) Open doors, Caf = 0, Kaf = 0, Df = 0 (After delay 5 seconds) Close doors. If door is blocked, open and repeat. goto SCAN DOWN CALLS ----------------------------------------- Notes on this simple elevator implementation: 1. When no one uses the elevator the controller alternates between SCAN UP CALLS and SCAN DOWN CALLS. That is innocous for a µP controller but would be unwelcome activity in a relay controller. 2. Calls are not served well while the elevator is in motion. It is possible for the elevator to proceed past a floor if a call to that floor was made after the elevator starts. That will distress a rider who changes their mind during travel. 3. No provision was made for soft acceleration/deceleration so the elevator speed is limited. Possible improvements which are more suitable for tall buildings: Re. 1. When Pa = Pd = 0 the elevator could be sent to an optimum rest floor, such as ground floor or a mid floor. Re. 2. Response to rider controls could be improved by scanning Di's more often than only when the elevator stops. Re. 3. Higher speed without abrupt starts/stops is possible if full speed/stop is reached only after travelling one floor. However for that strategy one cannot respond while the elevator is in motion to a new Di (in 2. above) nor commit to a new Cdi/Cai where i is closer than f +/- 1. Travel from a floor to an adjacent floor can only reach half the maximum speed. Overload, Fast Mode The elevator car should have a load sensor. - EXCESS load causes the doors to stay open, prevents elevator movement and (preferably) shows a warning to occupants. The following improvements to load sensing are possible. - FULL load corresponds to maximum number of adult occupants. Ignore floor calls and obey only occupant directions Di. This avoids serving floor calls with a full elevator that the caller cannot enter. - EMPTY load corresponds to less than the weight of a child. Move elevator at maximum speed with abrupt start and stop. *On floor #1 there is no Cd1 button nor down arrow. On floor Nf there is no CaNf button nor up arrow.