

InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
151. |
Solve : Applet? |
Answer» I am creating an Applet using java. The applet is supposed to get user input to make a rectangle. The user will enter in the height and width, and then click the draw BUTTON to have the rectangle drawn. My code compiles and runs fine, but I am just having some problems with some of the minor details. I am supposed to restrict the maximum and MINIMUM SIZE of the applet such that the user cannot enter a negative number or zero for the min, and limit the max so that the rectangle will be properly displayed in the applet. I'm thinking that this part would be IF statements, but I'm just unsure of how to goabouts in writing the IF statement. Also, I would like to have an image set as my background, but I just can't seem to get it to work right. Here is my code |
|
152. |
Solve : Boolean Operators? |
Answer» I was helping a friend with a Python assignment and in their code I noticed something along the lines of this: |
|
153. |
Solve : VBS - how to send windows key?? |
Answer» Hey does anyone know how to send windows key using VBS? |
|
154. |
Solve : C++ Windows Form Application? |
Answer» I am creating a Windows Form Application in Visual C++ 2011 Express and have run into a problem. |
|
155. |
Solve : c++ create a web browser? |
Answer» Hey Guys, ...Using their work, you can make an outline and project time line for yourself. Would it make a difference you to know AHEAD of time the project will take you six weeks working n10 hours a day six days a week? Of course you would look at http://www.mozilla.org/ and I suppose you already did that but had not heard of webkit. Have Fun |
|
156. |
Solve : VBScript adding TCP/IP port registry help? |
Answer» Hello all, |
|
157. |
Solve : Excel - need to sync two sheets into one master & be able to add rows? |
Answer» Hi there Hope, Yes, Access can import from Excel. Your LPs sheet and 7" SINGLES sheet would each become a "table" in Access. Then, you could create another table, Query, or Report. The third table, or the Query or Report form would pull the data from the main two tables. Therefore, any updating of the two main tables flows into the other table or the Query form or Report form. Haha! Yes, I have it saved to a flashdrive, regularly send the latest update to myself and save it on my work HD (plus it's then there in my Gmail) and save it to the cloud... Wow! Such useful information Soybean, thank you so very much. I have 5 days off work coming up and will tackle the situation then - but you have given me incredible hope! And, I think the budget can be stretched to allow a $4 outlay... Greatly appreciated, Snaps |
|
158. |
Solve : quick pdf viewer? |
Answer» Hi, |
|
159. |
Solve : html with JS accessing PHP Help required? |
Answer» Hey folks, document.formOne.quantity.value==""This will not reference the form variable you intend. Give the quantity input an id tag like this: Code: [Select]<input name ="quantity" id="quantity" type ="text" value="" /> You can then reference it like this: Code: [Select]var quantity = document.getElementById ('quantity'); if(quantity.value=="") { ... Remember to "return false;" to ensure the form is not submitted. Your onsubmit needs to be TWEAKED too (see >this tutorial< and follow it more closely.) And this is not valid javascript at all: Code: [Select]action ="my shop process.php" method="POST"; You don't need it, because the form will submit, unless the validation returns false. FWIW, I wouldn't do it this way, except for very very small projects. You might want to investigate one of the techniques referred to >here<. Don't forget your server-side validation. Javascript validation is no protection against deliberate abuse.Cool, will give this ago and let you know the outcome. Thanks for the post I'm doing this for college. So thanks again it's appreciated. Cheers, B2Hey there, Sorry took me a while to get back to you peeps on this. Just want to say thanks for the help and pointers!! I've got only got small prob now. My validation works... but it's not coming up in an alert box. It's taking it from the IF statement in the php file. I was told to put an IF statement in there for IF statements sake I think lol... anyway I'm not sure why my alert in the function validation() is not coming up. If you can see anything I've missed I'd or can't see anything wrong with it could someone let me know. It's driving me nuts lol source code below Cheers, B2 <html> <head> <title>Chocolate Shop on page 54</title> <script type ="text/JavaScript"> function validate() { If(document.OnlyForm.item.value=="" || document.OnlyForm.quantity.value=="") { alert("You need to fill in a quantity number"); return false; } else { parent.location="my shop process.php"; } } </script> </head> <body> <h4>Chocolate Shop Order Form</h4> <form name="OnlyForm" action="my shop process.php" method="post" onsubmit="validate()"> <select name = "item"> <option> </option> <option>Real Life sized T-Rex model</option> <option>Space Station</option> <option>A Cape with matching Mask</option> <option>A Plot of land on the Moon</option> <option>A Space Shuttle</option> <option>One Launch spot from Kennedy Space <option>A real dead vampire</option> <option>A revolution</option> <option>Aid Food Packages</option> <option>Plutonium</option> <option>Real 3D Glasses</option> </select> quantity: <input name ="quantity" type ="text"> <input type ="submit" value="Submit This" onclick="validate()"> </form> </body> </html>There is a "web design" forum. Anyway, you still don't appear to be doing what Rob suggested, as in giving the field an ID and use document.getElememtById() to get its value. Also, we can't see the PHP file you're using so can't really help. Quote from: kpac on October 15, 2011, 10:54:14 AM There is a "web design" forum. Hi there kpac, I've added in what Rob suggested and it still doesn't work (could be the way I've added it in though). I've put the php file on at the bottom of the bold source code. Sorry for posting in the wrong spot. You want to move it to the other forum? I'm not sure if I can or if I even have the privilege to do that. Cheers, B2 <html> <head> <title>Chocolate Shop on page 54</title> <script type ="text/JavaScript"> function validate() var quantity = document.getElementById ("quantity"); var quantity = document.getElementById ("item"); { if(item.value=="" || quantity.value=="") { alert("You need to fill in a quantity number") return false; } else { parent.location="my shop process.php"; } } </script> </head> <body> <h4>Chocolate Shop Order Form</h4> <form name="OnlyForm" action="my shop process.php" method="post" onsubmit="validate()"> <select name = "item" id="item"> <option> </option> <option>Real Life sized T-Rex model</option> <option>Space Station</option> <option>A Cape with matching Mask</option> <option>A Plot of land on the Moon</option> <option>A Space Shuttle</option> <option>One Launch spot from Kennedy Space <option>A real dead vampire</option> <option>A revolution</option> <option>Aid Food Packages</option> <option>Plutonium</option> <option>Real 3D Glasses</option> </select> quantity: <input name="quantity" id="quantity" type="text"> <input type ="submit" value="Submit This" onclick="validate()"> </form> </body> </html> My Shop Process $item = $_POST['item']; $quantity = $_POST['quantity']; If($item =="" || $quantity =="") { echo("You need to fill in all the boxes"); } else { echo "You ordered ". $quantity . " " . $item . ". "; echo "Thank you for ordering from Imaginery!"; } ?> Okay... This is your javascript... Code: [Select]<script type ="text/JavaScript"> function validate() var quantity = document.getElementById ("quantity"); var quantity = document.getElementById ("item"); { if(item.value=="" || quantity.value=="") { alert("You need to fill in a quantity number") return false; } else { parent.location="my shop process.php"; } } </script> Well, you declared the variable quantity twice. If you want the variable quantity to be assigned to the element with ID "quantity", then it can't be assigned to the element with ID "item" as well. You were also missing the opening parentheses of the function. Code: [Select]<script type ="text/JavaScript"> function validate() { var quantity = document.getElementById("quantity"); var item = document.getElementById("item"); if(quantity.value== "" || item.value == "") { alert("You need to fill in a quantity number.") return false; } else { window.location="my shop process.php"; } } </script> Just a suggestion, it's not the best IDEA to have filenames with blank spaces, i.e. "my shop process.php". It's better to use an underscore or hyphen to separate words like so: "my-shop-process.php" or "my_shop_process.php". As regards the PHP file, a rule of thumb is to make sure every variable you $_GET or $_POST from another page is filtered properly. Also, try using the empty function to check if a variable has any value. Code: [Select]<?php $item = strip_tags($_POST['item']); $quantity = strip_tags($_POST['quantity']); if(empty($item) || empty($quantity)) { echo("You need to fill in all the boxes"); } else { echo "You ordered ". $quantity . " " . $item . "."; echo "Thank you for ordering from Imaginery!"; } ?> One final thing, if you're posting code please use the Code: [Select][code] ...bbc tag. It's much easier to READ. Hey kpac, When I leave all fields blank the alert from the JS in the html file is working... however, the alert is coming up twice then it displays the php echo. Is there a way to just have the alert run once and then stop on the same page (the html one) so the user can fill in the details? I also tried to add a hyperlink on the php file outside of the php code and it doesn't show up on the page at all. Is there a way to do it like below. I renamed my pages with - between the words Code: [Select]<?php $item = strip_tags($_POST['item']); $quantity = strip_tags($_POST['quantity']); if(empty($item) || empty($quantity)) { echo("You need to fill in all the boxes"[b]A hyperlink in here somewhere???[/b]); } else { echo "You ordered ". $quantity . " " . $item . "."; echo "Thank you for ordering from Imaginery!"; } ?> <a href="my-shop-validation.html">click to go back</a>Instead of Code: [Select]<input type ="submit" value="Submit This" onclick="validate()"> use Code: [Select]<input type="submit" value="Submit This" onclick="validate(); return false;" /> Watch out for spurious spaces in the middle of your HTML attribute declarations (type ="submit"). Quote from: Rob Pomeroy on October 18, 2011, 06:04:05 AM Instead of Hi folks, Just to say that this would have worked but I overlooked one little thing.... Code: [Select]{ If(document.OnlyForm.item.value=="" || document.OnlyForm.amount.value=="") { alert("You need to fill in a quantity number"); return false; } Yup and everyone else overlooked it too lolz I had a capital "I" for if in my if statement lolz. Rob - what you posted works as well by the way. I tried it... after I replaced my "I" with an "i" lolz Issue resolved !! Cheers for the time you all took having a look at my code, much appreciated !! B2 Excellent. Thanks for the feedback. |
|
160. |
Solve : C++ STL Map? |
Answer» My objective to is CREATE a phone book that will receive a name, category, phone number, and address from the user. after the user enters their info, I would like their data to be saved. My code compiles, but i am having problems with some parts of my program. my find, report, and test functions do not work. The find function is suppose to search for a name in the phone book. for example, the user can enter in info for 3 people, and wants to find the info for one of the people entered by the user. the report function is to display all of the people entered into the phone book. the test function is supposed to generate 10 random people, that have a random name, category, phone number, and address, and display them on the screen. Also, my add function does not seem to work properly either. It just does not seem to be saving any new people the user adds to the phone book. I will include all of my files. There will be 9 files altogether. |
|
161. |
Solve : copying something to my website - help pls.? |
Answer» I want to copy the search feature found here..... Unless you own both websites, this would be considered poor etiquette.And illegal, in some cases - depending on how it was done it could be considered plagerism. |
|
162. |
Solve : Engine: Word input - Excel processing - pdf output? |
Answer» Hi |
|
163. |
Solve : Nonmember functions vs. member functions.? |
Answer» I am having trouble understanding why a prefix is USED and not used in these coding. The first code will be for a non member function, and the next will be for the member function. There is a prefix that is used in the Member Function code, but not in the NonMember Function code. The prefix that is used in the Member Function code is "Bank_Acct::" This is found in the header of the operator<< function. But this header of the operator<< function in the NonMember Function is not used. I'm trying to figure out why, but I can't seem to figure it out. Also, in the NonMember Function, I am having trouble figuring out the purpose of the Print function. it's nothing along the lines of compiler issues. its just a question. the question is howcome in the member function, there is the "Bank_Acct::" prefixed in front of the header of the operator<< function, but there is none is non-member function? Probably because the member function version doesn't use << on the Bank_Acct type and thus doesn't need one defined. it uses print() instead.ok, yea that makes SENSE. thanks. do u think you can help me out with my other post. not sure if you took a look at it. it's titled C++ STL map. |
|
164. |
Solve : JScript Popup Boxes? |
Answer» I have searched and asked this question at multiple sites and can't seem to FIND an answer: |
|
165. |
Solve : Simple example in Python? |
Answer» Hi! |
|
166. |
Solve : [Java]HashTable and HashMap? |
Answer» What are the differences between these two? All About Hash But this is more like what you want http://en.wikipedia.org/wiki/Hash_table There are references to Java. http://download.oracle.com/javase/6/docs/api/java/util/HashMap.html http://blog.griddynamics.com/2011/03/ultimate-sets-and-maps-for-java-part-i.html http://www.lampos.net/sort-hashmap Well I've read the Javadocs on both tables and maps and was just hoping I COULD get a summary of advantages between the two. But I guess I'll just have to read some more or dig up these endless arguments you speak of Have fun. They do not make a clear distention between tables and maps. The most important feature is the hash generator, or hash function. A table or map, in a simple form, can be just an array of pointers. With the large amount of memory how available in modern computers, size of the array is less of any issue. The point is that optimization the table of map is less important than having a good OVERALL scheme. Especially the Hash maker. For more tips on Java and hash, go to the website http://stackoverflow.com/ and find general discussion and specific issues with Java hash. Hashtable is synchronized on the table, HashMap isn't; you would have to add it yourself using a wrapper class. (or you could probably use the java.util.concurrent.ConcurrentHashMap to get a similar effect). Also, the iterator of the HashMap used in for loops is fail-safe, while the enumerator for the Hastable is not. if you change hashMap while iterating, you'll know; that is, that item will be iterated. if you iterate on a hashTable and add values while iterating, you won't see the new values unless you restart the iterator. Lastly, HashMap permits null values, while Hashtable doesn't. The actual objects being represented are exactly the same, they just have different names. Hashtable is one of the first classes ADDED to java's collections. Also, it was added before the introduction of generics and as such HashMap should be heavily favoured. (Hashtable extends from Dictionary, which itself is deprecated, also). The "distinction" is hard to find, because there quite literally is no distinction, at least data-structure wise. They represent the exact same data structure; hashMap just takes advantage of new language features, such as generics, to support strong typing of it's key's and values, whereas hashtable does not; it (hashMap) also better supports the use of strongly-typed iterators by virtue of generics iterators (such as those used with a FOREACH loop of the style for(value:collection){statements...}). |
|
167. |
Solve : Visual Basic problem? |
Answer» Hi, I'm using visual BASIC with .net framework 4, and I made a program that gets the strings from a table in a database and shows them in a listbox, the listbox shows the elements correctly, but when i try to set a variable with the index string (Label1.Text = listbox1.selecteditem() ) I get System.Data.DataRow or something like that, i want to get the string. Can someone help me? Label1.Text = ListBox1.SelectedItem().ToString() not working You'll need to get the field from the DataRow, then. Code: [SELECT]ListBox1.SelectedItem("fieldname").ToString()It works fine, thank you for helping me. Solved. |
|
168. |
Solve : Computer Logics and Digital Design: Operational Pair Grading System? |
Answer» Objectives |
|
169. |
Solve : bat file to search cmd window? |
Answer» Hello, |
|
170. |
Solve : GNU make dual-core Compilation Optimization? |
Answer» This may be a stupid question (and hopefully it's in the right section, since I associate make and compiling primarily with PROGRAMMING), but does anyone know what would be the best WAY to optimize the make process using "make -j #"? |
|
171. |
Solve : VB hide toolbar and move page accordingly? |
Answer» Hey Guys, |
|
172. |
Solve : CREATE A REGISTRY KEY WITH A BATCH FILE?? |
Answer» Hey, I was wondering how, or even if, you can make a subkey in the HKCR registry section with a batch FILE. |
|
173. |
Solve : bat file auto capture and webcam? |
Answer» hi all, first of all im just a beginner programmer, Maybe I can help. thanks for ur reply, but im looking for batch program, or any line, coz im working on my NEW project. THATS why i need that batch program. =) any idea? =)OK Yes, there are programs that work in DOS. Some of this are automatic. They make full-screen capture in DOS. http://www.screencapture.com/answers.htm Quote from: Geek-9pm on February 17, 2011, 09:51:43 PM OK thanks, but im looking for batch program, so any other answer? =)You could write your own CLI program to capture the screen and web cam. I have written a short tutorial on how to capture screen with Delphi codes. Unfortunately atm I have problem with my internet connection. I can not reach the page. Maybe later, if you are interested. Quote from: Luthfi on February 21, 2011, 02:51:27 AM You could write your own CLI program to capture the screen and web cam. I have written a short tutorial on how to capture screen with Delphi codes. Unfortunately atm I have problem with my internet connection. I can not reach the page. Maybe later, if you are interested. yeah, i am very interested, cant wait it! thanks man! i'll wait. =)Okay, here is the url to the tutorial: http://forum.codecall.net/pascal-delphi-tutorials/34552-how-capture-screen-delphi-code.htmlthx, but is there any other answer? maybe in c#? or in sh? or in pl? or in bat? =)If you're looking for a really simple command line app to capture a single snapshot from a webcam in Windows, you might be interested in the following post on my blog: http://batchloaf.wordpress.com/2011/04/06/snapz-a-command-line-cam-image-grabber/ I couldn't find an app to snap webcam images in a batch file, so I wrote this myself. It's very basic - just run it and it snaps a 640x480 image from the default camera device and saves it in the current directory. It should be perfect for including in a batch file. It's free to download and the full source code is included in my blog post. If you really need to capture an image at a different resolution, the program would need to be recompiled to do that (it's compiled using MinGW - a free gcc compiler for Windows). Hope that helps you with your problem! Quote from: batchloaf on April 07, 2011, 03:49:50 PM If you're looking for a really simple command line app to capture a single snapshot from a webcam in Windows, you might be interested in the following post on my blog: NICE coding man, this is what im looking for dude! btw, need ur little help again, do u mind if i add u on msn or ym? leave ur email or add me at [email protected] or [email protected] thanks batchloaf!Since a few people found their way from here to the snapz command line image grabber program on my blog, I'm POSTING a link here to the updated DirectShow version that I've just written, CommandCam. It's free and open source and it can be downloaded (either source or binary) from my blog or from github.Updated link for CommandCam command line image grabber: http://batchloaf.wordpress.com/commandcam/Am I the only1 curious about the program op is making? |
|
174. |
Solve : Basic C++ Quiz Help.? |
Answer» Hey guys, I was wondering, would it be an OK beginner project to try and make a little 3 question quiz out of C++. I'm moving up from Batch/crap-tons of markup and web scripting languages (HTML, JAVASCRIPT, PHP, VBScript, CSS, mySQL) and I was just wondering if that would be a good first program? Other than hello world of course :3.quiz would be an ok way of getting better with if & else statements but considering that you have already had experience with other languages im betting you already have that mastered, the only thing you'll learn by doing a quiz is more syntax. |
|
175. |
Solve : which is the best programming software to write a simple copy and paste program? |
Answer» Hi all, |
|
176. |
Solve : Writing an XML code beautifier? |
Answer» Here's the IDEA.... |
|
177. |
Solve : .vbs script help? |
Answer» So I need a script to disable the shutdown button on my laptop. Well I know it's possible to do in .vbs but I GOT no idea how to start. Just some start help would be MUCH obliged. Why don't you just disable it in Power Options? Why do you want to do this? Are you SURE it's your laptop you want to do this on? Just to be sure that we are on the same page the button I am talking about is the physical one on the exterior of the laptop. I know what page I am on. In Windows 7/Vista there is an option in Control Panel Power Options - "Choose what the power BUTTONS do" - in XP it's in the Advanced tab - "When I press the power button:" the powercfg utility MIGHT provide the functionality you seek.Okay Sry Salmon I completely misunderstood It's working now thank you. |
|
178. |
Solve : C++ if - else? |
Answer» I am trying to make this program work and it is not printing - COINS PER DOLLAR CALCULATION will not print. Help, Please. |
|
179. |
Solve : Need proper syntax for getevn (or set/environ)? |
Answer» trying to get this to print the environment variable "PATH" I just changed getenv to environ and it worked fine.1. Does the PATH environment string actually have a value? Sometimes people fool around and nuke it. 2. What does this code do? Code: [Select]#include "crt/stdlib.bi" Sub main() Print "Homedrive: " & environ("HOMEDRIVE") Print "OS: " & environ("OS") Print "PROMPT: " & environ("PROMPT") End Sub main() You should see something like this Code: [Select]Homedrive: C: OS: Windows_NT PROMPT: $p$g 3. If the lib was not found you would get an ERROR message from the compiler and no exe would be produced. Try changing stlib to stdlibb and see what happens! 4. Are you actually looking at the compiler output? No, i was using FEdit and had inadvertently chosen Windows GUI instead of Windows Console, all is good now. So SalmonTrout, i am now gettig the correct path. many thanks for your astutness Quote from: Salmon Trout on December 14, 2011, 12:08:14 PM 4. Are you actually looking at the compiler output?so after some more tweaking, i have things sort of being ported over to the new lang.. again im primarily setting and displaying environment variables. ONE thing that i have not figured out is this: #include "crt/stdlib.bi" Dim return1 As String, testdir As String return1 = Environ("return") testdir = Environ("%cd%") Print "return is "; return1 Print "testdir is "; testdir return1 is valid and prints out the value testdir prints out the statement and no value, so somehow the percent signs seem to give the environ command an issue how can i pass the %cd% to the environ function, i have tried quoting, single quoting, with and without %, nothing has worked so far. any thoughts Not sure if you need to use th curdir or exepath commands. Not exactly sure which path you are looking for.curdir is the winner.... and the answer is... so some more issues with this not working as expected, so i need to learn more... here is what i currently have in the FEDIT console window: #include "crt/stdlib.bi" Dim return1 As String, currdir As String, newpath As String return1 = Environ("return") 'display the current value of return currdir = curdir 'set the current directory to currdir Print "return is "; return1 'print the current value of return1 (not slot) Print "current dir is "; currdir 'print the current working directory newpath="return=" + currdir 'make new path string for setenviron SetEnviron newpath 'setenviron to newpath Print Environ("return") 'print the new value of "return" during runtime, this does exactly what it is supposed to do, set the envvar "return" to the curdir. and it prints out exactly what it is supposed to say, which is the folder where im compiling the program at. all is good to this point. however once it exits the program, the value for "return" is nil or not set. thoughts?The Environment Block of a process is a copy of the environment block of the parent process, or a new, default Environment Block (depending how you spawn the child process). In this case, the Environment Block your FreeBasic Application receives is a copy of the Environment Block as it exists in the spawning CMD console. However, because of this, changes will not persist back to the parent processes environment. With Older MS-DOS programs this wasn't an issue since... it didn't exist. The concept of multiple processes was a foreign one, and there really was only one environment block for each command interpreter that was globally accessible to any applications run within. Instead you have to write a value to the registry. (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment). This does that (can be confirmed be via RegEdit) but changes don't take effect until a reboot... (Even though I Broadcast the required WM_SETTINGSCHANGE. Oh well. Code: [Select]#include once "windows.bi" 'Windows Master Registry Block is stored in the registry, 'at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" as REG_SZ's Declare Function SetEnvironment(VarName As String, VarValue As String) As Boolean Const WM_SETTINGSCHANGE = &H1A Function SetEnvironment(VarName As String,VarValue As String) As Boolean Dim UseRoot as HKEY,usekey As String Dim hk as HKEY Dim returnvalue As Boolean returnvalue=False UseRoot=HKEY_LOCAL_MACHINE UseKey= "SYSTEM\CurrentControlSet\Control\Session Manager\Environment\" 'Open the key... If RegOpenKeyEx(UseRoot,UseKey,0,KEY_ALL_ACCESS,hk) = ERROR_SUCCESS Then 'hk is a pointer to the key, use it with RegSetValueEx()... SetLastError(0) if RegSetValueEx(hk,StrPtr(VarName),0,REG_SZ,StrPtr(VarValue),Len(VarValue)+1)<>ERROR_SUCCESS Then Print "RegSetValueEx Failed." + "GetLastError returns " + Str(GetLastError()) End If RegCloseKey(hk) Else Print "RegOpenKeyEx Failed. GetLastError() returns " + Str(GetLastError()) End If PostMessage HWND_BROADCAST,WM_SETTINGSCHANGE,0,StrPtr("Environment") return returnvalue End Function SetEnvironment("Testing","howdy") I keep wondering why the OP doesn't just use a cmd script ("batch file") to do the things that he wants, and he never answers. This makes me wonder if he is trying to do some kind of script-kiddie thing. Since he steadfastly refuses to tell us, the help he is going to get will not be focused. i dont' know how much clearer than to post my code to make you happy (i did post the routine that is not working). Im not a scriptkiddie nor a kid at all, im a director of a marketing firm and have a need to take my batch files (that run on an sql server) and make them faster (and now with more capabilities, having moved to freebasic.) i have been doing things in the batch file with no issue's but wanted to make things faster, so am i allowed by you to move my batch file into a higher level language? is there some tribunal that i need to attend prior to GETTING help from you??? is it the fact that my routine is so simple that you can't wrap your head around it and wonder if i have an ulterior motive??? Did I not tip at the gate the proper amount??? Should I move to another forum to get help??? Who's in charge, I want to talk to the management about this!!! Outrageous! Preposterous! Bullocks!!! Quote from: Salmon Trout on December 15, 2011, 11:02:53 AM I keep wondering why the OP doesn't just use a cmd script ("batch file") to do the things that he wants, and he never answers. This makes me wonder if he is trying to do some kind of script-kiddie thing. Since he steadfastly refuses to tell us, the help he is going to get will not be focused.These two statements kind of contradict themselves. Quote from: skorpio07 on December 13, 2011, 03:04:21 PM not to hide, but the source file is getting a bit large so as a way of making it run faster. Quote from: skorpio07 on December 15, 2011, 12:04:08 PM is it the fact that my routine is so simple that you can't wrap your head around itQuote from: skorpio07 on December 15, 2011, 12:04:08 PM i dont' know how much clearer than to post my code to make you happy (i did post the routine that is not working). Im not a scriptkiddie nor a kid at all, im a director of a marketing firm and have a need to take my batch files (that run on an sql server) and make them faster (and now with more capabilities, having moved to freebasic.) Oh dear! Thank you BC for your very detailed response. I appreciate the help that your giving alot. couple of quick questions. in my batch file, when it gets to the part of the code that sets the environment variables, i had to run this: if not "%return%"=="" setx return %cd% & set return=%cd% that way i set the new global (via setx for FUTURE windows) envvar and then set the local var for the current (parent) window and it works just fine as a batch file. but if i want to move up to freebasic, how to program the same functionality in it. i knew that there were options to create the regkeys but didnt think i needed that till now, maybe a better solution.. but if i use the regkey solution, is there a way to have it promote itself back to the parent window? would need the envvar to "stick" upon program completion. again, many thanks for your detailed explanations, i will learn from this. Quote from: BC_Programmer on December 15, 2011, 10:52:13 AM The Environment Block of a process is a copy of the environment block of the parent process, or a new, default Environment Block (depending how you spawn the child process). |
|
180. |
Solve : Batch file to read from CSV and output multiple files? |
Answer» Hello all, and a first poster here. I'll be upfront and say I haven't really messed with batch files since editing Autoexec.bat in the 90s. Hadn't even heard of it, but after looking at the wikipedia page for it, I think I might look into it more in depth. Well worth it. Once you've got your head around its peculiar syntax, you'll appreciate that power. It blows the command prompt out of the water. Here are a couple of quick-starts for string functions: http://technet.microsoft.com/en-us/library/ee692804.aspx http://powershell.com/cs/blogs/tips/archive/2009/06/08/using-string-functions.aspxA couple of YEARS ago I started working on PowerShell for a few solid months and then got to caught up in life and stopped. It definitely has its advantages but I did run into a few problems that still could only be solved with a batch file. But I did like that I could create GRAPHICAL Interfaces for my powershell scripts. That was pretty cool. I had actually started to try and convert some of my batch files into PowerShell scripts. We had even FIGURED out how to do drag and drop input onto a powershell script. Quote from: Squashman on December 21, 2011, 03:03:27 PM Am I undestanding you correctly that you want a batch file that creates another batch file as well as a text file? Correct on that I'm wanting to use a batch file to create additional batch files and text files. Essentially I have 121 specialized systems that I need to migrate from a routed network to a VLAN. Before I can change the IPs, I need to change the encryption keys. To do so, I need to Telnet into each device, login to it, issue some special commands, then leave the connection open while sending another batch of commands from a central server. Once the commands from the central device are processed, then I can close out the remote connections. So the inital batch file would read from list.csv (list.txt & list.csv are the same file, just different extensions, both using a , for the delims. - I typo'd the original post) Code: [Select]Bldg 123 Rm 456,10.1.28.171 Bldg 789 Rm 12,10.1.50.20 and create Bldg 123 Rm 456.bat and Bldg 123 Rm456.txt Bldg 123 Rm 456.bat would contain the following: Code: [Select]"tst10.exe /r:Bldg 123 Rm456.txt /o:bench.txt" (note: /o:bench.txt is the output log of the tst10 program, but the log file itself isn't necessary for me to keep, though I believe the switch needs to be there) and Bldg 123 Rm456.txt would contain: Code: [Select]10.1.28.171 20000 WAIT "username:" SEND "name\m" WAIT "password:" SEND "pass\m" WAIT ":" SEND "command\m" IP is the only thing that changes here. All other text is the same across all devices. So in the end, I'd end up with 121 batch files, each with the TST10.exe shortcut/parameters, and 121 text files as the command script that will be executed on the remote devices. I did look into Polyscript for this, but it didn't seem to work on the bench test. TST10 worked, so it looks like that's the route i'm going. Code: [Select]For /F "tokens=1,2 delims=," %%G IN (list.txt) DO ( echo "tst10.exe /r:%%G.txt /o:bench.txt">"%%G.bat" echo %%H 20000>"%%G.txt" echo WAIT "username:">>"%%G.txt" echo SEND "name\m">>"%%G.txt" echo WAIT "password:">>"%%G.txt" echo SEND "pass\m">>"%%G.txt" echo WAIT ":">>"%%G.txt" echo SEND "command\m">>"%%G.txt" )SWEET! That looks perfect! I'll test it out later today to make sure. Now as long as I didn't fat finger anything on my end, I should be golden. Thank you so, so much!Oh, I have to ask, cuz this is the one big thing that I've had a hard time wrapping my brain around: %%G is column A, and %%H is Column B....but why? What defines it? My guess at this point would be that the first line with %%G IN (list.txt) sets it up so that %%G = A1, therefore %%H would be A2 and it just works its way down the line, but.....well, is that correct?one flaw, now fixed: Code: [Select]For /F "tokens=1,2 delims=," %%G IN (list.txt) DO ( echo tst10.exe /r:%%G.txt /o:bench.txt>"%%G.bat" echo %%H 20000>"%%G.txt" echo WAIT "username:">>"%%G.txt" echo SEND "name\m">>"%%G.txt" echo WAIT "password:">>"%%G.txt" echo SEND "pass\m">>"%%G.txt" echo WAIT ":">>"%%G.txt" echo SEND "command\m">>"%%G.txt" ) Was: echo "tst10.exe /r:%%G.txt /o:bench.txt">"%%G.bat" The quotes inside the batch file didn't play nice. =D Quote from: ShaneC on December 22, 2011, 07:47:32 AM
What defines it is the "tokens=1,2" part of the tokens/delims block of the FOR statement. If you use tokens you can create potential "IMPLICIT" variables that follow the letter you choose for the explicit FOR variable. They are called implicit variables because they are implied by the tokens= section. This part: "tokens=1,2 delims=," %%G tells FOR: "Consider each line read in from list.txt to be a series of tokens separated (delimited) by commas. Assign token number 1 to %%G and assign token number 2 to a variable consisting of two percent signs and the next letter after G (i.e. %%H). "tokens=1-2" means the same as "tokens=1,2". It's all in the FOR documentation which you can access by typing FOR /? at the prompt. tokens 1 2 3 4 string horse,tiger,elephant,sheep ^ ^ | | %%G %%H |
|
181. |
Solve : NetBeans/Java DNS cache?? |
Answer» NetBeans seems to use a DNS cache separate from the O/S. When developing web sites with my laptop in different locations, it would be really handy if I could get this cache flushed (one LAN IP address when at work, one EXTERNAL IP address from a local DNS server when at home). Windows' own resolver has no problem with this CONCEPT and I can always run ipconfig /flushdns if needs be. But NetBeans is still looking in the wrong place. Hang on - reading that article more closely, there's a suggestion a JRE setting might fix it. I'll try that. Thanks! You bet, keep us posted So far so good - thank you!There was a strange twist to this. The Windows DNS cache operates slightly differently in versions of Windows after XP. ipconfig /flushdns appears to work properly in an unelevated command prompt. But it doesn't. The cache is only properly flushed when the command is run from an elevated prompt. Anyway, with the settings change and BEARING the above in mind, my multi-location development is proceeding smoothly again. |
|
182. |
Solve : MySQL 'Tip'? |
Answer» Just a quick tip: If you are trying to access a MySQL Server remotely (from another machine, say- for example, using the .NET DBConnector on a desktop while using a existing MySQL Install on the laptop) consider the fact that MySQL ships by default so that it doesn't allow remote connections. Are you developing in Visual Studio? Can that not handle all the FTP uploads for you?The applications I speak of are not web-applications, but client-side programs; my website is PHP/MySQL, running on a webhost. Normally, I would work on my site using Editpad Pro's FTP Panel, which makes dealing with FTP pretty much automatic. The reason I've had to start using the ftp shell on my linux machine is that my only Internet access currently is through wireless and my Wireless-N PCI card appears to have given up the ghost, so my desktop has no internet connection, (I tried learning how to bridge the connections via the laptop but gave up). ftp is still quite workable and in many ways faster to work with, so it's not a huge change. Although now my laptop is tethered to the desktop via a crossover cable for both my own MySQL dev server as well as data transfers through Samba in both directions . Quote from: BC_Programmer on December 17, 2011, 07:02:08 PM consider the fact that MySQL ships by default so that it doesn't allow remote connections.Sounds just like SendMail. You wouldn't believe how long I bitched and screamed at my old linux server when I couldn't receive any email on my server from the outside. SendMail by default just works locally on the machine until you change the config to allow it to receive email from the outside world.In MySQL's case, having it configured that way by default makes more sense, since one of the most common use cases is that the MySQL Server is in fact the same machine that is running apache, so it basically "connects" to itself,so allowing remote connections would just be opening an attack surface. I just found that, even after I knew that was the default setup, I had to do so much googling just to find out how to change it, and it was a bit frustrating. But it's working quite flawlessly now. Quote from: BC_Programmer on December 19, 2011, 07:03:09 AM even after I knew that was the default setup, I had to do so much googling just to find out how to change it, and it was a bit frustrating.Ditto when I setup SendMail the 1st time. I had one of those huge 3 inch hard cover SendMail books and I couldn't find the answer in their. Then spent a few days Google Searching and finally figured out how to change the SendMail config file. Was literally one line of code to change. I completely understand why MySQL and Sendmail would be configured out of the box like that. It is probably a huge security hole if you don't have your server or Network locked down. You certainly wouldn't want to have an Open Relay setup on your Mail server by accident.Hindsight is wonderful, isn't it! "telnet aaa.bbb.ccc.ddd 25" (from a remote machine) is our friend. |
|
183. |
Solve : Creating a batch file to open programs in order? |
Answer» Hello everyone, apparently so did i It's nothing about turf. It's about thread necromancy, which is frowned upon by most members of any forum. (unless it's the Original Poster)I agree. Leave a thread alone if the original poster has not come back. On most of the forums I contribute on if a new user posts a question I usually answer back with a feeler question to see if they are going to come back. I don't like wasting my time writing a script if they are never going to come back. |
|
184. |
Solve : batch file to check folders if populated? |
Answer» I've DONE very LITTLE with batch files, but I need to check several thousand directories to see whether or not they're populated. My FINAL outcome will be a list of directories that are empty. The folder structure looks like this: |
|
185. |
Solve : checkbox problem! need help? |
Answer» I have USE 4 checkbox in one asp.net webpage, say page |
|
186. |
Solve : OS boot problem? |
Answer» i am MAKING an OS (DakOS) and i am having some problems, 1.When i compile the file (i am making an os that will only use the boot LOADER) it YELLS at me that there isn`t any room when i convert the floppy disk to an ISO . 2.It recognizes it but it says "Invalid system disk" how might i fix this (also it is 512 Bytes) |
|
187. |
Solve : Batch Networking? And a cmd line ASCII graphics engine.? |
Answer» Is it possible to do networking with server in batch? And also, imagine a PROGRAM that allows you to load and move ASCII images for cmd line languages and text based programs. Also, for making text based games, and perhaps later games with minor graphics (like, minecraft low graphics) should I use C++, TorqueScript, Java, or make my own language if so possible?Well, now that you bring Minecraft up, I do think that Bukkit servers run using conhost.exe and cmd.exe from a batch file. So to your first question YES? Quote from: Nathansswell on November 28, 2011, 02:35:19 AM Well, now that you bring Minecraft up, I do think that Bukkit servers run using conhost.exe and cmd.exe from a batch file. So to your first question Yes? The batch file in Bukkit contains the following code: Code: [Select]ECHO OFF IF /I "%PROCESSOR_ARCHITECTURE:~-2%"=="64" "%ProgramFiles(X86)%\Java\jre6\bin\java.exe" -Xincgc -Xmx1024M -jar "craftbukkit-1.0.1-R2-SNAPSHOT.jar" IF /I "%PROCESSOR_ARCHITECTURE:~-2%"=="86" java -Xincgc -Xmx1024M -jar "craftbukkit-1.0.1-R2-SNAPSHOT.jar" PAUSE That's just RUNNING the java file and providing a vehicle for you to send and receive text to the server. Quote from: tommyroyall on November 19, 2011, 08:00:02 PM Is it possible to do networking with server in batch?Like a multiplayer game? I don't think that batch is well suited for that. There's one thing that I TRIED, where I set up a website and the batch connected to it using FTP, downloaded a certain text file that contained information, and uploaded its own version of it if that was needed every two seconds. It was pretty effective for a simple chat script, but actually what the batch file did was launch a DoS attack on my website. D: For networking, or a GUI game at all, you'd probably need a better programming language. While we're on the subject of minecraft, minecraft uses java. If you've never learned another programming language, cross C++ right off your list of possibilities. It has DIFFICULT syntax, and something fairly simple requires a large script. |
|
188. |
Solve : cs5? |
Answer» So Im trying to learn platform GAMING for fun, cs5 flash AS.3 |
|
189. |
Solve : C++ Floppy to C: tool issues? |
Answer» I have a large amount of floppy disks that I used between 1988 and around 2000 when I finally got a CD Burner. I started manually copying them via xcopy all contents to my C: drive, but after getting through 25 disks in 1 box, I thought there has to be an easier method of passing my disks contents to C: drive. |
|
190. |
Solve : Perform an HTTP/1.1 POST in VBScript? |
Answer» I have had the idea to make a "Chat Autofixer" for XSketch.com, and in order to do this, I basically flood the chat with a message consisting of [ ]. I want to make it distributable, for my XSketch friends, and source-viewable. I'd like to do this using VBScript. Unfortunately, the server running XSketch is using GWT with a POST to send messages, and I don't know how to EXECUTE a POST in VBS. I only NEED to post a string, and I know what URL to post to. Does anyone know the code required to perform such an action? |
|
191. |
Solve : Timer code that doesnt interupts proceedure? |
Answer» How can i write a timer code like the 1 in Visual Basic |
|
192. |
Solve : shUI builder is a little lost...? |
Answer» shUI is a program built in C++ for those who aren't able to run X window system on linux (and those who can't use anything else than the command prompt in DOS) and to give them a minimal UI-like interface to browse, edit text and whatever. This is the installation program, but I need help for a lot of things, like: 1. how to put color in the program. 2. How to make cin scroll horizontally when the text outbounds the specified limit. 3. how to position text on screen And other things will come over time that my program develops. This is where i'm stuck: Code: [Select]#include <iostream> #include <fstream> #include <conio.h> #include <stdio.h> #include <stdlib.h> #include <dos.h> using namespace std; const unsigned char Key1 = 224; const unsigned char LEFT = 75; const unsigned char RIGHT = 77; const unsigned char UP = 72; const unsigned char DOWN = 80; int main(){ int frm1(); frm1(); }; void frm1(){ int frm2(); cout << " ________________________\n"; cout << "| \\_____Setup______/ |\n"; cout << "| ______________________ |\n"; cout << "|| WELCOME to shUI's ||\n"; cout << "||installation program! ||\n"; cout << "|| ||\n"; cout << "|| ||\n"; cout << "|| ||\n"; cout << "||______________________||\n"; cout << "| <QUIT | | NEXT> |\n"; cout << "`------------------------'"; cout << "";stucked unsigned char choice = getch(); cout << endl; if (choice == Key1) { unsigned char choice2 = getch(); switch(choice2) { case LEFT: system ("CLS"); cout << "ShUI ended."; break; case RIGHT: system ("cls"); frm2(); } } return ; } void frm2(){ int frm1(); cout << " ________________________\n"; cout << "| \\_____Setup______/ |\n"; cout << "| ______________________ |\n"; cout << "||First of all, you ||\n"; cout << "||need to input some ||\n"; cout << "||information and ||\n"; cout << "||settings concerning ||\n"; cout << "||you, your account ||\n"; cout << "||data and your ||\n"; cout << "||computer. ||\n"; cout << "||______________________||\n"; cout << "| <Back | | Next> |\n"; cout << "`------------------------'"; cout << ""; unsigned char choice = getch(); cout << endl; if (choice == Key1) { unsigned char choice2 = getch(); switch(choice2) { case LEFT: system ("cls"); frm1(); } } return ; } |
|
193. |
Solve : Help me Convert this WPF to Silverlight? |
Answer» I am interested in a CHARLES Petzold C# example that shows how to do a fisheye effect ( http://www.charlespetzold.com/blog/2009/05/Realizing-a-Fisheye-Effect-in-Silverlight.html ). The XAML code samples are in WPF but I want to try this in Silverlight. |
|
194. |
Solve : Think of a number? |
Answer» I'm trying to write a program, that generates a random number, between 1 and 100, then asks the user to guess it. If the user is to high it states 'lower', if the guess is to low it states 'higher', until the correct number id guessed. I'm have trouble because i seem to keep creating infinite loops, how can i stop this? Code: [Select]import java.util.Scanner; public class ThinkOfANumber { public static void main(String[] args) { Scanner input = new Scanner(System.in); final int num = 100; int numgen = (int)(Math.random() + num) +1; int count = 0; System.out.println("Guess any number between 0 and 100"); int guess = input.nextInt(); while (guess != numgen) { if (guess > numgen) System.out.println("Lower"); while (guess != numgen) { if (guess < numgen) System.out.println("Higher"); while (guess == numgen) System.out.println("You've got the right number, Well Done"); } } } }your formatting isn't consistent with the actual control structures; Code: [Select]public class ThinkOfANumber { public static void main(String[] args) { Scanner input = new Scanner(System.in); final int num = 100; int numgen = (int)(Math.random() + num) +1; int count = 0; System.out.println("Guess any number between 0 and 100"); int guess = input.nextInt(); while (guess != numgen) { if (guess > numgen) System.out.println("Lower"); while (guess != numgen) { if (guess < numgen) System.out.println("Higher"); while (guess == numgen) System.out.println("You've got the right number, Well Done"); } } } }basically, your loops are nested. Additionally, if you want to keep looping then you would need to have a while loop that terminates only when it's correct. All your while loops seem to be attempting to print the same thing as long as the guess is less than , greater than, or equal to the GENERATED number, but within the loops there is no actual change of that value so the condition remains the same. Something like this ought to be written with a loop that terminates only when the guess is correct, and reads in the next input at the start. Than if it's too low you print a message, if it's too high you print a message, and outside the loop is where it gets when the guess is correct, so you woul print an appropriate message for that outside the loop.I don't understand the use of all those while loops, you should just have one while loop with the appropriate if statements inside of it. Maybe something like this. Sorry, I can't actually TEST it because I do not program in java, so you may need a little tweaking. Code: [Select]public class ThinkOfANumber { public static void main(String[] args) { Scanner input = new Scanner(System.in); final int num = 100; int numgen = (int)(Math.random() + num) +1; int count = 0; int guess = 0; while (guess != numgen) { System.out.println("Guess any number between 0 and 100"); guess = input.nextInt(); if (guess > numgen) System.out.println("Lower"); if (guess < numgen) System.out.println("Higher"); count++; } System.out.println("You guessed it."); } } And I forgot, you may also want to print out count. I assumed that you wanted to count how many guesses. Thank BC, after some tweaks (I had the random number generator set to 101, which didn't help) , it was basically like you said. I've learned alot today about the placement of curly brackets. Thanks again, everyone. public static void main(String[] args) { Scanner input = new Scanner(System.in); final int num = 100; double numgen = (Math.random())*100; int a=(int)numgen; while (a>100 || a<0) { numgen = (Math.random())*100; a=(int)numgen; } int count = 0; System.out.println("numgen"+a); System.out.println("Guess any number between 0 and 100"); int guess = input.nextInt(); while (guess != a) { if (guess > a) System.out.println("Lower"); if (guess < a) System.out.println("Higher"); System.out.println("Guess any number between 0 and 100"); guess = input.nextInt(); } if (guess == a) { System.out.println("You've got the right number, Well Done"); } }you are getting 101...its because the random number generated is becoming 0 each time...its because you made it an int type... to get the full random value....you should get it in double value....all the numbers are like 0.5677777777 or 0.06777777777....its always in decimal value...so to be able to get a value between 0 and 100....i have multiply the random value by 100...then i cast it to an int...so that the value obtained is not a decimal one...then i have checked it the way u wanted. QUOTE from: lina19 on January 09, 2012, 02:57:47 AM you are getting 101...its because the random number generated is becoming 0 each time...its because you made it an int type... Sorry, i should have marks this as solved. As you can see by 'reply 3' it was solved last November. its because...it wasnt marked as solved...and your reply was confusing as well.. Thank BC, after some tweaks (I had the random number generator set to 101, which didn't help) , it was basically like you said. I've learned alot today about the placement of curly brackets. I had the random number generator set to 101, which didn't help: what am i supposed to understand about it???"didnt help"....you could have stated that it was solved more clearly.... INSTEAD of asking u....whether it was solved and WAITING for you to reply...it was quicker to give the answer...its ok eventhough the reply is not useful for now...it can be useful for others as well... |
|
195. |
Solve : editable Jtree in java? |
Answer» refer to this code for testing: |
|
196. |
Solve : 16 bit C++ compiler? |
Answer» I've got a 64-bit PC (WINDOWS 7), but I must compile a C++ program for DOS. BTW:You could look for an old COPY of BORDERLAND Turbo C++ which might be a free download by now. But the real issue is running any 16 bit programs in the 64 bit Windows 7 system. You will need to use a virtual machine. EDIT: This looks like it. http://www.brothersoft.com/turbo-c-182798.htmlYou can use DOSBox, it's simple to use and works great. |
|
197. |
Solve : Help needed in C# - programming? |
Answer» Please I'm a beginer in C#, so if you just can give me a suggestion about how to SOLVE the following problem. The problem is that I'm stucked in a place where where it is asked to show how many km/one liter. Is the problem to do with getting the formula correct, or something else?I had a problem on writing the codes, so after a time I solved (learned) it. Anyway cheers for your help. |
|
198. |
Solve : what do u mean by pallindrome? |
Answer» SHORT DEFINITION WOULD be fineSorry, we don't do HOMEWORK here | |
199. |
Solve : code to make pyramid shape astersik in c program? |
Answer» please sir give me the simplest code to make pyramid shape astersik using for loopThis comes up froim time to time in programming classes... is this your homework? please sir Sunday night, addressed as sir, mentions language in TITLE rather than text as if everyone uses C, specifically needs to use for loop... Quote from: Salmon Trout on January 08, 2012, 11:44:25 AM This comes up froim time to time in programming classes... is this your homework? Gonna agree with that guess. Code: [Select] * *** ***** ******* ********* Looking for this? Not going to worry as this has been MARKED as solved...yeah it is my homework.......and at LAST i had managed to make the shape using for loop thnxNo more homework help please. |
|
200. |
Solve : please tell me error in this program of prime no.(i had made it )? |
Answer» #include; |
|