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.
| 1051. |
Solve : What type of VM or interpreter would this be?? |
|
Answer» I was just thinking about possibly designing a new version of my scripting language. I know that there are two types of programming language interpreters. There's the kind the decodes the syntax in real time as it's executing (like mine) and then there is the kind like Java or .NET that compiles to byte code. I am also aware that there are two types of byte code interpreters (stack based and register based). My question is what would you call an interpreter that uses byte code, but does not use a stack or registers? It would simply have a byte or two to represent each command and then each command would have a few bytes after it that represent the location in memory of the parameters for that command. If the command had math in the parameters, then it would just point to a string containing the math and then the interpreter would execute it. To me it seems like this type of interpreter would be a lot faster than the ones that use an actual virtual machine code. Would this be better, or is there something I'm overlooking? I hope you understand what I mean because it's pretty hard for me to explain this stuff clearly.Quote from: Linux711 on FEBRUARY 01, 2013, 03:25:52 PM To me it seems like this type of interpreter would be a lot faster than the ones that use an actual virtual machine code. You are overlooking this: Quote then it would just point to a string containing the math and then the interpreter would execute it.And how does it "execute" the string? By interpreting it. Your method only really 'compiles' the highest level, where everything LOWER down is STILL in the original form, and needs to be interpreted later. So you don't think there'd be any added speed by using this method? Why would an actual VM be faster than this? Isn't reading the syntax and then deciding what to do the slowest part? I figured by eliminating that step, it would make it much faster.My idea is that if you condense the actual syntax into a byte code that I explained, and then use the interpreter to execute that, then most of the actual processing is done on the real CPU itself and only the big picture concepts (the commands) are emulated. With an actual VM every little step has to be interpreted any finally executed as native code rather than just the 'big picture' commands.Quote from: Linux711 on February 01, 2013, 03:25:52 PM a string containing the math and then the interpreter would execute it. *censored*! If only I had KNOWN it was that simple! Quote *censored*! If only I had known it was that simple! Yes, I could have been more specific on that, but it doesn't matter because that's not the point. (Not trying to be mean if you were just pointing that out for fun.) My latest post most accurately describes my point.Quote With an actual VM every little step has to be interpreted any finally executed as native code rather than just the 'big picture' commands.First, the .NET CLR as well as the JVM use a of JIT(Just in Time) Compilation. That is, once it executed a block of code, that piece is compiled and that compiled bit is used from then onwards if that code is executed again. And that isn't to touch on the other optimizations that they both make, such as Sealed methods in public classes no longer requiring virtual dispatching, which would normally be required to call the appropriate method implementation. I think you are seriously underestimating just how much experience and understanding the people that work on these Virtual Machine implementations have. Very few languages today- with the possible exception of ruby and PHP- are truly interpreted 'in place'. Otherwise, the most "basic" implementation is generally to build an Abstract Syntax Tree for the language tokens. This is almost exactly what you are describing. Quote from: Linux711 on February 01, 2013, 04:31:04 PM So you don't think there'd be any added speed by using this method? Why would an actual VM be faster than this? Isn't reading the syntax and then deciding what to do the slowest part? I figured by eliminating that step, it would make it much faster."reading the syntax and deciding what to do" are two completely disparate tasks. "reading the syntax" would consist of building an Abstract Syntax tree. Deciding what to do involves executing that tree. Of course Virtual Machines also compile to Native code on the fly as they execute the Bytecode (Implementations of bytecode interpreters in other languages sometimes take this approach as well). The reason I pointed out the "a string containing the math and then the interpreter would execute it." You are basically saying "I think the easiest way to interpret some script is to have it in a string and then have an interpreter execute it"... it doesn't actually say anything but what you plan to do. It's not an algorithm. It's like saying "I think the best way to sort a list is to have a list and have a function sort it".Quote from: BC_Programmer on February 01, 2013, 05:39:53 PM The reason I pointed out the "a string containing the math and then the interpreter would execute it." You are basically saying "I think the easiest way to interpret some script is to have it in a string and then have an interpreter execute it"... it doesn't actually say anything but what you plan to do. It's not an algorithm. It's like saying "I think the best way to sort a list is to have a list and have a function sort it". This is what I was getting at. |
|
| 1052. |
Solve : How to go to previous directory form current working directory? |
|
Answer» Hi, cd "C:\Program File\Adobe\"This would do it...btw your slashes are WRONG way for windows/dos To go up to the parent directory, you want to USE "cd ..". When navigating directories ".." represents the parent directory and "." represents the directory you are currently in. Hope this helps.Hi, Thanks for the reply, I tried the script like this setlocal ENABLEEXTENSIONS echo %CD% echo %CD..% endlocal it is printing only cd path as "D:\PROJECTFILES\Scripts" But not cd.. I need to get the the parent path by the batch script.. Please send the batch script. Thank You,AH! When you said you wanted to "go" to the previous directory PEOPLE understandably thought you wanted to change the current directory to that one. Now it seems you want to obtain the drive & path name of that folder, i.e. obtain the path of the current folder with the final item (this folder name) removed. Echo the path to the folder above the current one: for %%A in ("%cd%") do echo %%~dpA Quote from: jackk on April 26, 2013, 11:19:57 PM Hi,You are confusing a command with a variable. CD is a command. %CD% is a variable.Thank you for reply .. Now it is WORKING.. Thank you |
|
| 1053. |
Solve : help with python invalid syntax? |
|
Answer» #prompt for name then subsequent MILE runs then add mile runs. The second line has an unclosed parentheses. Parenthesis? |
|
| 1054. |
Solve : forgotton VBA Document password (Excel , VBA)? |
|
Answer» i was working on abit of CODE in VBA, in excel, i added a passsword and mispalced it, i have read around and seen theorys about EDITING abit of the code in a HEX editor, for me this just corrupts the VBA and replaces it with a blank one |
|
| 1055. |
Solve : Bat file help!? |
|
Answer» Before reading i want you to know that my english is not good... IF-THEN-ELSE statements are not a batch strong point If "%condition%"=="TRUE" ( echo Yes ) else ( echo No ) @echo off cls echo Welcome to Haslien Transolater :trans REM The word English starts with a capital E set /p word="[0 to quit] Enter English word: " if "%word%"=="0" goto end REM I use English / French word pairs because REM I don't know what language you are using REM Use /i to ignore case if /i "%word%"=="cat" goto cat if /i "%word%"=="dog" goto dog if /i "%word%"=="man" goto man if /i "%word%"=="hat" goto hat if /i "%word%"=="pig" goto pig REM if you get here then word not in list Echo Error: %word% not in list goto trans :cat echo %word% = chat goto trans :dog echo %word% = chien goto trans :man echo %word% = homme goto trans :hat echo %word% = chapeau goto trans :pig echo %word% = cochon goto trans :end echo Finished Pause Screen output: Welcome to Haslien Transolater [0 to quit] Enter English word: cat cat = chat [0 to quit] Enter English word: hat hat = chapeau [0 to quit] Enter English word: man man = homme [0 to quit] Enter English word: pig pig = cochon [0 to quit] Enter English word: dog dog = chien [0 to quit] Enter English word: TAP Error: tap not in list [0 to quit] Enter English word: 0 Finished Press any key to continue . . . This is much shorter @echo off cls echo Welcome to Haslien Transolater :loop set /p word="[0 to quit] Enter English word: " if "%word%"=="0" goto end set trans=$$$$ REM You only have to EDIT here to add / remove word pairs if /i "%word%"=="cat" set trans=chat if /i "%word%"=="dog" set trans=chien if /i "%word%"=="man" set trans=homme if /i "%word%"=="hat" set trans=chapeau if /i "%word%"=="pig" set trans=cochon if "%trans%"=="$$$$" ( Echo Error: %word% not in list goto loop ) echo %word% = %trans% goto loop :end Echo Finished Pause Suggestion: if "%word%"=="" ( Echo You entered a blank string goto loop )another WAY: (1) words.txt cat,chat dog,chien man,homme hat,chapeau pig,cochon horse,cheval sheep,mouton cow,vache mouse,souris bird,oiseau girl,fille (2) Batch program in same folder @echo off cls echo Welcome to Translater :loop set /p word="[0 to quit] Enter English word: " if "%word%"=="0" goto end set trans=$$$ for /f "tokens=1,2 delims=," %%A in (words.txt) do if /i "%word%"=="%%A" set trans=%%B if "%trans%"=="$$$" ( Echo Bad input or word not in list goto loop ) echo %word% = %trans% goto loop :end Echo Finished Pause |
|
| 1056. |
Solve : Monitoring Log Files with Perl? |
|
Answer» I am attempting to write a program that takes INPUT from /var/LOG/auth.log and PARSES all of the successful/attempted logins on this server. I have been able to write the logs files that I want to keep to another log (formatted in columns for date time user success/failure and ip). The problem that I am having a hard time figuring out is how I can write just the new logs when I schedule the script with crontabs. I'm fairly new at Perl, but I KNOW there is a WAY to do this. |
|
| 1057. |
Solve : just a small question about a python program? |
|
Answer» this is just a small learning excercise I'm doing. Im attempting to make this and combine a number of skills i have learned to see how it WORKS and learn some things. im self teaching myself python and how to use TERMINAL and a few other subjects as i am taking pre recs now for SCHOOL and WANT to have an edge when i start taking computer programming classes |
|
| 1058. |
Solve : RGB to Long and Back? |
|
Answer» It's quite easy to CONVERT RGB colour to Long as used in the Property Sheet EVEN without the RGB function, but what about the other WAY around? I managed to work it out, so I'll reproduce it here for anyone who is interested. I've also shown the RGB to Long formula for reference. |
|
| 1059. |
Solve : text file into rich text box in vb? |
|
Answer» Hello, |
|
| 1060. |
Solve : Lenovo recovery question?? |
|
Answer» I have a Lenovo H430 desktop that i am going to work on this sunday. APPARENTLY after the windows logo loads there is just a black screen and will go no further. The pc came with a disk labeled Lenovo Win7 Drivers pack v2.7. Is this the recovery disc or do i need to order them from lenovo? Any tips would be appreciatedI'm gonna say that it's just the drivers, I think you may need to contact them to GET a Win 7 disc. |
|
| 1061. |
Solve : Get between two strings VB.NET function? |
|
Answer» I need to modify a VB function that gets a substring from between a starting string and ending string. The problem is that I need it to be able to ACCEPT multiple parameters for the ending string and stop when it finds the first instance of one of those strings. Can anyone (BC_Programmer) help me with this? Anyone who helps me with this, I will send the full SOURCE of the application when it's done if you'd like. |
|
| 1062. |
Solve : Need (SIMPLE?) Program for Artwork? |
|
Answer» Hi All. I am working on a new work of art that is titled IT IS BETTER TO BURN OUT THEN FADE AWAY. It consists of a new computer with a program that will visually count down from 27 days (Based on the 27 Club...those famous people that have died at 27...and the planned obsolescence of technology) and then overheat the unit causing it to "burn up" or at least shut down. I have yet to purchase the computer, so I can get any operating system needed. Is this possible? How difficult would it be? Can anyone write it for me? At what cost?The 27 day count down until the computer shuts down is your safest option although not as impressive to onlookers as a computer that burns up. It would basically use a shutdown -f -s to force the computer into a shutdown. Any real triggered burn up event would be flagged as bad by homeland security as potential computer based bomb making plans. |
|
| 1063. |
Solve : c problem? |
|
Answer» first i download c++ and install, after install when i oen msg |
|
| 1064. |
Solve : vnc like software programming general question? |
|
Answer» Hey Guys, |
|
| 1065. |
Solve : c# splitting string into separate strings.? |
|
Answer» Hello all im trying to split a string into multiple strings for INSTANCE im trying to send an email with a string. |
|
| 1066. |
Solve : VB .Net get focused process title? |
|
Answer» Hi and Happy New Year:D |
|
| 1067. |
Solve : Batch - Using IF/Else statement with system info? |
|
Answer» Here is the code that i have so far alrighty, i have another question but this time i am really stumped Are you running the batch file as administrator? It should be necessary already if you're accessing system32, but I wanted to make sure. Another suggestion (see around where I put the REM commands/comments): Code: [Select]c: cd c:\sccm_temp\sap echo "Copying Saplogon File" xcopy "c:\sccm_temp\sap\saplogon.ini" "%appdata%\SAP\Common\" /Y echo "Setting up NWBC client" REM this will save a backup of services to services.bak and the new version to 'services' REM previous code would save two copies of the modified file and no backup copy c:\windows\system32\drivers\etc\services c:\windows\system32\drivers\etc\services.bak type c:\windows\system32\drivers\etc\services.bak | findstr /v sapmsEDV | findstr /v sapmsEPR | findstr /v sapmsEQA > c:\windows\system32\drivers\etc\services echo sapmsEDV 3600/tcp >> c:\windows\system32\drivers\etc\services echo sapmsEPR 3600/tcp >> c:\windows\system32\drivers\etc\services echo sapmsEQA 3600/tcp >> c:\windows\system32\drivers\etc\services regedit /s c:\sccm_temp\sap\DEV_SETTINGS_NWBC.reg <-----------Line 16 If %PROCESSOR_ARCHITECTURE%==AMD64 ( regedit /s c:\sccm_temp\sap\NWBC_Sec_64bit.reg ) else ( regedit /s c:\sccm_temp\sap\NWBC_Sec.reg ) Quote from: TechnoGeek on November 27, 2012, 05:32:28 PM Are you running the batch file as administrator? It should be necessary already if you're accessing system32, but I wanted to make sure. Your REM/Comment code is a nice touch, but why are you looking at the .bak to overwrite the original without the EDV/EPR/EQA? No the batch file is ran as a local user (granted all users have admin rights) so it baffles me that the reg file wont run IN the batch. I have tried nesting the other reg files in the DEV_SETTINGS_NWBC and vice versa; both resulting in the reg file RUNNING but the DEV_SETTINGS_NWBC info never gets DUMPED into the registry. Not sure if it has to do with that its adding things to "HKEY_CURRENT_USER" or that the batch suppresses something that it shouldn't. Quote from: The_Valkyrie on November 28, 2012, 08:49:05 AM Your REM/Comment code is a nice touch, but why are you looking at the .bak to overwrite the original without the EDV/EPR/EQA?If you read your original code carefully, you save two copies of the same file, both with those particular entries removed. The one I wrote *should* save the original, unmodified file as services.bak. The reason I copy from services.bak (original file) to services is to avoid any file-in-use errors from copying services (with lines removed) to itself. Quote No the batch file is ran as a local user (granted all users have admin rights) so it baffles me that the reg file wont run IN the batch. Try this: edit the registry to match what you want it to become, then export those keys. See if there are any differences between the generated .reg file and yours (which could have an error somewhere).Quote from: TechnoGeek on November 28, 2012, 10:41:30 AM If you read your original code carefully, you save two copies of the same file, both with those particular entries removed. The one I wrote *should* save the original, unmodified file as services.bak. The reason I copy from services.bak (original file) to services is to avoid any file-in-use errors from copying services (with lines removed) to itself.Oh I see! Quote from: TechnoGeek on November 28, 2012, 10:41:30 AM Try this: edit the registry to match what you want it to become, then export those keys. See if there are any differences between the generated .reg file and yours (which could have an error somewhere). Tried that, the export and the .reg file are the same down to the ordering of entries. I am super baffled so i found a fix, kinda weird but its a start: create another batch with the following Code: [Select]reg add "HKCU\Software\SAP\NWBC\Settings\Pages\RuntimeConnections\BAG" /v "URL" /t "REG_SZ" /d "http://" Then use the original batch above to call this batch and BAM! you have yourselves an EDITED registry in the HKCU area. Now i MUST make it all in one cause im lazy and RATHER push 1 file than 4 files. Quote IF %systemtype%==AMD64 iI believe you need quotes sine you're matching a variable to a string Try:Code: [Select]IF '%systemtype%'=='AMD64' dont know if thats still a problem, but that should fix it. im no expert, but have had the same problem before with batch files. Quote from: TechnoGeek on November 28, 2012, 10:41:30 AM If you read your original code carefully, you save two copies of the same file, both with those particular entries removed. The one I wrote *should* save the original, unmodified file as services.bak. The reason I copy from services.bak (original file) to services is to avoid any file-in-use errors from copying services (with lines removed) to itself. found an issue with your code: Code: [Select]copy c:\windows\system32\drivers\etc\services c:\windows\system32\drivers\etc\services.bak type c:\windows\system32\drivers\etc\services.bak | findstr /v sapmsEDV | findstr /v sapmsEPR | findstr /v sapmsEQA > c:\windows\system32\drivers\etc\servicesThe first line returns an "access denied" when running it. Yes, the line works when its ran as admin but i cant specify to run as admin in SCCM's task sequence. I CAN, however, issue commands that can start this batch as admin or execute the batch that contains admin escalation....just dont know how to do that right now. Warning: this topic has not been posted in for at least 30 days. Unless you're sure you want to reply, please consider starting a new topic. ^I'm use to using 1 thread as to be respectful and tidy^ anyways!!!!! Anyone of you Ladies and Gentleman know the best way to write data to the C:\windows\systems32\drivers\etc\services file without being phycially near the computer (ie. remote) Currently I have this batch (see parts above) that needs to write to the services file. Well that needs to be ran as admin.....can't log onto all 857 computers to do this so i rather make a script. KICKER: the admin password is the same but with different variations (ie. password, Password, PassWord, passw0rd, etc) thank you |
|
| 1068. |
Solve : How to let the user select a path f a file and delete it in batch? |
|
Answer» Hey im not sure how to let the user of a batch file select a file and delete it using batch. My computer keeps getting ERRORS although i cannot find out what i programmed wrong. PLEASE help.Quote My computer keeps getting errors although i cannot find out what i programmed wrong. please help. What errors? Syntax? Logic? You would do yourself a world of good if you posted what you have programmed. How do you see this working? List the files in a folder and allowing the user to select ONE for deletion? Allowing the user to manually input the label of the file to be deleted? Well, I want to let the user type in the path of the file and delete it.Code: [Select]@echo off setlocal set /p file=Enter File Name: if exist %file% ( echo del %file% && echo %file% has been deleted ) else ( echo Incorrect File Name: %file% ) I dislike writing destructive scripts, so this script performs a whatif SCENARIO. When you're satisfied remove the first echo instruction from line 6. Thanks alot sidewinder! I had found the MISTAKE i made and i had successfully made this batch file that can dlete files. thx! |
|
| 1069. |
Solve : PHP - exporting to .xls file? |
|
Answer» Hello, I'm working with PHP + CODEIGNITER + PHPExcel library and am having trouble trying to perform a certain function. |
|
| 1070. |
Solve : Zip.vbs script? |
|
Answer» Quote from: Sidewinder on May 24, 2013, 09:29:11 AM OK, this has become a quest. OK well Here is the error when I run from command prompt Input Error: There is no file extension in "C:\dir\dir with space but first part of the dir with space". I also What i provided above is all I have I an new to scripting so still learning So not sure about arguments or place holders but i did give you all the code. Is there way to run the script on command with a dir that has a space? Like "Program files" cause when i run it in cmd it says Input Error: There is no file extension in "C:\dir\Program" and doesn't show the word files. Hope that makes senseWhen the command is executed from the command line, the paths which CONTAIN spaces must be enclosed in quotes, as stated by Sidewinder. i.e. Quote cscript "C:\dir\dir with space\dir\Backup\zip.vbs" "C:\dir\dir with space\dir\Backup\file.bak" "C:\dir\dir with space\dir\Backup\file.zip" When using the batch file, (or manually setting the variable MY_PATH in cmd), you need to: EITHER change "SET MY_Path=C:\PATH\DIR\" to "SET MY_Path=C:\PATH\DIR" (NOTE: No trailing backslash) OR change every occurrence of "%MY_PATH%\DIR\..." to "%MY_PATH%DIR\..." (NOTE: No backslash after %MY_PATH%" ok I fixed the set path portion of the script and it ran with no errors but the zip file is empty. Thanks again.New and Improved Script v4. Code: [Select]Set objShell = CreateObject("Shell.Application") Set fso = CreateObject("Scripting.FileSystemObject") Set objArgs = WScript.Arguments If objArgs.Count <> 2 Then WScript.Echo "Two Arguments Required ... Job Fail" WScript.Quit End If If Not fso.FileExists(objArgs(0)) Then WScript.Echo "Input File: " & objArgs(0) & " Not Found ... Job Fail" WScript.Quit End If zipFolder = Mid(objArgs(1), 1, (InStrRev(objArgs(1), "\")) - 1) If Not fso.FolderExists(zipFolder) Then WScript.Echo "Output Folder: " & zipFolder & " Not Found ... Job Fail" WScript.Quit End If Set f = fso.CreateTextFile(objArgs(1), True) f.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0) f.Close Set objFile = objShell.NameSpace(objArgs(1)) objFile.CopyHere objArgs(0) WScript.Sleep 1000 Quote ok I fixed the set path portion of the script What does this mean? Do not use the batch file, run from the command prompt by typing: cscript "scriptname.vbs" "drive:\path\file.bak" "drive:\path\file.zip" Replace drive and path with the proper values. Use the quotes, If you do not get the results you're looking for, post back the script you used, the command line exactly as you typed it at the prompt, and any error messages you received. Quote from: Sidewinder on May 28, 2013, 01:02:40 PM New and Improved Script v4. Ok so I ran the script from the command line and from the zip.vbs. No errors were shown. It did create a zip folder but the zip folder was empty there was no file in it. .vbs code is Set objShell = CreateObject("Shell.Application") Set fso = CreateObject("Scripting.FileSystemObject") Set objArgs = WScript.Arguments If objArgs.Count <> 2 Then WScript.Echo "Two Arguments Required ... Job Fail" WScript.Quit End If If Not fso.FileExists(objArgs(0)) Then WScript.Echo "Input File: " & objArgs(0) & " Not Found ... Job Fail" WScript.Quit End If zipFolder = Mid(objArgs(1), 1, (InStrRev(objArgs(1), "\")) - 1) If Not fso.FolderExists(zipFolder) Then WScript.Echo "Output Folder: " & zipFolder & " Not Found ... Job Fail" WScript.Quit End If Set f = fso.CreateTextFile(objArgs(1), True) f.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0) f.Close Set objFile = objShell.NameSpace(objArgs(1)) objFile.CopyHere objArgs(0) WScript.Sleep 1000 Batch code is @echo Compressing your Database now. SET MY_Path=C:\dir\dir with space cscript "%MY_PATH%\Dir\Backup\zip.vbs" "%MY_PATH%\dir\Backup\file.bak" "%MY_PATH%\dir\Backup\file.zip" @pause and where you asked "What does this mean? Do not use the batch file, run from the command prompt by typing:ok I fixed the set path portion of the script. I was referring to what oldun suggested which worked. Thanks again.Quote I was referring to what oldun suggested which worked. Thanks again. OK. So if you have a method that works, is this thread closed? Here is a script I found on the web and adapted. Usage: cscript //nologo Scriptname.vbs "file to zip.ext" "zip file name.zip" cscript //nologo Scriptname.vbs "folder to zip" "zip file name.zip" (use quotes in either parameter if they have spaces) examples create a zip and add a file to it cscript //nologo MyZip.vbs "u:\Text-to-Phone\Bus Girona-Aeropuerto.txt" d:\testme.zip add another file to an existing zip cscript //nologo MyZip.vbs "u:\Text-to-Phone\2-Bus Girona-Aeropuerto.txt" d:\testme.zip create a zip and add a folder (and SUB folder tree) to it cscript //nologo MyZip.vbs "D:\Virtual Machines\ST62K\caches\GuestAppsCache" "s:\Folder with spaces\test.zip" Notes: No error checking; will fail silently if the zip already contains a top level object the same name (i.e. files with the same name must be in different folders) Tested on Windows 7 Professional 64-bit and XP Professional 32-bit Files are compressed Set oFSO = CreateObject("Scripting.FileSystemObject") ToZip = oFSO.GetAbsolutePathName(WScript.Arguments.Item(0)) ZipName = oFSO.GetAbsolutePathName(WScript.Arguments.Item(1)) d=WindowsZip(ToZip, ZipName) Function WindowsZip(sFile, sZipFile) Set oZipShell = CreateObject("WScript.Shell") Set oZipFSO = CreateObject("Scripting.FileSystemObject") If Not oZipFSO.FileExists(sZipFile) Then NewZip(sZipFile) End If Set oZipApp = CreateObject("Shell.Application") sZipFileCount = oZipApp.NameSpace(sZipFile).items.Count aFileName = Split(sFile, "\") sFileName = (aFileName(Ubound(aFileName))) sDupe = False For Each sFileNameInZip In oZipApp.NameSpace(sZipFile).items If LCase(sFileName) = LCase(sFileNameInZip) Then sDupe = True Exit For End If Next If Not sDupe Then wscript.echo "Adding " & sfile oZipApp.NameSpace(sZipFile).Copyhere sFile On Error Resume Next Do Until sZipFileCount < oZipApp.NameSpace(sZipFile).Items.Count Wscript.Sleep(100) Loop On Error GoTo 0 End If End Function Sub NewZip(sNewZip) Set oNewZipFSO = CreateObject("Scripting.FileSystemObject") Set oNewZipFile = oNewZipFSO.CreateTextFile(sNewZip) oNewZipFile.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0) oNewZipFile.Close Set oNewZipFSO = Nothing Wscript.Sleep(500) End Sub Quote from: Salmon Trout on May 28, 2013, 01:33:40 PM Here is a script I found on the web and adapted. This is what I was looking for thank you. Thank you to as well sidewinder and oldun I APPRECIATE you guys taking the time to assist me. |
|
| 1071. |
Solve : recovery disc /flashdrive? |
|
Answer» Morning i have just got a new laptop i have already INSTALLED some programmes.then i read that i should make a recovery disc or flash drive. |
|
| 1072. |
Solve : VBA Error index 33 string, Argument exception was unhandles? |
|
Answer» Public Class Form1 |
|
| 1073. |
Solve : MS SQL get max values for a join? |
|
Answer» I've struggled with a MS SQL QUERY for a while and realize that I have to get help from someone who knows MS SQL (much) better than I do.
Any help would be appreciated! |
|
| 1074. |
Solve : Kill wscript.exe without WMI service permission? |
|
Answer» Greetings all. I'm on Windows 7 professional, and I do not have admin rights. I use many VBScript files, and have no issue there. My issue is that every time I run one of them, the WSCRIPT.exe process is left running. If there gets to be several instances of it the cpu usage spikes, the fan goes into overdrive, and my laptop sounds like a jet about to take off until I manually kill them all using the task MANAGER. This is what I have TRIED. My issue is that every time I run one of them, the wscript.exe process is left running Please post one of the scripts giving you problems. Your problem can be recreated by using the RUN method to start a secondary program/script and waiting for a return that never happens. Does this only happen with WScript/CScript? Just a thought. Quote from: Geek-9pm on May 29, 2013, 03:47:09 PM Greg, If it is your laptop, why don't you have admin rights? Sorry for the lack of info. It is a work laptop, and once we transitioned to W7, all admin rights gone. Most people had them with XP, but now I cannot rely on it if I am writing a script for others. Thank.Quote from: Sidewinder on May 30, 2013, 04:10:11 AM Please post one of the scripts giving you problems. Your problem can be recreated by using the RUN method to start a secondary program/script and waiting for a return that never happens. Sidewinder, here is a SAMPLE script that just pulls some data from a database. Note, I changed the DSN name and query and all that, not that it would mean anything to anyone, but just covering my rear. Anyhow, this script works exactly as it should, but leaves wscript.exe running after it is done. Code: [SELECT] Set cn = CreateObject("ADODB.Connection") Set rs = CreateObject("ADODB.Recordset") userid = inputbox("Enter EID") password = inputbox("Enter password") strSQL = "SELECT SomeColumn FROM SomeTable" cn.Open "DSN=SomeDSN;Password=" & Trim(password) & ";User ID=" & Trim(userid) & ";" Set rs = cn.Execute(strSQL) With rs .movefirst While Not (.EOF AND .BOF) On Error Resume Next MsgBox "Col1 = " & .fields(0) & vbcrlf & _ "Col2 = " & .fields(1) .MoveNext Wend End with rs.close Set rs = nothing Set cn = nothing Wscript.quit Just for grins, I put 'MsgBox "Hello"' in a script, with nothing else, and it did not leave an instance of wscript running, so I wonder if it has something to do with the objects. Just to test, here is another simple one that *does not* leave wscript.exe running. Code: [Select] Set wshShell = CreateObject("WScript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") strFilePath = wshShell.ExpandEnvironmentStrings("%temp%") & "\Test.txt" If objFSO.FileExists(strFilePath) Then 'Delete the file if it exists objFSO.DeleteFile(strFilePath) End if set WriteText = objFSO.CreateTextFile(strFilePath) WriteText.WriteLine("Hello") Set objFSO = nothing Set WriteText = nothing I got it now. I had "While Not (.EOF AND .BOF)" where I should have had only "While Not (.EOF)". I copied from one of my Access VBA scripts without thinking. Thanks all. |
|
| 1075. |
Solve : Help with iterating through cells in datagrid? |
|
Answer» I need help on a program I am currently CREATING as all I am trying to do is read all the cells in the DATAGRID to see if there are any null values and then display a message. I have racked my head around this for ages and I just cant find any CODE to help. Below is the code I am trying to use to search through each cell but this throws an exception that datatable cannot be converted to dataset. Any help would be appreciated. |
|
| 1076. |
Solve : HTML5 canvas doesn't work? |
|
Answer» This is my first time trying to write a "game" in HTML5. I'm following CODE from this: http://www.slashgame.net/2011/06/video-intro-to-html5-game-dev.html |
|
| 1077. |
Solve : .csv to .xls conversion using VBS? |
|
Answer» Hello. |
|
| 1078. |
Solve : How to search a file in the whole drive and take action-batch? |
|
Answer» Hey guys i know i asked questions a lot, but IM new to batch. So i want to make a batch file find a file anywhere in the drive and take action(eg, delete it, rename it.) |
|
| 1079. |
Solve : Modifying Notepad? |
|
Answer» So I want to modify notepad to double as a batch compiler. I am having trouble finding source code. I was wondering if anyone new where I might find some (that I can easily compile). Thanks in ADVANCE. (I looked into Notepad++, but can't open most of the files for some reason)Microsoft Windows Notepad is proprietary software (and thus, you will NOT find source code for it). Microsoft Windows Notepad is proprietary software (and thus, you will NOT find source code for it).I was hoping to make a notepad like program that would have an option (like save or save as) that would say something AKIN to "Compile and run" that way I would not have to open Windows Explorer after saving and find my batch file. I started to write my own, but I know so little of any other language (than batch) that I'm running into some difficulty. I figured it would be simpler to get someone else's code and work my way though making a few edits than to write it from scratch. EDIT: So far (in c++) i have a window, with a menu bar (that doesn't do anything yet), and a giant text box. Still working on saving.Notepad++ has options (from the Run menu) to open the folder containing the file or a cmd prompt in the current folder (which I think may be the containing folder as well). Another option is to Run -> Run... (F5) this command: Code: [Select]$(FULL_CURRENT_PATH) (You can save it and add a hotkey, I used Shift-F5, if you use it a lot) Again, compiling literally does not make any sense with batch files by themselves. There are some third-party tools that 'convert' bat files to exe files (not that one should necessarily use one). What is the end goal? To write your compiled programs from source? I use VISUAL Studio for that. Downloading an IDE/compiler to compile c++ to make your own IDE/compiler is... how do I say... a lot of extra (and IMHO unnecessary) work.Quote from: TechnoGeek on December 10, 2012, 06:53:34 PM Again, compiling literally does not make any sense with batch files by themselves. There are some third-party tools that 'convert' bat files to exe files (not that one should necessarily use one). I guess I wasn't exactly using "compile" correctly. What I ment was that I wanted it to save it as a .bat (directly from my text editor) and run that .bat. That way I could eliminate Windows Explorer all together and overall save TIME. Quote from: TechnoGeek on December 10, 2012, 06:53:34 PM Notepad++ has options (from the Run menu) to open the folder containing the file or a cmd prompt in the current folder (which I think may be the containing folder as well). This is pretty much what I was looking for. Thanks for the help.Glad I could help and that the solution met your needs I believe N++ has a plugin that puts an icon on your toolbar. You just click it and it runs your batch file. I used it on my Windows XP computer with N++ but I just got SWITCHED over to Windows 7 and haven't gotten everything loaded back on at work. |
|
| 1080. |
Solve : turning on my pc automatically? |
|
Answer» Hey guys ! i wanna turn on my PC at night and download some stuff but i can't figure out how to turn it on automatically (win 7, 32bit, SP1 ) ! Help please! Some bios's have the ability to schedule when to turn a computer on etc, does your bios have this? |
|
| 1081. |
Solve : dll problem? |
|
Answer» 'The procedure entry POINT _Z21qRegisterResourceDataiPkhS0_S0_ COULD not be LOCATED in the dynamic link library QTCore4.dll'. What can i do? |
|
| 1082. |
Solve : _Z9qBadAllocv problem? |
|
Answer» The PROCEDURE ENTRY point_Z9qBadAllocv COULD not be LOCATED in the DYNAMIC link library QtCore4.dll". |
|
| 1083. |
Solve : Help debugging VBA for Excel 2000? |
|
Answer» Hey, So, if I were to define each of the variables that I want to be globally shared, I could just define them in a module (under the Modules folder), then make the other sections of code Option Explicit?Yes and No. I'm basing this on Visual Basic 6, which is very similar to the VBA used in Word/Excel. My Experience with macros says it's exactly the same for this; and in Visual Basic 6, global variables had to be declared in a module, using either the "Public" or the "Global" keywords. (They ACTUALLY work the same). Option Explicit is not required, however, it will flag when you use a variable you don't declare. In this case the use of the variable you thought would be publically accessible but wasn't would be flagged as undefined. Quote Would this allow me to reference them whenever? Because I was reading something about variables being destroyed once their respective instance is stopped... Would this work, or am I thinking of this all wrong?Modules do not have "instances"; That is part of why they are required. With userForms, you can have two of the same UserForm present; if you declare a variable within that UserForm, those two instances are going to have distinct copies of that variable that are not the same. With modules, a publically accessible variable is accessible everywhere. Ok. Cool. So that worked for that part of the code. Now I have this properly passing from the userform to sheet1. The next but is on this: Code: [Select]'This ASSIGNS ranges to be used based on credentials. Private Sub Range_Assignment() Select Case PermLevel Case "1" Set ProtectedCells1 = Range("A:N") Set ProtectedCells2 = Range("AT:AZ") Case "2" Set ProtectedCells1 = Range("K:M") Set ProtectedCells2 = Range("AT:AZ") Case "3" AdminPerm = True Case Else MsgBox "There has been an error establishing your permissions. Please exit immediately.", vbExclamation, "WARNING!" End Select End Sub 'This block cells designated to be restricted based on user perm. Private Sub Worksheet_SelectionChange1(ByVal Target As Range) If Not AdminPerm = True Then 'This is the beginning of the first limited range. If Not Intersect (Target, Range(ProtectedCells1)) Is Nothing Then Application.ScreenUpdating = False Set ProtectedCell = Target MsgBox "You do not have permission to access this cell.", vbExclamation, "Insufficient Permissions" Application.ScreenUpdating = True Else Set OriginalCell = Target End If Basically, it checks each time a selection change is made, to see if the new cell is in a restricted range, and bounces back if it is. However, the range assignment is the part I'm having trouble with. The columns that I need to block are infinite, in that there will always be additions to them. So how do I tell it to use a bottomless range? :s I did find a little snippet that will return the last row number of a column/range, but it's just a number (like "14"). So it's not too helpful at the moment either... I'll have to modify a copy of this project, but I think I can probably post it so that you can see a little more what it's all about... (If wanted.)Try using Sheet1.Range instead of just range and use the Union method. Code: [Select] Set ProtectedCells = Union(Sheet1.Range("A:N"), Sheet1.Range("AT:AZ")) for example I was able to do this code: Code: [Select]Option Explicit Sub test() Dim r As Range Set r = Union(Sheet1.Range("A:C"), Sheet1.Range("E:G")) r.Select End Sub And it selected A:C and E:G properly (untested) Modification of your code you could try: Code: [Select]'This assigns ranges to be used based on credentials. Private Sub Range_Assignment() Select Case PermLevel Case "1" Set ProtectedCells = Union(Sheet1.Range("A:N"), Sheet1.Range("AT:AZ")) Case "2" Set ProtectedCells = Union(Range("K:M"), Range("AT:AZ")) Case "3" AdminPerm = True Case Else MsgBox "There has been an error establishing your permissions. Please exit immediately.", vbExclamation, "WARNING!" End Select End Sub 'This block cells designated to be restricted based on user perm. Private Sub Worksheet_SelectionChange1(ByVal Target As Range) If Not AdminPerm = True Then 'This is the beginning of the first limited range. If Not Intersect (Target, ProtectedCells) Is Nothing Then Application.ScreenUpdating = False Set ProtectedCell = Target MsgBox "You do not have permission to access this cell.", vbExclamation, "Insufficient Permissions" Application.ScreenUpdating = True Else Set OriginalCell = Target End If Thanks Techno. I'll slap this in my code and see how it runs. If you feel like having another look at the script as a whole, I'll PM you the link to my pastebin. THANKS! kyle_engineer |
|
| 1084. |
Solve : Java is dead. What now?? |
|
Answer» Given that Java is dead, what do you do now? Guess what? It is not pure Java.So? |
|
| 1085. |
Solve : How to write a batch file? |
|
Answer» Hello all, I am trying to write a batch file that will read the files in a folder on my computer. The path is O:/CustomerInvoices. Inside this folder there are 1000's of folders and each folder has three columns. What I want to do is find all records in the folder that have a date, which is in the third column, that is LESS than or equal to year 2010. I want to take the files that are in each folder and zip them with winrar and place the zip'ed files in separate folder. How do I do this? Please keep in mind that I know very little about batch files.Maybe vb, perl or powershell would be a better solution for you?definitely not a tak for batch. it might be possible... (doubtfully) but it would take a lot of work. im sure there is a better language for this.What type of files are they?Honestly, I don't have much of an idea. Since the number of records pre-2011 isn't going to change, it may be SIMPLER to just do it manually. All of the files should have a modified date..., so you may be able to use that ASSUMING that it wasn't changed since 2010. But there are a lot of variables that come into play with something like this. What I do know, is that building a script/program to do that could BECOME quite time consuming and complicated, and if it's not going to have significant benefit in the FUTURE, it doesn't sound like the right solution. |
|
| 1086. |
Solve : YouTube Throttling Buffer? |
|
Answer» There are many youtube video downloading programs and plugins. I really want to program one that downloads videos at the full speed provided by the ISP. If you load a youtube video, you will notice that it will start downloading/buffering really FAST and then begin to slow once it gets a CERTAIN percent buffered. I've never found a video downloader that circumvents this, so I was thinking of making one. There is one site, youtubemp3pro, that converts youtube videos to mp3s and it somehow is able to do this. The only problem is that that site is only used for mp3s and often has other issues. I know that if I keep clicking ahead in the video, I can force it to finish buffering much faster. How is flash player telling the server to do this? Would it be possible to make a flash program to do this? Can anyone help me figure out how this can be accomplished? Does that site have a partnership with youtube or something? There is one site, youtubemp3pro, that converts youtube videos to mp3s and it somehow is able to do this. Unless these videos are free for all, uncopyright, etc, this is illegal and I wouldnt do it. Taking full albums or even single music videos and making a MP3 collection out of them for free is no different than stealing MP3's thru a torrent. Most the videos on youtube are free for listening/viewing only because advertising pays for them, and others are promo's to get you to buy the CD's or buy the music digitally. As long as its streamed with the painful 30 sec commercials its free for listening/viewing. Once downloaded if its copyright, its illegal because you are now in posession of something you didnt buy to pay royalties on as well as severed the revenue that the identity would get for each time its played and COMMERCIAL pops up that pays them for number of viewings. To answer your question, many ISP's throttle your bandwidth depending on the source and so there might not be a WAY to avoid the slow down that you are having. Such as i had an FTP server and was getting throttled badly. I used this for sending large files between work and home on projects I was working on. I then switched to port 8077 after reading some information on some ISP's blocking or throttling FTP ports and no longer was throttled by my ISP when I used an alternate port. I doubt that you'd be able to use an alternate port to bypass the throttling in this case though. |
|
| 1087. |
Solve : quality of code? |
|
Answer» what is the quality of code for efficient?What are you ASKING/saying? Can you rephrase this?how efficient is a GOOD quality of code? hope this is better to understand |
|
| 1088. |
Solve : Switching from Notepad++ to Sublime (Custom language: PAWN)? |
|
Answer» Helllo. |
|
| 1089. |
Solve : What is this? in lay terms please? |
|
Answer» /*1351386131,173213487*/
if(!JSON.stringify.__fb)JSON.stringify=function(a){function b(){var c=a.apply(this,arguments);if(!c)return c;return c.replace(/[%\u2028\u2029]/g,function(d){var e=d.charCodeAt(0).toString(16);return '\\u0000'.substring(0,6-e.length)+e;});}b.__fb=true;return b;}(JSON.stringify); if(!Object.create)Object.create=function(a){var b=typeof a;if(b!='object'&&b!='function')throw new TypeError('Object prototype may only be a Object or null');var c=new Function();c.prototype=a;return new c();};if(!Object.keys)Object.keys=function(a){var b=typeof a;if(b!='object'&&b!='function'||a===null)throw new TypeError('Object.keys called on non-object');var c=[];for(var d in a)if(Object.prototype.hasOwnProperty.call(a,d))c.push(d);var e=!({toString:true}).propertyIsEnumerable('toString'),f=['toString','toLocaleString','valueOf','hasOwnProperty','isPrototypeOf','prototypeIsEnumerable','constructor'];if(e)for(var g=0;g<f.length;g++){var h=f[g];if(Object.prototype.hasOwnProperty.call(a,h))c.push(h);}return c;}; if(!String.prototype.trim)String.prototype.trim=function(){if(this==null)throw new TypeError('String.prototype.trim called on null or undefined');return String.prototype.replace.call(this,/^\s+|\s+$/g,'');}; var undef,nativeSplit=String.prototype.split,compliantExecNpcg=/()??/.exec("")[1]===undef;String.prototype.split=function(a,b){var c=this;if(Object.prototype.toString.call(a)!=="[object RegExp]")return nativeSplit.call(c,a,b);var d=[],e=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.extended?"x":"")+(a.sticky?"y":""),f=0,a=new RegExp(a.source,e+"g"),g,h,i,j;c+="";if(!compliantExecNpcg)g=new RegExp("^"+a.source+"$(?!\\s)",e);b=b===undef?-1>>>0:b>>>0;while(h=a.exec(c)){i=h.index+h[0].length;if(i>f){d.push(c.slice(f,h.index));if(!compliantExecNpcg&&h.length>1)h[0].replace(g,function(){for(var k=1;k<arguments.length-2;k++)if(arguments[k]===undef)h[k]=undef;});if(h.length>1&&h.index<c.length)Array.prototype.push.apply(d,h.slice(1));j=h[0].length;f=i;if(d.length>=b)break;}if(a.lastIndex===h.index)a.lastIndex++;}if(f===c.length){if(j||!a.test(""))d.push("");}else d.push(c.slice(f));return d.length>b?d.slice(0,b):d;}; var console;if(!console)(function(){function a(){}console={log:a,info:a,warn:a,debug:a,dir:a,error:a};})(); function bagofholding(){}function bagof(a){return function(){return a;};}Array.prototype.reduce=null;Array.prototype.reduceRight=null;document.documentElement.className=document.documentElement.className.replace('no_js',''); (function(a){if(a.require)return;var b={},c={},d={},e=0,f=1,g=2,h=Object.prototype.hasOwnProperty;function i(t){var u=b[t],v,w,x;if(!b[t]){x='Requiring unknown module "'+t+'"';throw new Error(x);}if(u.waiting&&u.special&g)l();if(u.waiting){x='Requiring module "'+t+'" with unresolved dependencies';throw new Error(x);}if(!u.exports){var y=u.exports={},z=u.factory;if(Object.prototype.toString.call(z)==='[object Function]'){var aa=[],ba=u.dependencies,ca=ba.length;if(u.special&g)ca=Math.min(ca,z.length);for(w=0;w<ca;w++){v=ba[w];aa.push(v==='module'?u:(v==='exports'?y:i(v)));}var da=z.apply(u.context||a,aa);if(da)u.exports=da;}else u.exports=z;}if(u.refcount--===1)delete b[t];return u.exports;}function j(t,u,v,w,x,y){if(u===undefined){u=[];v=t;t=n();}else if(v===undefined){v=u;u=t;t=n();}var z=b[t];if(z){if(y)z.refcount+=y;return;}else if(!u&&!v&&y){d[t]=(d[t]||0)+y;return;}else{z={id:t};z.refcount=(d[t]||0)+(y||0);delete d[t];}z.factory=v;z.dependencies=u;z.context=x;z.special=w;b[t]=z;o(t);}function k(t,u,v){j(t,u,undefined,f,v,1);}function l(){var t={},u;for(u in c)if(h.call(c,u))if(b&&!t&&b.special&g)m({},u,t);}function m(t,u,v){v=1;var w=c,x;if(!w)return;t=1;for(x in w)if(h.call(w,x)){if(!b
|
|
| 1090. |
Solve : some questions regards Jade & Jess and others? |
|
Answer» Hi guys, |
|
| 1091. |
Solve : Start a program that uses cmd then enter commands and rename text displayed. VB? |
|
Answer» Ok so basically what im trying to do is have my program start an exe that uses command prompt. This exe will display text after the commands have been entered. I want to CHANGE the text that is displayed. something like .replace("The program is unable to connect to the default blablabla", "The program is unable to connect") but the thing is I'm using streamwriter to display this text within my program. Here have a look. If you don't want to show output from the Command Prompt, then don't use the Command Prompt. No reason to start CMD when all you want to do is run xbmovie. As a console application it will create it's own console and you can easily hook into the standard output streams as you are doing with cmd.Well it's a form application and it's suppose to run cmd because xbmovie is a console application.Quote from: DaftHacker on November 12, 2012, 07:22:29 AM Well it's a form application and it's suppose to run cmd because xbmovie is a console application.cmd has nothing to do with console applications. cmd IS a console application, but it isn't used(inherently) for executing other console applications. Quote from: BC_Programmer on November 12, 2012, 05:52:20 AM As a console application it will create it's own console and you can easily hook into the standard output streams as you are doing with cmd. |
|
| 1092. |
Solve : Audio Thread Question C++? |
|
Answer» One of my friends came to me for assistance with a game he is making. He wants to have BACKGROUND audio for his game that is written in C++ that will loop, but he is having problems. |
|
| 1093. |
Solve : C# Foreach statement not working on datagrid? |
|
Answer» I need help on a program I am currently creating as I am trying to use a foreach statement on a DataGridView & loop through the rows & cells. I have tried the dataview but this doesn’t seem to have the properties to count through cells. I have therefore tried to use a for each statement on a datagridview to loop through the rows, then the cells & count the cells. However, when I run the code & press the BUTTON to execute the loop, the code just bypasses the foreach statement & does not count the rows. I have looked through lots of examples but can’t seem to get this working and its really frustrating. Below is the code with the loop. I need help please sorry, Rowcount should be cellCount & start value was nil. Ive corrected the code belownil isn't a value.... Have you tried setting a breakpoint and inspecting locals?Can you show us the ORIGINAL code. It looks like there should be another statement. You have only one statement inside a compound for loop. I think C# requires both loops to have statements. Maybe I am wrong. It should not hurt to add a null statement.Quote from: Geek-9pm on June 11, 2013, 07:29:47 PM Can you show us the original code.What are you on about?Quote from: BC_Programmer on June 11, 2013, 08:31:50 PM What are you on about?I am wrong. Sorry.Below is the full code for that section when the update button is pressed. The rows show in the table in DV when I check the debugger but not in Dgv1 when the DV is set as the datasource for the Datagridview (Dgv1) Code: [Select] private void UpdateSavebtn_Click_1(object sender, System.EventArgs e) { Mcon.Open(); Dv = new DataView (Movset1.Tables[0]); Dgv1.DataSource = Dv; int CellCount = 0; int Rowcount = 0; foreach (DataGridViewRow dr in Dgv1.Rows) { foreach (DataGridViewCell dc in dr.Cells) { CellCount++; } Rowcount++; } MessageBox.Show(" there are " + CellCount + " cells "); Yeah, That makes sense. There are two statements inside the compound loop. CellCount++; // inside loop Rowcount++; // outside loop I think both are required.set AutoGenerateColumns to true on the DataGridView. AT the moment ive got Cell count and Row count and the data source of the datagridview(DGV1) is set as dataview. The table & rows show in Dataview. I am unable to FIND why the data source is not showing in DGV1 which is why the foreach loops are not beng triggered. The reason am doin this is because I want to loop through the cells of the datagrid and see if there are any null cells. Am using the foreach loop at the moment to see if the cells can be picked up. Ive tried using a Dataview but this doesnt seem to have a property to loop through the cells of the grid. Is is it really that hard to loop through a datagrid & check the values? Quote from: BC_Programmer on June 12, 2013, 03:20:28 PM set AutoGenerateColumns to true on the DataGridView.I have managed to get it going by looping through the datatable & counting the blank cells. I loop through the datarows & then the datacells. The code for this is below. Thanks again for your help Code: [Select] int CellCount = 0; int Blk_Cell = 0; DataTable MovTable = Movset1.Tables[0]; foreach (DataRow row in MovTable.Rows) // Loop over the rows. { foreach (var item in row.ItemArray) // Loop over the items. { CellCount++; if (item.ToString() == "" && CellCount != 4) { MessageBox.Show(" This cell is blank "); Blk_Cell++; } MessageBox.Show(item.ToString()); } CellCount = 0; } MessageBox.Show(" there are " + Blk_Cell + " Blank Cells "); So you never tried AutoGenerateColumns, I take it. When I tested I found the DataGrid was empty from code, and a foreach iterator would skip- the same issue you were having. I changed the AutoGenerateColumns to true and the foreach iteration worked as intended. I was using a BindingList rather than a Database-backed DataTable, though.I did try the AutoGeneratecolumns on the datagirdview but this still DIDNT work. But this is probably because I didnt use a binding list as you mentioned |
|
| 1094. |
Solve : How to use QT Creator?? |
|
Answer» Please tell me tutorials and more.Welcome to CH. I see you have Windows 7. Does this mean you want to use MS C++ compiler to make a QT thing for a smartphone? Not sure want you want. I INSTALLED Visual Studio 2008, Qt 4.8 libraries for vs2008 and Qt add in. I can build Qt projects in VS2008. But it's very inconvenient for me. When I open Qt project in Qt creator it can't compile because can't find qmake.Or maybe this is what you mean. http://www.developer.nokia.com/Community/Wiki/How_to_use_Qt_Creator_IDE Quote Qt Creator is a new lightweight cross-platform IDE that comes in combination with Qt SDK. Qt Creator IDE package is very easy to INSTALL which offers fast and RAPID application cross-platform development. Qt Creator IDE v4.5 includes several new features, but sees the greatest improvement via a concerted effort to increase performance across the entire framework. It's also the first release of Qt under the LGPL.Please provide details. |
|
| 1095. |
Solve : Trying to make a remote app that you can change code anytime, need help. VB? |
|
Answer» So I'm kind of interested to experiment with this, what I'm trying to do is make the program read the code off an uploaded text file that I'm able to change anytime. Well I'm kind of stuck, here is what i got. A couple (a lot of) problems with this:It's just something to simply try out, there is really no point to the program I'm making other then running code from an uploaded file. It's just for fun and not for a serious program.here's some stuff that may help: https://duckduckgo.com/?q=compile+vb.net+dynamically The thing about re-compiling in #4 and #5 isn't quite accurate, I didn't know about the dynamic compilation libraries available .NET before. But the performance considerations still stand, I think.Quote from: TechnoGeek on November 09, 2012, 11:02:57 PM here's some stuff that may help: https://duckduckgo.com/?q=compile+vb.net+dynamicallyI am using visual studio if that helps at all, I'm not using any old VB 6.0 or anything.Quote from: DaftHacker on November 09, 2012, 11:14:37 PM I am using visual studio if that helps at all, I'm not using any old VB 6.0 or anything. VB6.0 was part of visual studio. I can see from your screenshot that you're using VS2012 (running as admin for whatever reason), and maybe not the express version either given some of the menus you have available (unless those are VB specific). I think you'll find if you look that ONE of the first results in that link I posted has a zip file of sample code you can look at, which should work on any recent version of VB.NET.Not having a GOAL on what to specifcially achieve with such a program, and to achieve anything within the limitations of VB itself or any other language you chose to use, with the dynamic creation remotely, I would think that you would want to create a web interface by which to authenticate against, and create your code with, then have a routine on the web server side process and compile your code, and then offer you up a dynamic hyperlink pointing to your finished compiled product for download to the workstation etc that your on. Only catch in this and VB is that I am not aware of any command line compilers for VB where there are numerous ones available for C++ which I work with. On the server side you would need to have a routine that takes your program and compiles it and then references to the compiled product and to do this, you would need to be able to execute a command via command line to compile from within say the Perl script which can interface with the command prompt on the fly and run an external process to that of the Perl CGI etc. Personally this is A LOT OF WORK to create a program through a remote web interface, when its easiest to create the code locally. And would be even more involved if you made a WYSIWYG type interface that makes it so that a person who doesnt even know VB could assemble objects and create VB programs similar to WYSIWYG HTML creation tools. The only programs I have ever created that were changed remotely, where controlled in a way that the code itself did not change. I had a program with a purpose, and within my program I had all the bells and whistles I needed. The program would read in a config file and that config file gave the program the variable inputs to process the correct routines based on simple IF,THEN,ELSE and loops in the functionality. So I wouldnt have to send a new EXE to a workstation or server to perform different tasks, the tasks could be changed by changing the config file and sending that config file over the private network to the systems/servers, and upon scheduled task, trigger and run the way I wanted it to following DIRECTIONS from the Config.TXT file that was in the root of the EXE.VB.NET,C#, and even FSharp expose their compilers as part of the .NET Framework, as part of the System.CodeDom.Compiler namespace. the C# Compiler is the CSharpCodeProvider class; the VB.NET compiler is the VBCodeProvider. These can both be used to compile files or strings into full Assemblies. The compilation unit of .NET is the assembly. The best way to work with an assembly is with either concrete classes or interfaces. Create a class definition that implements that known interface or derives from a known concrete class, and then use the CodeDOM to compile that file into an assembly, using one of the language code providers. The compilation is the same as that performed by Visual Studio. The resulting Assembly is not interpreted anymore than something compiled from Within Visual Studio. The only catch is that you cannot unload dynamically compiled Assemblies unless you load them in a separate AppDomain, but that should only be an issue if your program runs for very long periods and loads a lot of separate assemblies. This can usually be mitigated by simply doing all the compilation needed during application startup. One important piece is that you need a consistent interface. That is, Something that the main program knows to look for in the resulting compiled assembly. Thankfully, you can implement a simple interface in your external file, and use that. Eg. ICodeRunner interface: Code: [Select]Public Interface ICodeRunner Sub Run() End Interface and a program that reads .cs and .vb files and compiles them into Assemblies, which it stores in a List. It then iterates through each assembly and then each Type in each Assembly and looks for classes that Implement the ICodeRunner interface defined in the project, and when it does it instantiates them and runs the interface method. Code: [Select]Imports System.Reflection Imports System.IO Imports System.CodeDom.Compiler Imports Microsoft.CSharp Module Module1 Sub Main() Dim PathUse As String = Assembly.GetExecutingAssembly().Location PathUse = PathUse.Substring(0, PathUse.LastIndexOf(Path.DirectorySeparatorChar)) Dim di As New DirectoryInfo(PathUse) Dim AssemblyResults As New List(Of Assembly)() Dim fi As FileInfo For Each fi In di.GetFiles() Dim result As Assembly = CompileScriptToAssembly(fi.FullName) If Not result Is Nothing Then AssemblyResults.Add(result) Next Dim Runthese As New List(Of ICodeRunner)() For Each iterate As Assembly In AssemblyResults For Each looptype As Type In iterate.GetTypes() If looptype.GetInterfaces().Contains(GetType(ICodeRunner)) Then Runthese.Add(Activator.CreateInstance(looptype)) End If Next Next 'now run them... For Each looprun As ICodeRunner In Runthese looprun.Run() Next Console.ReadKey() End Sub Public Function GetTempPath() As String Dim tpath As String = Path.GetTempPath() tpath = Path.Combine(tpath, Assembly.GetExecutingAssembly().GetName().Name) If Not Directory.Exists(tpath) Then Directory.CreateDirectory(tpath) Return tpath End Function Public Function CompileScriptToAssembly(ByVal ScriptFile As String) As Assembly Try Dim readfilein As New FileStream(ScriptFile, FileMode.Open) Dim sr As New StreamReader(readfilein) Dim allcode As String = sr.ReadToEnd() sr.Close() Dim ExtensionTest As String = Path.GetExtension(ScriptFile).ToLower() Dim AssemblyNames As String() = New String() {"system.dll", "system.Design.dll", "System.Xml.dll", "system.data.dll", "system.windows.forms.dll", "system.drawing.dll", Assembly.GetExecutingAssembly().Location} Dim cp As New CompilerParameters(AssemblyNames) cp.GenerateExecutable = False cp.GenerateInMemory = TRUE Dim outfile As String = Path.Combine(GetTempPath(), "script_" + Path.GetFileNameWithoutExtension(ScriptFile)) If File.Exists(outfile) Then File.Delete(outfile) cp.OutputAssembly = outfile Dim result As Assembly Dim cr As CompilerResults = Nothing Select Case ExtensionTest Case ".cs" Dim Prov As New CSharpCodeProvider() cr = Prov.CompileAssemblyFromFile(cp, New String() {ScriptFile}) Case ".vb" Dim Prov As New VBCodeProvider() cr = Prov.CompileAssemblyFromFile(cp, New String() {ScriptFile}) Case Else Return Nothing End Select If cr.Errors.HasErrors OrElse cr.Errors.HasWarnings Then 'Errors occured during compilation... Else Return cr.CompiledAssembly End If Catch Return Nothing End Try End Function End Module As a console project- then put the following in the Bin/Debug folder, in a file called "RunExample.vb": Code: [Select]imports System imports dynamicrunner Public Class RunExample Implements ICodeRunner Public Sub Run() Implements ICodeRunner.Run Console.WriteLine("Executing from outside the program!") End Sub End Class The End result is the output "Executing from outside the program" indicating that the "text file" was compiled and run. This example uses files as the main source, but the requisite functions (CompileToAssembly) Can also accept plain strings. You could always use a WebClient to download a file to a local path before compiling, as well. This simple implementation doesn't do anything special in the case of errors. (The C# Code that I derived it from uses a special Exception class to represent the aggregation of compiler errors, but I've removed it for brevity in this VB.NET implementation). |
|
| 1096. |
Solve : mini project for MCA? |
|
Answer» Iam persuing my final YEAR MCA i want MINI project in JAVA .I choosen my project as "Weather Report" i wnat IDEA to do my project please hehp me please its urgent.I worked on a similar project in a C# programming book which used RSS feeds in which the C# application was merely just a RSS READER that was getting a weather feed for info to display. Here is some that pertain to Java and RSS http://www.vogella.com/articles/RSSFeed/article.html |
|
| 1097. |
Solve : Variables, and meaningful names? |
|
Answer» I can figure these out to save my life and I only have 45 minutes left |
|
| 1098. |
Solve : ms access relationships diagram? |
|
Answer» Hi i am new to ms access databases, really struggling with my tables relationships |
|
| 1099. |
Solve : Help with while statement in a vb 2010 program? |
|
Answer» Hello everyone, When will the statement i = e be true? In the while statement it has: Code: [Select]i = i + 1This should add 1 to i until i = eAnd is that happening? Quote from: Salmon Trout on October 24, 2012, 07:17:40 AM And is that happening? No, it completely skips the while statement and goes straight to the messageboxAnd what is i? Even if it is a form-level variable, the code won't compile. e is declared as a local variable but it already exists as a PARAMETER to the event method. Ignoring those two problems, The code seems to work mostly as intended. Though if the input value was 50 it actually iterates 51 times. I also wonder why you would use a While Loop to begin with. For...Next seems to do what you are after and more concisely: Code: [Select] Private Sub Button1_Click(ByVal sender As System.Object, ByVal ev As System.EventArgs) Handles Button1.Click Dim e As Integer If Not Integer.TryParse(TextBox1.Text, e) Then MessageBox.Show("Please Enter a Number") End If e = TextBox1.Text For i = 1 To e SendMail() Next i MessageBox.Show("All Mail Sent") End Sub I changed the parameter name to ev, and I used the equally indescriptive name for the textbox, TextBox1. Just has a better ring than TextBox16. I was going to go overboard and call it "txtSendAmount" but then somebody might be able to make sense of what it is for, and we wouldn't want that. I also used Integer.TryParse() simply because I never liked the IDEA of implicit type coercion at least as implemented in Visual Basic. Too unreliable. And more importantly, it can throw an exception which in the original code would have been unhandled. Best to make Exceptions EXCEPTIONAL and avoid causing them to begin with. Another point is that The Try...Catch block in the Button event routine is moot. The only thing that could throw an exception within the try...catch would be the call to SendMail(), but that method already silently catches all exceptions anyway. More importantly, "Pokemon" exception handling ("Gotta catch em all") is not generally a good idea. |
|
| 1100. |
Solve : programming language tutorials-C,C++,MATLAB,LABVIEW,Simulink and more? |
|
Answer» The TUTORIALS section covers RF and wireless tutorials. It include zigbee tutorial,antenna tutorial,GSM tutorial and tutorial on CDMA,satellite,LTE,WiMAX,DSP,Wireless LAN,GPRS,RF measurements,WAVEGUIDE,SCADA,GPS,TD-SCDMA,VSAT,UMTS,microcontroller,Test and Measurement, speech coding,C programming,C++ programming,Labview tutorial,simulink tutorial,Matlab tutorial,VHDL,tutorial,AMPS tutorial,DECT tutorial,software testing tutorial and more topics. |
|