Explore topic-wise InterviewSolutions in .

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.

2351.

Solve : Visual Basic 6.0 Enterprise?

Answer»

Is VB6 Enterprise a recent version of Visual Basic? I can't find a good answer anywhere. Hmmmmmmmmmmmmmmmmmmmm.
Good question.

I use Visual Basic .NET, which is h'awesome.
(Visual Studio)Quote

VB6 has entered Microsoft's "non-supported phase" as of March 2008. ... . ..
Current version of Visual Basic is largely the same language as VB6.
Quote from: monkeytime on February 25, 2010, 05:07:23 PM
Is VB6 Enterprise a recent version of Visual Basic? I can't find a good answer anywhere.


No.

Visual Basic 6 Learning, Professional, and Enterprise Editions were all released in 1998 both stand-alone and as part of Microsoft Visual Studio 6, which also consisted of Visual C++, Visual FoxPro, Visual InterDev, and Visual J++.

The Enterprise Edition doesn't really add a whole lot compared to the professional edition at all- it basically boils down to, If you don't know what it adds, you don't need it; mostly things like the APE (Application Performance Explorer) And Visual SourceSafe, Microsofts rather ostracized source code control tool.

I'm not sure if you can get VB6 Enterprise separate from Visual Studio, come to think of it.

Anyway, gather round for a short history...

there were BASIC versions before it, but BASICA was the first one that was readily available on PCs. this was included with MS-DOS version 3 (and maybe 2 and 1, dunno). this continued until DOS 5, which included QBASIC. During all this, Microsoft also had a BASIC compiler/IDE called "QuickBasic", which was modelled after it's other successful QuickC and... well actually I'm not sure if they had any other "quick" products.... anyway...

With the release if Windows 3.0, the desktop environment was getting popular, but programming it still required an intimate knowledge of C. So, some genius came up with the idea of an easy to use tool that can make designing the User interface a process of dragging buttons and textboxes and so forth on a representation of a form, rather then messing around with CreateWindow() and other calls in the WM_CREATE message in a Window Procedure. To make things even more beginner-friendly, they made the code behind these objects a dialect of Basic. The prototypes were called "Ruby"... (or maybe it was Thunder.. I forget... Ruby was a name used to describe the system by Alan Cooper... so I think the MS worked prototypes might have gone by a different name.

Now, anyway, Visual Basic 1.0 was a godsend to hobbyists everywhere. First off, already versed BASIC programmers needed to only copy paste their code into VB1. with a few changes- the code was 100% compatible save a few select procedures that were more or less DOS-specific. It met with rather astounding success.

With each new release, features were added making it less of a toy language and more of a industrial plaything; For example, Visual Basic Version 2.0 introduced the "Variant" Data type, which became rather prevalent. (with VB.NET there is no "Variant" type, but rather boxed Object types, which work just as well). It also introduced a host of other features, and the professional version included an assortment of "professional" controls like animation buttons and the "ssribbon" control, which by today's standards would be called a toolbar. (and a weak one at that). It also added internal support for databases through Object techniques- the first glimpses of database code were seen:

Code: [Select]Dim dset as DynaSet
Dim DBName as String,DBConnect as String
DBName = "\\SALES\PUBLIC\NEW\CUSTDB_1"
DBConnect="UID=JAN;PWD=CD"

Set db = OpenDatabase(DBName,False,False,DBConnect)

Set DS = db.CreateDynaSet("Select * From Customers")

Do While Not DS.Eof
Print "First Name:";DS("First_Name")
Print "Last Name:";DS("Last_Name")
Ds.MoveNext()


Loop


Anyway, so VB2 brought forth the idea that maybe VB would make a good database access type language as well.

VB3 rolled around, and the OLEClient Control, which used to be a separate VBX (Visual Basic eXtension) was now part of the run-time. On the other hand, nobody uses the bloody thing... not sure what made them decide to do that. Not sure what Else VB3 offered, since I didn't have to use it seriously. It did add the CreateObject() Function, if I recall, which has become nearly ubiquitous in VBScripts, at the very least. It might have had GetObject... but I don't think so.

VB4 brought two major things to the table. First- it was able to create both 16-bit, and 32-bit applications, and came with a 16-bit and a 32-bit version of the IDE (and also the runtime). the second major addition was the creation of Class Modules, which could be used to create your own objects; and VB now supported the creation of OLE servers in both DLL and EXE form (OLE is pretty much synonymous with ActiveX... in fact, ActiveX is really just a fancy name for OLE)

Visual Basic 5.0 added a whole new facet: the IDE was completely redesigned, additionally the crappy Extensibility framework that VB4 offered was thrown away and a new one was written that didn't SUCK quite so badly. the Interface itself now used the common MSOffice CommandBars, and used a MDI interface rather then the SDI interface that VB1-4 used. (the SDI interface was still accessible via the Options dialog). The main things VB5 added were support for the creation of ActiveX DLL and EXEs as well as ActiveX Controls. These features in addition to the newfound ability for Interface inheritance were a boon for developers. Additionally, the language added in rich improvements to User Defined Type limitations.

VB6- by all appearances, seems the same as VB5 in nearly every facet. they added a good number of useful features, fixed a lot of annoying VB5 bugs, and for some reason you can give VB6 a XP/Vista/7 Manifest and let it use Luna/Aero themes but for some reason VB5 balks. Also most of the common controls were a million times better with VB6 (ALTHOUGH I don't use them anymore, having found VBaccelerator, which hosts similar controls that are a million times better then those... there's .NET stuff there now, too, I think).
Oh wait, I lied. VB6 added Webclasses.

*crickets chirping*

My thoughts exactly.


Quote from: Geek-9pm on February 25, 2010, 08:47:57 PM
Current version of Visual Basic is largely the same language as VB6.


Um... no...

Visual Basic .NET is a fine language, and the .NET framework has almost everything you could ever need; heck, it provides stuff that TAKES months to get working in VB6.

However- while the syntax is similar, it isn't the same language. For example, you could use an "Instr" function in VB.NET, but that's just a compatibility kludge. the actual way would be to use appropriate method of the string object. The great thing about .NET is everything is an object... you can do something like:

"This is a string".Reverse()

(well, I think, not sure if the String object has a Reverse Method, but you get the idea.)
with VB6, that same code gives you:

Expected: line number or label or statement or end of statement


It removed a lot of "cruft" from the language, but it made migrating existing programs - you know, the millions of core business objects and applications developed in VB6 - impossible without a complete rewrite. the "migration tools" were a complete joke- they should have admitted from the start that it was a completely different language rather then try to hold on to the delicate fiber that was their credibility at the time and say "oh, it's mostly compatible" since they were secretly saying "for a hello world program" after that.

I'm not too sure about the differences between the original .NET 2001, 2003, 2005, or 2008... well, I recall that they added the "my" namespace to 2005... which is like a punch in the gut. it's like saying, "oh, here, we know this framework is confusing, here, let us do the hard work for you by creating a global namespace that you can suckle from"

last, you cannot say a language is "largely the same" when a keyword has a completely different name.

"Static" had meant the same thing from QuickBasic to VB6; and yes it was a stupid procedure modifier that all local variables persist between calls... (same for declaring a variable with "Static" rather then "Dim".)

However- and really, I have no probelm with this myself- the keyword Static changed entirely- now it meant that a method was a method of the class rather then the instance. Which is actually a great thing since class methods were simply impossible to create before .NET. But they still redefined the meaning.

Once you redefined a keyword that has been in the language for years, your no longer working on a same language. Like I said, VB.NET is a fine dialect of Basic, but it is not friendly to developers who are used to previous versions (well, to be more precise, I should say developers who want to migrate code from previous versions).

Anyway... err, there you are, a short history of Visual Basic.BC_Programmer,

Thank you for the lecture. Your check is in the mail.

On point you may have overlooked. At one point in time the MS BASIC software was a classic line by line language. Then when it went visual it also became event-driven. That means that the program might not do anything if there is no event. It just sets there. And you cold create a from with some text in it with no code to speak of. It was now a template language. Just fill in the blanks.

Quote from: Geek-9pm on February 25, 2010, 10:12:47 PM
BC_Programmer,

Thank you for the lecture. Your check is in the mail.

On point you may have overlooked. At one point in time the MS BASIC software was a classic line by line language. Then when it went visual it also became event-driven. That means that the program might not do anything if there is no event. It just sets there. And you cold create a from with some text in it with no code to speak of. It was now a template language. Just fill in the blanks.



good point, that would be with VB1 the change to an Event Driven language was made.

Really you cannot fault it; I mean, even C when used to write a windows program is purely event driven, but you have to parse the messages yourself. Sure, your winmain() routine was still executing (in a message pump) but this was rather insignificant- you process messages and respond to them, just as you do to events in VB (or really nearly every language nowadays).

Also you can write console applications with VB6, so it's not a strict requirement to be event driven.

Quote
It was now a template language. Just fill in the blanks.

Now this is evidently a cold observation; Is removing the mundane task of Windows Message Loops and Accelerator Translation and Resource editing really that bad? Is it in any way different to the way people will write a program template and use that from then on? Not really. Just takes away the monotony.

Quote
Now this is evidently a cold observation; Is removing the mundane task of Windows Message Loops and Accelerator Translation and Resource editing really that bad? Is it in any way different to the way people will write a program template and use that from then on? Not really. Just takes away the m

What I wanted to say was that it got to the point that the code was hidden from the person that did the application. Yes, you did have to put in something in a little box for OnMouseOver or OnEventWhatever and it world invoke something you had to identify. But the application programmer would not ever see a full line-by-line source code of his project, unless he made a real effort to get it. This was a sea change from traditional languages. And yes, you could do console programs, but the GUI interface changed forever the way a working programmer would conceive an idea.It's no different then it used to be...

you generally didn't modify printf() or sscanf() or other run-time functions...

The scope of what encompasses the framework itself changed.

Actually, come to think of it, my customized "New Project" in VB consists of 3 classes as well as a form with several controls, and it doesn't even do anything... Nowadays for programming XP/Vista/Win7 Properly with VB Classic you need a of extra stuff, too. Like manifests and API declarations for the common controls library and so forth.

Oh, and that whole "you cannot see the code" thing changed with .NET. you can see the code that generates the form and it's controls and hooks them to the event procedures. (not the ASM code, of course, since the ASM for IDL will be different on different processors, silly)Quote from: BC_Programmer on February 25, 2010, 09:28:23 PM
Microsoft also had a BASIC compiler/IDE called "QuickBasic", which was modelled after it's other successful QuickC and... well actually I'm not sure if they had any other "quick" products....

QuickPascal
Quote from: Salmon Trout on March 07, 2010, 03:31:13 PM
QuickPascal

NO. QP is only for MS-DOS.
Quote
D:\BIN\qb>QP

WARNING: Microsoft QuickPascal has been tested for use
only with the MS-DOS and PC-DOS operating systems.
Your use of this product with another operating system
may void valuable warranty protection provided by
Microsoft on QuickPascal.

...Press any key to continue
Quote from: Geek-9pm on March 07, 2010, 04:13:33 PM
NO. QP is only for MS-DOS.

Where did I say otherwise?
Quote from: Salmon Trout on March 08, 2010, 12:09:28 AM
Where did I say otherwise?
Sorry, you did not say that.
Both QBASIC and QB can run as command line programs in most windows versions with no nag messages. But QP gives a error message. This might indicate that MS was not too confident about their Pascal.

There was a Quick C.

Quote
Microsoft QuickC was a commercial integrated development environment (IDE) product engineered by Microsoft for the C programming language, superseded by Visual C++ Standard Edition[1]. It main competitor was Turbo C[2].
http://en.wikipedia.org/wiki/QuickC

But there was never a quick PL/1 (sigh)

QuickBASIC 2.0 gives the same message...

And None of them work in the recent 64-bit versions of windows

Also I find it ironic that you would mention that message, since it's probably originally designed to show for non MS-DOS or PC-DOS operating systems, such as DR-DOS.

2352.

Solve : VB get filename or edit text?

Answer»

hi guys,

i am USING this code to grab file names:

My.Computer.FileSystem.GetFiles( _
My.Computer.FileSystem.CurrentDirectory, FileIO.SearchOption _
.SearchTopLevelOnly, "*.gif*", "*.jpg*", "*.jpeg*", "*.jif*")

when i load this into a list box it appears as c:\docu~\visua~\filename.ext

what im trying to get is just the filename or filename.ext, is there a command to get this or can i somehow edit the string?

any help will be great avoid using the My namespace if you can.

I really have absolutely no idea why it would return the short name.
the main issue here is that you are being given a collection of strings rather then a more helpful array of files.

you could use Directory.GetCurrentDirectory.Getfiles() to RETRIEVE files, but you can only specify a single file mask.

Not to fear, however- it's rather easy to slap together a small FUNCTION that does what the My Namespace function does but giving back FileInfo Objects rather then short path names:

Code: [Select]Sub Main()
Dim useMasks As String = "*.jpg|*.jpeg|*.jif|*.gif"

Dim filesgot As ArrayList
Dim loopfile As FileInfo
filesgot = GetFilesDirect(New DirectoryInfo(Directory.GetCurrentDirectory), useMasks)
For Each loopfile In filesgot
Console.WriteLine(loopfile.FullName)


Next
Console.ReadKey()
End Sub

Private Function GetFilesDirect(ByVal StartFolder As DirectoryInfo, ByVal Filemasks As String, _
Optional ByVal SearchOption As SearchOption = SearchOption.TopDirectoryOnly) As ArrayList
Dim returnArray As ArrayList = New ArrayList
Dim filemaskarr() As String = Filemasks.Split("|")
Dim I As Long
For Each fInfo As FileInfo In StartFolder.GetFiles("*.*", SearchOption.TopDirectoryOnly)
For I = 0 To filemaskarr.Length - 1
If fInfo.Name Like filemaskarr(I) Then
returnArray.Add(fInfo)
Exit For
End If

Next I
Next fInfo
Return returnArray
End Function

The "Main" Function here does essentially what you want- enumerates the matching files in the currentDirectory. Just copy the function to your code (in a blank area, and not inside another function, obviously) and call it in a similar fashion instead of using the My namespace.

Now, you ask "how does this help? I want just the filename!"

WELL, as you can see in my Main() routine, I use the "FullName" property of the FileInfo Class. In your case, you could use the "Name" property to get the Filename.ext, or the "Extension" property to get the file extension. using both together and some string manipulation, it's rather easy to get just the basename:
(Loopfile in the following is a "FileInfo" Object)
Code: [Select]loopfile.Name.Substring(1, loopfile.Name.Length - loopfile.Extension.Length - 1)
Yay it works!

sorry for late reply was too AMUSED by my 90% program haha.

Thanks BC

2353.

Solve : exporting picture from VB into word?

Answer»

Hi,

i have a form that grabs all PICTURE files in a folder and displays them one at a time in a picture box and allows the user to INPUT text in a RICH text box.

What IM trying to do is export the picture into a word document with the text from the rich text box under it.

Is this even POSSIBLE?

Thanks for your help

2354.

Solve : increase memory allocation c++?

Answer»

Hey,

im having ISSUES declaring

const int MAX = 280000;

int main()
{

string word[MAX];
.
.
.
}

I get an ISSUE of STACK overflow, ive been TRYING to change the memory allocation but my syntax keeps failling, is this because you cant change memory allocation of a constant? im confused.

Any help would be great.

ThanksPlease disregard this i found out...

string *word = new string [280000];

thanks

2355.

Solve : advantages of sequential processing?

Answer»

can ANYONE tell me ADVANTAGES of SEQUENTIAL processingFor the programmers who don't know what sequential processing is:
sequential processing

2356.

Solve : How to show include data from a directory one by one??

Answer»

I have put some PHP content in a directory named "DATA" and i WANT to show them ONE by one through next and previous button

i am try to do this by this code

foreach (glob("data/*.php") as $filename) {
INCLUDE($filename);
}
?>

but it is showing all the content at a same page i want to do it one by one through next and previous button

Previous Page[/url] Next Page[/url]

2357.

Solve : JAVA Programming (Platform)?

Answer»

I have done programming in dBaseIV, Access and VB. In these programming languages I was using programing platforms like Dot Prompt and design screens. However, now that am learning programming in Java I have installed the software but I cant see the platform except receiving massages that the software is installed.

Please let me know where I can test Java programming codes....Hello there EK.

To develop and test programs in Java (source code), you have to download the Java Development Kit (JDK, formerly referred to as JavaSDK (Software Development Kit)).

Download it here.
Scroll a bit down and you will find JDK 6 Update 18 (JDK or JRE), which is the JDK you need.

There are two steps required:

I. Compiling your code (.java)

If you installed the JDK, you will find the (javac.exe) javac executable (compiler) under the default directory of the JDK (usually c:\jdk, otherwise it will be in the JDK installation dir you put it in; please install the JDK in a seperate directory than the JRE dir).
This (javac) is what you need to compile your files (before you can run them of course).

.java is the code, .class is the compiled file (e.g. HelloWorld.java -> javac -> HelloWorld.class).
To test your code, you need to compile the .java file, which is why I was explaining the previous.

In short, download the JDK, locate the javac.exe, go to Windows commandline and run the following:

cd x:\path\to\jdk\

Commandline will now display:
x:\path\to\jdk

To compile, run the following (assuming that javac.exe is in this dir):
javac x:\path\to\yourfiledir\test.java

After it has been compiled (when it's compiled, commandline will return to default prompt),
the file will reside in x:\path\to\yourfiledir\, named x:\path\to\yourfiledir\test.class

By default, the compiler puts each class file in the same directory as its source file. You can specify a separate destination directory with -d (e.g. javac -d


II. Running your code (.class)

You can test your code in 2 ways.

1. Commandline-wise, through the java.exe executable (usually found in C:\WINDOWS\system32 ;this path has been added to Path in the environment variables, so all you have to do to run your .class program is to open up Windows commandline and run the following command:

java -cp x:\path\to\yourfiledir yourfile

java.exe will assume that yourfiledir is the directory to search for the particular yourfile.class java class thanks to the -cp (classpath; absolute directory) command.
It will also assume that yourfile translates to yourfile.class, so don't specify the .class extension in the command.

2. IDE-wise, comes with GUI Text Editor, compiler, debugger, everything.
Two popular ONES are IntelliJ and NetBeans (others are JBuilder, etc. etc.)


Good luck.
If any questions, you may post them here.

Treval


Hi Treval!

Have just seen your massage... am following the steps will post you how it goes...

Thanks
EKAlright man.
I'll read about it when you post it.

Treval
Hi Treval!

I have problems understanding your syntax. (cd x:\path\to\jdk).

I have done the following:

1. Downloaded Java JDK13
2. Installed it in c:\jdk
3. Located javac.exe that its in C:\jdk\bin
4. ................

Your notes are confusing me. I don't know if am suppose to copy the javac.exe file to c:\jdk\ or am suppose to run the javac.exe before I come to compile my programs.

Pls help.

EdgarHm. Sorry if I confused you.

- The syntax 'cd' is for Windows commandline ('DOS'), which means 'change directory'.
- 'x:' is a general representation of your drive (for EXAMPLE, it can be c:), so REPLACE x: with the drive letter
of your drive.
- path/to/jdk is yet another generalisation of your path. It is just illustrating the path to the jdk (so you have to replace 'path/to/jdk' with 'c:\jdk\bin' for example)

javac is the compiler. You need it to compile your .java written code before you can run it.

The steps are as usual:

1. Write your java program in notepad
2. Save as myprogram.java
3. Open up Windows commandline (DOS) and type cd c:\jdk\bin then press enter
4. The commandline should now SHOW "c:\jdk\bin>" with a blinking cursor
5. To compile your java program, have javac compile it by passing the path of your
java program to the javac compiler with the -cp or -classpath (classpath) switch.
Here is how you do it:
If your .java program you've just written resides in c:\Edgar\java\myprogram.java, then write this in commandline as the following step:
javac -classpath c:\Edgar\java\myprogram.java
6. To run your java program that you've just compiled, write the following in commandline:
java -classpath c:\Edgar\java\myprogram

That's it!
If my steps didn't help you, then please read this helpful short tutorial:
tutorial


Treval

2358.

Solve : What notation is it??

Answer»

Can anyone tell me what kind notation the following PICTURE using?


I found it at json.orgI'm going to go out on a limb and say JavaScript Object Notation (JSON)@jhuns

Thank you for your reply.
I finally found the ANSWER after I received the book from Amazon.
That is one kind to diagram, which is always used to describe the syntax.
It is called Syntax DiagramHere is one used to define the syntax in PASCAL.
http://www.augustana.ab.ca/~mohrj/courses/2000.fall/csc370/lecture_notes/images/ebnf.jpg
These diagrams are helpful to LEARN a computer language.

Quote

Syntax diagrams (or railroad diagrams) are a way to represent a context-free grammar. They represent a graphical alternative to Backus-Naur Form or EBNF. EARLY books using syntax diagrams include the "Pascal User Manual" written by Niklaus Wirth [1]
http://en.wikipedia.org/wiki/Syntax_diagram
Some books may have BNF and not railroad.
Quote from: Geek-9pm on March 17, 2010, 03:21:53 PM
Here is one used to define the syntax in Pascal.
http://www.augustana.ab.ca/~mohrj/courses/2000.fall/csc370/lecture_notes/images/ebnf.jpg
These diagrams are helpful to learn a computer language.
Some books may have BNF and not railroad.


Thank you.
2359.

Solve : Base 10 to Base 2?

Answer»

What's the easiest formula to use to convert base 10 to base 2? Comparison with descending powers of two and subtraction

Let's convert the decimal number 156 to binary. What is the greatest power of two that will fit into 156? Since 128 fits, write a 1 for the leftmost binary digit, and subtract 128 from your decimal number, 156. You now have 28.

Move to the next lower power of two. Can 64 fit into 28? No, so write a 0 for the next binary digit to the right.

Can 32 fit into 28? No, so write a 0.

Can 16 fit into 28? Yes, so write a 1, and subtract 16 from 28. You now have 12.

Can 8 fit into 12? Yes, so write a 1, and subtract 8 from 12. You now have 4.

Can 4 (power of two) fit into 4 (working decimal)? Yes, so write a 1, and subtract 4 from 4. You have 0.

Can 2 fit into 0? No, so write a 0.

Can 1 fit into 0? No, so write a 0.

Since there are no more powers of two left, you are done. You should have 10011100. This is the binary equivalent of the decimal number 156.

The answer is the remainders read from the bottom up. Hi,

You could try this example , that algorithm is the best in my opinion:

http://mathbits.com/mathbits/compsci/Introduction/frombase10.htm

Something like : 31 is ?

31 : 2 = 15 r 1
15 : 2 = 7 r 1
7 : 2 = 3 r 1
3 : 2 = 1 r 1
1 : 2 = 0 r 1

So 31 = 11111 ( hmmm one more example , a better example could be... shown)

Let's say.... 20

20 : 2= 10 r 0 (20 = 2 * 10 + 0 )
10 : 2= 5 r 0 ( 10 = 2*5 + 0 )
5 : 2 = 2 r 1 ( 5 = 2*2 + 1 )
2 : 2 = 1 r 0 ( 2 = 2 * 1 + 0)
1 : 2 = 0 r 1 ( 1 = 2*0 + 1 )

So 20 = 10100

Execute those divisions until 0 (as floor) appears in front of r , and your number is constructed from "r" part ( remainder) which should be read from bottom to top.

In those link ALSO this algorithm is explained , may be better how i do it. (any way this algorithm could be used for any number base conversion )

Regards,




Easy? Use a calculator.
http://www.tucows.com/preview/414618
Or a table.
http://www.ascii.cl/conversion.htm
No formula is needed.
Binary numbers has the same value as decimal numbers.

OK. Just joking. But is seems rather SILLY to ask on a forum.
Can't you do this is your head?
1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 and so on. In my opinion you should know how that algorithm works, so that if necessary you could program it, and it will be computer's job to calculate, ", 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 and so on." but you should know how to tell it to do it.

I believe that this question is really a good one.

Then let's clarify the question.
An input source has some numbers in ASCII format that represent a number using base ten, sometimes called decimal. We shall change this sequence of symbols into a binary number that represents the value of the visible symbols that most humans understand. (Assembly language programmers are almost human, but that is another topic.)

What have to understand the visible representation of number ant the absolute binary value.

In this example we suppose the the number does not have a decimal point or does not have anything to the right of the point. And the number is less that 32,768 if we want to limit this to a 16 bit operation.

First, we chose a register or variable in memory large enough to hold the binary value. In this case a two byte memory or register. We start with a value of zero. Next we start to the far left of the string of decimal symbols. We subtract 48 to convert the ASCII symbol to a corresponding absolute binary value. This will be done for each digit in the string. but before we do the cent digit, if there is another, we multiply our temp value by ten before we add the value of the current digit.

Using a PSEUDO code, it might look link this.
Code: [Select]set 16bit location to zero. call is result
set a Bolean to false and call it done.
while NOT done
get current digit, subtract 48, store in a temporary place. call it temp
multiply result by ten
add temp to result
incitement digit pointer
if pointer beyond last digit then let done be true
loop
use result as binary value.
Now then, do you want to represent the binary value as a string of 1s and 0s ?
That's another exercise.

But did you want to BCD? Packed or unpacked?

Do you need to understand this? I don't know. You can go through life and be happy without needing to understand the reson roe using numbers systems other that base ten.

We must understand, however you represent a number, it is a number and a number is number.
for example the value fifteen and be:
15 base 10
0F base 16
0000 1111 base two
or even like this:


If you are using any fomr/mutation of BASIC you can use BIN$(x).

So, to make a QUICKBASIC base10 --> base2 program, use something like this:

CLS
INPUT "Enter base 10 number:", x
PRINT "Binary form: " + BIN$(x)
DO WHILE INKEY$ = ""
LOOP
ENDQuote from: Fleexy on March 19, 2010, 05:05:19 PM

If you are using any fomr/mutation of BASIC you can use BIN$(x).

So, to make a QuickBASIC base10 --> base2 program, use something like this:

CLS
INPUT "Enter base 10 number:", x
PRINT "Binary form: " + BIN$(x)
DO WHILE INKEY$ = ""
LOOP
END


"BIN$" or "BIN" functions do not exist in QBASIC, QuickBASIC, or any dialect of Visual Basic 1 through 6.

It's probably exclusive to a single dialect, such as RealBasic.


here are two functions that I never use that Ifound in one of my modules (VB6):


Code: [Select]Public Function BinaryToDecimal(ByVal BinValue As String) As Long
Dim lngValue As Long
Dim X As Long
Dim K As Long
K = Len(BinValue) ' will only work with 32 or fewer "bits"
For X = K To 1 Step -1 ' work backwards down string
If Mid$(BinValue, X, 1) = "1" Then
If K - X > 30 Then ' bit 31 is the sign bit
lngValue = lngValue Or -2147483648# _
' avoid overflow error
Else
lngValue = lngValue + 2 ^ (K - X)
End If
End If
Next X
BinaryToDecimal = lngValue
End Function


and the reverse:

Code: [Select]Public Function dec2bin(mynum As Variant) As String
Dim loopcounter As Integer
If mynum >= 2 ^ 31 Then
dec2bin = "Number too big"
Exit Function
End If
Do

If (mynum And 2 ^ loopcounter) = 2 ^ loopcounter Then
dec2bin = "1" & dec2bin
Else
dec2bin = "0" & dec2bin
End If
loopcounter = loopcounter + 1
Loop Until 2 ^ loopcounter > mynum
End Function

Oops, sorry, got it mixed up with HEX$ and OCT$. Disregard my post please.

...probably because I made my own sub BIN$ (can't find it now, must be on my other computer)
2360.

Solve : Need help with C++ code?

Answer»

So what's wrong with this code guys ?


#include ;
#include ;
using namespace std;

int main()
{
float Amount ;

cout << "enter how much you want to pay";
cin >> Amount;

if (Amount>=1500);
cout << "CLASS A";

else if (Amount>700 && Amount <=1499);
cout << "Class b";

else if (Amount>500 && Amount <= 699);
cout << "Class c";

else if (Amount<500);
cout << "ro7 erkab toktok "<
else
cout << "roo7 moot" << endl;

system ("pause");
return 0;


}I know nothing about C++, but I got this version to compile with Dev-C++

Code: [SELECT]#include <iostream>;
#include <cmath>;
using namespace std;

int main()
{
float Amount ;

cout << "enter how much you want to pay";
cin >> Amount;

if (Amount>=1500)
cout << "Class A";

else if (Amount>700 && Amount <=1499)
cout << "Class b";

else if (Amount>500 && Amount <= 699)
cout << "Class c";

else if (Amount<500)
cout << "ro7 erkab toktok "<<endl;

else
cout << "roo7 moot" << endl;

system ("pause");
return 0;


}

GOOD luck. SideWinder's corrections should fix the various syntax errors.

(semicolons are not necessary on any PREPROCESSOR command, such as #include- it just adds an empty statement (no harm done either way)).

a comment on the logic flow. Consider for a moment, the conditions of the various else if's.

a quick example: the first one checks if the amount is larger then 1500. if so, it prints "Class A" and the remainder of the else's is ignored.

This means that the only way the other Else conditions will be evaluated WOULD be if the value is already less then zero- this makes your second check, (Amount <=1499) redundant, since that is a "Known" fact in the else. the same logic applies with each condition, all the way down to the standard "else" which will never be executed at all.

2361.

Solve : Computer randomly switching between active programs?

Answer»

I'm not sure if this question belongs in this forum or not because I'm not sure what is causing it. If I have internet explorer (with several tabs) open and also Outlook the computer will randomly switch to EITHER another open tab or back to Outlook while I'm working. It happens also if I am working on a Word Document. I'm not sure where to start LOOKING for the problem. I assume you are using XP? as this issue normally affects that...

1.
Hace you turned on speech recognition, but not configured it? I which CASE you just need to disable or configure it correctly, see the microsoft support link below.

Programs May Start, Quit, Lose, and Gain Focus Randomly
http://support.microsoft.com/default.aspx?scid=kb;en-us;313176&Product=winxp

2.
PowerToys for Windows XP is a free utility from Microsoft which give you addition power and control for tweaking XP, you could use that to prevent switching (as another option):
http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx

Install TweakUI
Start it up and go to: General > Focus > and check the "Prevent applications from stealing focus" box.

3.
As a final option - there is a tweak fix is from kellys-korner-xp to Prevent Programs from Stealing Focus and comes with an Undo:
http://www.kellys-korner-xp.com/xp_tweaks.htm

Line 66. (r-h column) Prevent Programs from Stealing Focus - Undo
To use the VBS Files: Download .vbs file and save it to your hard drive (you may want to right click and use Save Target As). DOUBLE click the vbs file. You will be prompted when the script is done.


NOTE any scripts/registry editing can be dangerous, so always check what it is entering first (open with notepad and read them yourself if needed), these are labeled pretty safe and come with undo incase. I suggest trying the Microsoft options first as they would be a safer option. It's also better to work out why and resolve the problem, rather than just patch the issue. Hopefully it's just the speech recognition issue.

Did this just start? If so, your first step is to run a full malware scan with BOTH your anti virus utility AND MalwareBytes. Frequent focus changes are often the work of Malware.I just completed "turning off text" and I will see how it works. Thank you!

2362.

Solve : String comparison?

Answer»
I would like to COMPARE two .cs (C# code) files and have the differences be marked in yellow.. or some such.
Basically I followed a tutorial and the end result of the code done in the video is not the same as mine.
The source file is provided. I want to compare this source file to mine and SEE the differences.

Call me lazy. =P

Treval
Using a Linux or Unix OS allows for this compare easily using the diff command.
Two useful flags you can specify when COMPARING files are -b (ignore blanks) and -i (ignore case).

Quote
diff -b -i cookies.old cookies.new

Do you have to try WRITE a program to do the compare and want HELP with the code?
If not why reinvent the wheel?

ExamDiff is a freeware Windows 95/98/Me/NT/2000/XP/2003/Vista tool for visual file comparison.
http://www.prestosoft.com/edp_examdiff.aspThanks man.you could also use the fc command (file compare), or WinDiff (in the SDK).
2363.

Solve : Excel formula??

Answer»

I would like a way to do an if-condition (filter) based on a particular value in an excel sheet (2007).
Consider the following sheet:
my sheet

I would like every occurence of DELL and MOO to not be done 21% tax on. I would like them to be done 50% tax on, while leaving the TOTAL of DELL/MOO untouched. Only the second column (TAX 21%) should be calculated as 50% for DELL/MOO occurences. So this means:

DELL 100 50 121

Any ideas?

Thanks
I figured it out.

syntax Excel if condition:
if(condition;output_if_true;output_if_false)

e.g.:

=IF(B2="MOO";C2/100*50;C2/100*21)

For the last column I used:

=C2+(C2/100*21)


Treval
That's really cool. I never knew that before! I'm GLAD you discovered this on your own, and I'm even happier that you shared this with us. Now, if someone has the same ISSUE, they can just do a forum search and find your post.Yep, the good ole IF-THEN-ELSE logic of an IF statement, very effective for such situations.

By the way, I'd like to know your technique to putting that spreadsheet on the web. Did you save the Excel in HTML format, and then upload it to a Google account? I went to docs.google.com logged in as my gmail account, then selected the option to PUBLISH my sheet as HTML. It then spits out a link where the sheet has been converted to HTML. Pretty much it.What do you guys think of this cool FUNCTION? =P

=VLOOKUP(max(wages);review2;2;FALSE)

It returns the highest number in a list of numbers called wages, looks it up in the range between 50 and Sally and returns the name that matches the max number. =)
In other words:
=VLOOKUP(max(listOfNumbers);listOfNumbersAndNames;whichColumnToDisplay;returnExactOrApproxResult)

the sheet

The downside is that VLOOKUP only looks up values in the left column.. forcing me to put the numbers on the left. I'll have to figure out a way to do this if the left column contains names (in other words, the sheet I showed, but vice versa).

Treval

2364.

Solve : Determining partition sizes, and computer models in DOS??

Answer»

I'm working on building a script to use with WinPE to launch GHOST, and one of the PARAMETERS is to set the partition to put the image on to. It's not a problem if you're USED to doing it manually and you know what partition it needs to go onto. The purpose of this script though is for people that may not have the familiarity with it to just put the correct partition in. My question is, is there a either a way to list the partitions on a hard drive for the user to select? Alternatively, a better more "hands off" approach would be for the script to automatically determine the largest partition and just use that one with Ghost.

My second part of this question is, is there an easy way to figure out what model computer you're using from within the script so that possibly I could forgo the user selecting which Ghost image to use? The computers I work with are Dell's and HP's, and they've been coming with Vista so far. This is helpful, because as of right now only the files in the folder containing the images are listed, not any description of them. There is an option to view the readme that has the description of the files, but it requires the user to read it carefully, and is not full proof.

Thanks for the help.You may want to do research on how to read the partition table. There is no easy way to do this. And with Vista there is a new method used to identify the partition layout. The link below is about a problem. It does not apply directly to your project. But the implication is that it may be hard to identify partition size in Vista.

http://support.microsoft.com/kb/919529

Sorry I can't give you more help on this.Quote from: Geek-9pm on March 24, 2010, 10:42:08 PM

And with Vista there is a new method used to identify the partition layout.

No, there isn't. GPT is available in a number of operating systems and even then it's hardly ever used on Vista or 7 anyway. Partition layout is almost exclusively defined with the same MBR that has existed for decades.

Either way, determining Disk/partition size is difficult from a pure DOS environment, simply since DOS doesn't support partition sizes larger then 2GB and most BIOS calls that can be made from DOS are subject to a number of limitations.

I think the best solution would be to get a tool such as aefdisk which can be used to list partitions directly and then somehow process the output from the tool to determine the desired partition, but it isn't going to be easy.Quote from: BC_Programmer on March 24, 2010, 11:03:03 PM
No, there isn't. GPT is available in a number of operating systems and even then it's hardly ever used on Vista or 7 anyway. Partition layout is almost exclusively defined with the same MBR that has existed for decades.

Either way, determining Disk/partition size is difficult from a pure DOS environment, simply since DOS doesn't support partition sizes larger then 2GB and most BIOS calls that can be made from DOS are subject to a number of limitations.

I think the best solution would be to get a tool such as aefdisk which can be used to list partitions directly and then somehow process the output from the tool to determine the desired partition, but it isn't going to be easy.
I don't think the OP is talking about DOS, more LIKELY, he is talking about the command-line interpreter in Windows OSs.Quote from: Helpmeh on March 25, 2010, 06:20:43 AM
I don't think the OP is talking about DOS, more likely, he is talking about the command-line interpreter in Windows OSs.

They should say what they mean then.
2365.

Solve : Batch file to save photos into folders?

Answer»

I would appreciate any help to speed up a very mundane task.

I would like to find or write a batch file to do the following:

1. find all jpegs in a specific folder,
2. for each jpeg in the folder read the "date picture TAKEN" attribute,
3. create a folder with the name as the date the picture was taken,"YYYY_MM_DD"
4. move each picture into its new folder,
5. Then move all folders to a different directory.

I might be asking a bit much but it doesn't sound simple to me as im a complete novice.

Can anyone help me or point me in the RIGHT direction.I'm very skeptical that a batch file would be of help here. The "Date Picture Taken" property is not exposed in batch code. This little snippet will overcome that shortcoming:

Code: [Select]folderName = "c:\Pictures" 'check for valid directory

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(folderName)

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderName)
Set fc = f.Files

For Each fs In fc
If fso.GetExtensionName(fs) = "jpg" Then
Set objFolderItem = objFolder.ParseName(fs.Name)
strValue = objFolder.GetDetailsOf(objFolderItem, 25)

If strValue <> "" Then
newYY = DatePart("yyyy", strValue)
newMM = DatePart("m", strValue)
If newMM < 10 Then newMM = "0" & newMM
newDD = DatePart("d", strValue)
If newDD < 10 Then newDD = "0" & newDD
newFolder = "c:\" & newYY & "_" & newMM & "_" & newDD 'check for valid drive and path

If Not fso.FolderExists(newFolder) Then
fso.CreateFolder(newFolder)
End If

fso.CopyFile fs.Path, newFolder & "\"
End If
End If
Next

The lines are marked that need to be changed. folderName is the directory where the pictures are now. newFolder is where you want the pictures to be.

Step 5 of your request is a duplicate step 4. Instead of copying files to an interim directory, why not just send them to their final resting place with a single instruction?

Save the script with a vbs extension and run from the command prompt as cscript scriptname.vbs

I dislike trashing files (especially pictures with sentimental value), so I used the copyfile method. You can change this to movefile method.

Good luck.

Sorry about the code alignment. It looked great in my editor. I have copied into a notepad file and changed ext to .vbs and it worked partially .

3 jpegs were moved to their correct folder however ther was 100+plus left behind.....

many thanks for your help sof far by the way im light years further than i was...

the 3 that moved were .jpg whilst the remainder were .JPG does the case make any difference?Quote from: eddie.ceri on April 07, 2010, 04:34:29 PM

the 3 that moved were .jpg whilst the remainder were .JPG does the case make any difference?

it would appear so.


Change the line:

Code: [Select] If fso.GetExtensionName(fs) = "jpg" Then


to:
Code: [Select] If lcase(fso.GetExtensionName(fs)) = "jpg" Then
I did TRY:
If fso.GetExtensionName(fs) = "jpg" or "JPG" Then

but it didnt recognise the string JPG.....Well ...... I would like to say a big thank you to sidewinder for his time and effort and for BC_Programmer for his fine tuning........

Many thanks.....

All i have to do now is decifer how the beast works....
This could work...not quite sure...it depends on the camera.

@echo off
setlocal enabledelayedexpansion
for /f "skip=5 tokens=1,5" %%A in ('dir /t:c *.jpg') do (
echo Date --- %%A
echo File --- %%B
if not "%%B"=="" if not "%%B"=="free" (
set filedate=%%A
set filedate=!filedate:/=-!
if not exist !filedate! md !filedate!
copy %%B !filedate!
)
)
pause

Seems to work for me.

I just felt like making an all-batch solution.Quote from: eddie.ceri on April 07, 2010, 04:40:27 PM
I did try:
If fso.GetExtensionName(fs) = "jpg" or "JPG" Then

but it didnt recognise the string JPG.....

That isn't proper syntax. the "Or" operator only works on Booleans or numeric variables.

in order for it to work here you'd need to use:

Code: [Select]If fso.GetExtensionName(fs) = "jpg" or fso.GetExtensionName(fs)="JPG" Then

However, it still wouldn't work for mixed case, like jPg or Jpg or JPg, etc.

using lcase or ucase to convert the case before COMPARISON, however, fixes that.

*Note:

Previously, me and Geek-9pm, another member, got in a rather heated debate with regards to this particular usage. my stance was that it was best to use StrComp() to compare strings,rather then case conversions. this was based on the fact that StrComp() would recognize combined glyphs such as the combined "AE" character properly being matched to the actual two characters, AE.

However, it would appear, from what I've read in the meantime regarding StrComp, that while this would work, it is slower (another incorrect contention I held was that the StrComp() method was faster). StrComp() is designed for comparing strings for sorting algorithms; this is why it returns a value indicating the sort order of the two items.

Therefore, if geek-9pm is reading this, I was WRONG


Quote from: Helpmeh on April 07, 2010, 04:47:57 PM
This could work...not quite sure...it depends on the camera.

@echo off
setlocal enabledelayedexpansion
for /f "skip=5 tokens=1,5" %%A in ('dir /t:c *.jpg') do (
echo Date --- %%A
echo File --- %%B
if not "%%B"=="" if not "%%B"=="free" (
set filedate=%%A
set filedate=!filedate:/=-!
if not exist !filedate! md !filedate!
copy %%B !filedate!
)
)
pause

Seems to work for me.

I just felt like making an all-batch solution.

No, that won't work. "Date Picture Taken" is an EXIF attribute, and while the actual date of the picture can be used for this it breaks down when that file is copied or moved, whereas the EXIF data stays intact.


I have just test run the .vbs file and it works great ...........

there are a few ponts that i didnt think would be a problem but might cause issues.....

1. If a file with the same name is already in that folder (probably the same file anyway) the WHOLE routine doesnt run it creates an error message "Microsoft VBScript runtime error: File already present" which is common sense i suppose.

2. What i would prefer if it didnt copy it and allowed me to sort it out manually later but carried on with the rest of the jpegs.Quote from: eddie.ceri on April 07, 2010, 04:59:14 PM
I have just test run the .vbs file and it works great ...........

there are a few ponts that i didnt think would be a problem but might cause issues.....

1. If a file with the same name is already in that folder (probably the same file anyway) the whole routine doesnt run it creates an error message "Microsoft VBScript runtime error: File already present" which is common sense i suppose.

2. What i would prefer if it didnt copy it and allowed me to sort it out manually later but carried on with the rest of the jpegs.

Good idea. I just added an "On Error Resume Next" statement.

Code: [Select]folderName = "c:\Pictures" 'check for valid directory

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(folderName)

Set fso = CreateObject("Scripting.FileSystemObject")

Set f = fso.GetFolder(folderName)
Set fc = f.Files

For Each fs In fc
If fso.GetExtensionName(fs) = "jpg" Then
Set objFolderItem = objFolder.ParseName(fs.Name)
strValue = objFolder.GetDetailsOf(objFolderItem, 25)

If strValue <> "" Then
newYY = DatePart("yyyy", strValue)
newMM = DatePart("m", strValue)
If newMM < 10 Then newMM = "0" & newMM
newDD = DatePart("d", strValue)
If newDD < 10 Then newDD = "0" & newDD
newFolder = "c:\" & newYY & "_" & newMM & "_" & newDD 'check for valid drive and path

If Not fso.FolderExists(newFolder) Then
fso.CreateFolder(newFolder)
End If
On Error Resume Next
fso.CopyFile fs.Path, newFolder & "\"
End If
End If
Next

It is also possible to create a logfile of the files that were missed.That worked great.......

The log would be good,

I have removed any duplicate jpgs by using the "Easy duplicate finder" application.

Many thanks for your time and effort BC_Programmer Quote from: eddie.ceri on April 07, 2010, 02:10:01 PM
I would appreciate any help to speed up a very mundane task.

I would like to find or write a batch file to do the following:

1. find all jpegs in a specific folder,
2. for each jpeg in the folder read the "date picture taken" attribute,
3. create a folder with the name as the date the picture was taken,"YYYY_MM_DD"
4. move each picture into its new folder,
5. Then move all folders to a different directory.

I might be asking a bit much but it doesn't sound simple to me as im a complete novice.

Can anyone help me or point me in the right direction.

you can download jpeg tools like jhead for example, and then run your photos with jhead using for loop and grab the images creation date/time, do some manipulation with the date/time to the format you want, and then use mkdir to create directories etc etc...




2366.

Solve : Batch - for loop?

Answer»

Hello, I need some assistance, the web or the HELP does not seem to work or I'm not understanding it.

I'd like to create a batch file that will read in a list of IP addresses and for each IP address perform a ping and then a traceroute.

To reduce iteration I figure I have an initial batch file, a text file with all the IP address (which could expand) and then a 2nd batch file that will run the ping and traceroute from the list (again other commands or tasks may well take place within this)

Initial.bat
FOR /f "eol=" %%L IN (c:\list.txt) DO call c:\2nd.bat %%L

2nd.bat
ping %%L
tracert %%L

The black windows appears for a split second, and nothing happens. I have tried putting in pause statements, and replaced the call with echo, do see what is happening, even tried sending the output to another text file. Nothing seems to work. Even tried using an example from the cmd prompt "for /?"

for /F "eol=; token=2,3* delims=, " %i in (c:\list.txt) do @echo %i %j %k

Could somebody advise

Is this just to see if it can be done?
Does it have a real world application?
The reason I say that is many people come here already sure they need a batch file and have a hard time understanding the FOR command. If you are a professional programmer, and you do not understand the FOR command already, you may need to re think your objective. Peal, Python or VB script are choices.
My point is, are you sure you want to do this in batch?
I can been done, it does not have to be a compact four line FOR LOOP that washes hides and puts them away.. The problem can be split into parts and each part tested by itself. Which is a standard PRACTICE anyway, unless the objective is to get a cryptic bit of code that you will not understand 30 days from now.
hello,

yes to see if it can be done and also how to understand how it is done.
depending on the success yes.

Pro programmer no, I dabbled in it a few years back, i kinda understand the principles, I lack the syntax. I think Pearl, Python, VB etc are making things to busy and complex.

to reduce iteration I figured it would be easier and the general essence of programming to split things up and call functions, other programs and such.

if it works, then to add more IP address to a list would be easier than adding the IP address and also the ping and tracert each time. again should i wish to remove the ping this is a simple quick change that will happend only once.

I figured this for loop would be ideal, and a batch file is simple and easy to transport is this not the case??In 2nd.bat, change %%L to %1Can you provide a list of address that you want to ping?
Is the purpose of this to make a report on the up time or performance of serves in different areas? If so, there already are thousands of free programs that do that.
Myself, I avoid the use of FOR in a batch unless that is the best solution. When ONE has a desperate list, a list where the items differ in a large way, iteration may not be appropriate.

Here is a disparate list of web sites in a batch file that calls another batch. The objective is to build a report using PING. We initialize the list on the first line with the > redirection symbol
Code: [Select]REM BigList.bat
echo Ping Test results > results.txt
call pingtest.bat yahoo.com
call pingtest.bat amor.com
call pingtest.bat bearclw.com
call pingtest.bat why-me.net
...
echo ...all done!
This big list calls a small batch that has more detail

Code: [Select]REM pingtest.bat
ping -a %1 >> results.txt
The >> adds more to the text file.
Later, use some other kind of program to compile the results.txt file into a report.

The list was make with notepad or a similar editor that lets you insert a sedative string in front of a desperate list. Even a very large list will take less than a few moments to edit notepad.
The advantage of this is that you can put in an error trap in the subordinate batch file that will stop and report an error. So you can go back and remove invalid items in the main file. By insertion of a REM you can block a line.

This kind of job is easier to maintain and modify than a FOR loop in simple cases. FOR is more suitable for manipulation of file names and attributes.

In general, this Big List method is very simple to understand.
Does this help?server errorBefore I start, here is a handy tip. When you are trying out a batch script, don't start it from Windows Explorer (by doubling clicking its icon). If you do this any errors can, and successfully reaching the end of the script will make the command window abruptly vanish. You can trap the script termination with a pause command, but if there is a prior error the window may vanish too quickly for you to read the error message.

So run the script from a command window by typing its name and any parameter(s) at the prompt, this is easiest if you are in the same folder then you can just type its name and optionally its extension. The long winded way to get there is to type "cmd" in the Run box from the Start menu, and then navigate to the folder using CD. The quicker way is to use "Command Prompt here" from a right click on the folder in Windows Explorer. This is built in to Vista and later, with earlier Windows versions see here

http://www.petri.co.il/add_command_prompt_here_shortcut_to_windows_explorer.htm

Running the script this way means that when it terminates either at the end or because of a syntax error, or doesn't do what you expect, you get the prompt back and in the case of an error you see the script output and any error messages and this is available for you to look at, and in the event of mystification, to copy and paste it into a search engine or as part of a post in a help forum such as this one.

Now to the matter in hand:

You don't need 2 batch files.

The general syntax of FOR is

On one line:

FOR ["options"] %%variable in (dataset) DO command

Using parentheses you can make it span multiple command lines (many people indent the interior for readability):

FOR ["options"] %%variable in (dataset) DO (
command1
command2
command3
etc
)

["options"] may not always be PRESENT. Can contain skip= eol= tokens= delims= sections.
variable is a single letter from A-Z a-z.
dataset can one or more files, wild cards can be used.

To apply command to every line of a file you would use the /F switch

Thus

FOR /F %%A in (filename.txt) DO ping %%A

or

Code: [Select]@echo off
for /f %%A in (ip-addresses.txt) do (
ping %%A
tracert %%A
)
echo.
echo *** loop completed ***
echo.
pause

Here is a text file (It has 2 lines but could have more). I have called it ip-addresses.txt

Code: [Select]87.248.112.81
209.85.229.99

Running the above batch code produces this output at my location:
Code: [Select]Pinging 87.248.112.81 with 32 bytes of data:
Reply from 87.248.112.81: bytes=32 time=41ms TTL=53
Reply from 87.248.112.81: bytes=32 time=51ms TTL=52
Reply from 87.248.112.81: bytes=32 time=40ms TTL=53
Reply from 87.248.112.81: bytes=32 time=44ms TTL=53

Ping statistics for 87.248.112.81:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 40ms, Maximum = 51ms, Average = 44ms

Tracing route to fe15.global.sports.ird.yahoo.com [87.248.112.81]
over a maximum of 30 hops:

1 8 ms 7 ms 7 ms 10.15.176.1
2 7 ms 7 ms 7 ms aztw-geam-1b-ge212.network.virginmedia.net [80.1.243.137]
3 7 ms 7 ms 7 ms aztw-core-1b-ae0-0.network.virginmedia.net [80.1.241.13]
4 13 ms 10 ms 9 ms brhm-bb-1b-as1-0.network.virginmedia.net [213.105.175.161]
5 13 ms 13 ms 13 ms nrth-bb-1a-as4-0.network.virginmedia.net [62.253.185.105]
6 11 ms 11 ms 11 ms nrth-tmr-1-ae1-0.network.virginmedia.net [213.105.159.30]
7 31 ms 31 ms 33 ms fran-ic-1-as0-0.network.virginmedia.net [62.253.185.81]
8 27 ms 27 ms 64 ms ge-1-3-0.pat1.dee.yahoo.com [80.81.192.115]
9 26 ms 27 ms 29 ms so-2-0-0.pat1.ams.yahoo.com [66.196.65.144]
10 44 ms 45 ms 43 ms UNKNOWN-66-196-65-X.yahoo.com [66.196.65.81]
11 44 ms 52 ms 43 ms ae-1.msr1.ird.yahoo.com [66.196.67.231]
12 47 ms 46 ms 79 ms te-7-4.bas-b1.ird.yahoo.com [87.248.101.103]
13 41 ms 52 ms 53 ms fe15.global.sports.ird.yahoo.com [87.248.112.81]

Trace complete.

Pinging 209.85.229.99 with 32 bytes of data:
Reply from 209.85.229.99: bytes=32 time=25ms TTL=53
Reply from 209.85.229.99: bytes=32 time=25ms TTL=53
Reply from 209.85.229.99: bytes=32 time=25ms TTL=52
Reply from 209.85.229.99: bytes=32 time=26ms TTL=52

Ping statistics for 209.85.229.99:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 25ms, Maximum = 26ms, Average = 25ms

Tracing route to ww-in-f99.1e100.net [209.85.229.99]
over a maximum of 30 hops:

1 6 ms 7 ms 7 ms 10.15.176.1
2 8 ms 7 ms 8 ms aztw-geam-1b-ge136.network.virginmedia.net [80.1.242.121]
3 7 ms 7 ms 7 ms aztw-core-1b-ae0-0.network.virginmedia.net [80.1.241.13]
4 9 ms 9 ms 9 ms brhm-bb-1b-as1-0.network.virginmedia.net [213.105.175.161]
5 11 ms 11 ms 11 ms manc-bb-1a-as6-0.network.virginmedia.net [62.253.185.134]
6 12 ms 13 ms 17 ms manc-bb-1b-ae0-0.network.virginmedia.net [62.253.187.178]
7 78 ms 22 ms 19 ms tele-ic-3-ae0-0.network.virginmedia.net [212.43.163.70]
8 21 ms 19 ms 19 ms 138-14-250-212.static.virginmedia.com [212.250.14.138]
9 20 ms 20 ms 19 ms 209.85.252.76
10 26 ms 25 ms 25 ms 72.14.232.134
11 72 ms 26 ms 28 ms 216.239.49.45
12 25 ms 33 ms 29 ms 209.85.243.85
13 27 ms 25 ms 20 ms ww-in-f99.1e100.net [209.85.229.99]

Trace complete.

*** loop completed ***

Press any key to continue . . .

You don't say why you are using "eol=" in the options block. If it is not used, you can comment out lines in the text file simply with a semicolon.

Thus in this text file, using my above syntax, the third line will be ignored:

Code: [Select]87.248.112.81
209.85.229.99
;212.58.224.138
212.250.162.12

By the way, this is an ip address:

Code: [Select]209.85.229.99
and this is (part of) a url:

Code: [Select]www.yahoo.com












..Kudos Salmon Trout

worked like a treat. For confirmation and historical purposes I have done the following.

Initial Batch file....
FOR /F %%A in (list.txt) DO call bat2.bat %%A

list.txt
Just a simple list of non sequenced IP address's

called batch file
ping %1
tracert %1


This will read in, a line at a time a list of IP address's and perform a ping and a tracert to that particular IP address.

Excellent thanks again

2367.

Solve : new user of c++?

Answer»

hi,iam new user of c++ so i want tips of how to tackle c++ problems.please give me tips.You are very vague.

Quote

Listed below are some common programming errors
1. Misuse of the Include Guard.
A common mistake is to use same symbol in multiple files for #ifndef.
2. Typo's : Using ">" for ">>" and "<" for "<<"
3. Trying to directly access the private variables in the main program.
4. Switch Statments without break.
5. Wrong usage of postfix and prefix operator (diff between i++ and ++i)
6. Undeclared and Unitialised Variables and functions.
7. ALWAYS USE MAKE FILE if you have more than one C++ program. The order of
compilations matters a lot too.
8. Trying to include "INCORRECT" header fuction.
9. Marking a member function as const in the class definition but not in the member function implementation.
10. Returning a value in a void function.
11. Confusing the name of an array with the contents of the first element.
12. Cstring array Errors - Arr[10] = Arr[0] to Arr[9]. Trying to access Arr[10] element.
13. Using "=" ( assignment operator ) INSTEAD of "= =" (comparison operators) scanf() without '&' and wrong format.(IN C)
14. Trying to divide a number by Zero.
15. Poor Loop Exiting comparisons will tend to either loop being not executed at all or goes to an infinite loop.
16. Not using STRING functions and TREATING the strings are integer . SAY trying to compare string by (string1= = string2) , rather than using strcmp command
17. CString not terminated by '\0'- Null character
18. Mismatched "{" or IF-ELSE statements or for that matter any looping statment.
19.Namespace errors
20. Forget }
21. Wrong number of }
22. Missing ;
23. Missing )
Quote from: taumang on February 18, 2011, 09:10:09 AM
hi,iam new user of c++ so i want tips of how to tackle c++ problems.please give me tips.
please post me a program and its algorithm so that i can understand what you are talking about.pretty basic stuff below, if you want to know more, ask what you want to know :p


//double forward slash allows for comments

#include //#include will include header files that will allow for functions that are within, iostream will be almost always used

using namespace std; //this will use standard namespace which will let you type cout instead of std::cout

int main(){ //this will define main function, function works within parenthesis

int number = 0; //sets variable number to 0 and declares i as an int

for (int i = 0; i < 3; i++){//loop 3 times
number++;//increment number by 1;
}//end loop

cout << number << endl; //output variable number (3) followed by a line break

return 0; //returns zero
}//end mainGoogle:
youtube C++ tutorial

Here is 'Hello World'
http://www.youtube.com/watch?v=vYHB0DUcfV0
2368.

Solve : Perl: split data by line and column in csv file?

Answer»

Hi,

i have data in csv file. i want to split it base on line and COLUMN.

my code so far:

Code: [Select]CODE

#!/usr/bin/perl use strict;
use strict;
use warnings;
use TEXT::CSV_XS;

# Store our CSV file name
my $file = 'input.csv';

open( CSV_XS, '<', $file )
or die( 'Unable to open csv file ', $file, "\n" );

open MYFILE, ">output.csv";
select MYFILE;

my $csv = new Text::CSV_XS;
foreach my $line (<CSV_XS>) {
if ( $csv->parse($line) ) {

my @data = $csv->fields();
print $data[0], ',share,', $data[1], ',emotions,', $data[2],
',broadcast,', $data[3], ',social,', $data[4], ',other,', $data[5],
',feedback,', $data[6], ',funding,', $data[7], ',recruit,', $data[8],
',promotion,', $data[9], "\n";
}
else {
print 'Unable to parse CSV line: ', $line, "\n";
}
}
close(CSV_XS);
-----data---
WorkerId,share,emotions,broadcast,social,other,feedback,funding,recruit,promotion
A1LWAFOQEFVU9K,20119,20116,,20111|20112|20113|20115|20117|20120,|||||||20118|Not in English||,,,,20114
A3ACYKMVJAEAIZ,20105,20104|20106,,20102|20104|20108|20109|20110,|||||||||,20101,,,20103|20105|20107|20110


----Current output-----
A1LWAFOQEFVU9K,share,20119,emotions,20116,broadcast,,social,20111|20112|20113|20115|20117|20120,other,|||||||20118|Not in English||,feedback,,funding,,recruit,,promotion,20114
A3ACYKMVJAEAIZ,share,20105,emotions,20104|20106,broadcast,,social,20102|20104|20108|20109|20110,other,|||||||||,feedback,20101,funding,,recruit,,promotion,20103|20105|20107|20110


what i need is:
A1LWAFOQEFVU9K share 20119
A3ACYKMVJAEAIZ share 20105
A3ACYKMVJAEAIZ emotions 20104
A3ACYKMVJAEAIZ emotions 20106
A1LWAFOQEFVU9K emotions 20116
A1LWAFOQEFVU9K broadcast ## this empty, i would LIKE remove it.
A3ACYKMVJAEAIZ broadcast ## this empty, i would like remove it.
A1LWAFOQEFVU9K social 20111
A1LWAFOQEFVU9K social 20112
A1LWAFOQEFVU9K social 20113
A1LWAFOQEFVU9K social 20115
A1LWAFOQEFVU9K social 20117
A3ACYKMVJAEAIZ social 20102
A3ACYKMVJAEAIZ social 20104
A3ACYKMVJAEAIZ social 20108
A3ACYKMVJAEAIZ social 20109
A3ACYKMVJAEAIZ social 20110
.........


Any help is much appriciated. Thank you.

_____________________

No spam, thanks.
-- kpac

I don't know how to do this via a programming approach, so what I would do is IMPORT the data in to Microsoft Excel, which can parse, or split, the data into columns. If you don't have Excel, then the free OpenOffice is an option, and I believe you could use either the spreadsheet (Calc) or the database (simple called Base) component of OpenOffice.

2369.

Solve : Batch File If Statement?

Answer»

i know i just WANTED to point that outQuote from: mat123 on April 16, 2011, 07:42:04 AM

i know i just wanted to point that out

You could also mention that the sky is blue and that the sun goes AWAY at NIGHT.
2370.

Solve : Java server code problem?

Answer»

i have this code for a server for a program i made

Code: [Select]package com.matter123.main;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.SOCKET;
import com.matter123.net.*;

public CLASS Clienthandle implements Runnable {
Socket thesocket;
ObjectInputStream in;
ip bbs;
public Clienthandle(Socket CLIENT,ip bbs) {
thesocket=client;
this.bbs=bbs;
try {
in=new ObjectInputStream(thesocket.getInputStream());
} catch (IOException e) {
// TODO Auto-generated catch BLOCK
e.printStackTrace();
}
}

@Override
public void run() {
sendable sender=null;
try {
while (true) {
while ((sender=(sendable) in.readObject()) !=null) {
System.out.println("got a object: "+sender.toString());
bbs.tell(sender);
}
}
} catch (IOException e) {
System.out.println("IOException");
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

} and
Code: [Select]package com.matter123.main;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.*;
import java.util.ArrayList;
import java.util.Iterator;


import com.matter123.net.sendable;

public class ip implements ActionListener {
ArrayList<ObjectOutputStream> client=new ArrayList<ObjectOutputStream>();
private Beatboxserver bbs;
public ip(Beatboxserver bbs) {
this.bbs=bbs;
}
@Override
public void actionPerformed(ActionEvent arg0) {
System.out.println("got to ip.actionPerformed() with a port of"+bbs.portfield.getText());
bbs.ipport.setVisible(false);
try {
ServerSocket serversock=new ServerSocket(Integer.parseInt(bbs.portfield.getText()));
while (true) {
System.out.println("got to serversock.accept()");
Socket client=serversock.accept();
System.out.println("got a connection at "+client.getLocalAddress().getHostAddress());
ObjectOutputStream out=new ObjectOutputStream(client.getOutputStream());
this.client.add(out);
Thread t=new Thread(new Clienthandle(client, this));
t.start();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void tell(sendable sender) {
Iterator<ObjectOutputStream> it=client.iterator();
while(it.hasNext()) {
ObjectOutputStream out=it.next();
try {
out.writeObject(sender);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}

}
the first time a MESSAGE is received it sends the message but the second time it throws a IOException why and how do i fix it

2371.

Solve : how to click an anchor with visual basic?

Answer»

the HTML DOM SAYS that there are two ways of accessing anchor elements in an HTML document. 1) .getElementsByID and 2) cycling through the HTMLDoc.anchors iHTML collection.

Using VBA, I'm trying to write code that will CLICK an anchor (a "a" element right?) given certain conditions and I can't seem to get 2 to work. I can get 1) to work:

ex.

set elmLink = htmldoc.getelementbyID("-----")
elmLink.click

But this is very case specific and the link I want to click doesn't always have an ID property listed in the source code. Most often it is an "a" tag, and only has a class and HREF listed from which to work with.

This is fine, the shown text almost always contains a phrase. But I can seem to cycle through the anchors in any way.

I've tried:

for each elmLink in htmldoc.getElementsByTagName("a")
if instr(elmLink.innerText, "[phrase]") then
elmLink.click
exit for
end if
next

and i've tried

for each elmLink in htmldoc.anchors
if instr(elmLink.innerText, "[phrase]") then
elmLink.click
exit for
end if
next

and i've tried

for i = 0 to UBound(htmldoc.anchors, 2)
set elmLink = htmldoc.anchors(, i)
if instr(elmLink.innerText, "[phrase]") then
elmLink.click
exit for
end if
next

..and none of these 3 do anything, the last one doesn't even run without errors. I guess .anchors([name], [index]) is too ambiguous for me. Any thoughts? thx


________________________


No spam, thanks.
-- kpac

for each is working fine for me in VB6. chances are it's the Instr causing the most problems (aside from the last example, where you try to use UBound on a collection. That will never work.

for Instr you might need to make the comparison case insensitive.

Code: [Select]If InStr(1,elmLink.innerText, "[phrase]",vbCompareText)>0 Then

2372.

Solve : hidden programs?

Answer»

is there any way to use a command prompt to show me any hidden programs that are hiding on my computer? im under the influence that my parents have installed a program on our computer and are now watching everything that i do, is there any way to prove\disprove this?sorry that I laughed when reading this... if your parents put anything on it to monitor, its PROBABLY easily seen in the task manager processes. Another sneaky device that I have seen available is a hardware keylogger that plugs between the keyboard and computer, so it is invisible. The person such as parent then can detach the ps2 port keystroke logger and then plug it into their computer to dump out all KEYSTROKES and read whatever was typed, private info and passwords etc. The device is like $40 an I saw it on cyberguys catalog. Could be a very evil device for a rogue employee who wants to farm credentials and has access to plugging this little device in, since no network security will block this device that operates independently of the system itself and captures all keystrokes. Another hot spot for getting info is with wiresharking the network and watching traffic that is unencrypted, as well as loggers that can operate from the router and REDIRECT all logged traffic to another device or be viewed at that device.

taskmgr can be executed from command prompt of a windows system to get to task manager or ctrl+alt+delete and then select it, then write down all processes and then check them out on google search to look up any or all that you may be unfamiliar with.haha thank you, i posted this question i used task manager to check and nothing came up out of the ordinary. it just seemed uncanny how my parents just happened to know what i had to talked to my friends about the day before on facebook. Quote from: frostyjones13 on March 07, 2011, 07:06:31 PM

haha thank you, i posted this question i used task manager to check and nothing came up out of the ordinary. it just seemed uncanny how my parents just happened to know what i had to talked to my friends about the day before on facebook.

Are they on facebook as well?Quote from: BC_Programmer on March 07, 2011, 07:29:35 PM
Are they on facebook as well?

I laughed when I read this... You could easily find your way around it by using the task manager. You can try stopping those programs there so you could do whatever you want with the computer. Also, you could check for the installed programs list on your computer. This way, you could further search the internet for ways on how to et past those programs. But i bet that your parents installed those programs for your own good. So better keep up with them. Everything will be yours for the taking, when the time is ripe.Quote from: ericb82 on March 11, 2011, 06:20:52 AM
Everything will be yours for the taking, when the time is ripe.

err...

what?There are some KEYLOGGERS which are built to hide from task manager, start up, add/remove programs, and other major locations. Your best choice would be to use an application which will scan your computer for potential keyloggers.

Here is one I found: http://dewasoft.com/privacy/kldetector.htmThe programs that are built to disappear from the Processes list pretty much have to be services. You can see the list of services by choosing Control Panel -> Administrative Tools -> Services. Click on a service to see if it is running (look at the left panel). Clicking STOP on a running service will stop the keylogger/spy program.Quote from: frostyjones13 on March 06, 2011, 07:47:45 PM
is there any way to use a command prompt to show me any hidden programs that are hiding on my computer? im under the influence that my parents have installed a program on our computer and are now watching everything that i do, is there any way to prove\disprove this?

I don't know if you're still checking this post, but I can second ultimatum's recommendation from DewaSoft. Permit me a second on my soapbox, and I can give you a few more TIPS as well (and all subsequently mentioned utilities are free, most portable as well). Firstly, if you are an avid user of Facebook, your parents should be the least of your concerns. Facebook collects (and leaks) massive amounts of data to the public (http://lifehacker.com/#!5526429/see-what-facebook-publicly-publishes-about-you), and it collects this information even when you are browsing other sites (there are plugins for Firefox for example, for preventing this...)

Have you considered just asking your folks how they knew? Sometimes the best way to get a direct answer, is to ask a direct question... Unless your parents are quite sophisticated computer users, they could have simply discovered traces left behind in your browser cache, perhaps without intending to snoop. I don't use Facebook, but without seeking to do so learned which friends my wife had been chatting with over the period of about a month, as I had Google Picasa running and it began asking for identities on a number of faces discovered in photos of our friends I didn't recognize as part of our collection (it was grabbing them from her browser cache). My wife's personal correspondence is her business, so I try to remind her to clear her browser cache from time to time...

You could perhaps run a portable browser, or setup your browser to automatically clear cached information, and perhaps try running some of these utilities (NIRSoft; http://www.nirsoft.net/utils/), which are generally really useful tools, to get an idea of the bits of information scattered around your system over time (there's a link somewhere in the page to get all the utilities together in one shot...). The search utility Everything (http://www.voidtools.com/) is also a fast way to locate files cached on your system, and the utility CCleaner (http://www.piriform.com/ccleaner) is a great way to automatically clear them out... I probably don't have to mention that Picasa, while not designed for the purpose, is a great "forensic" tool as well. However, if you are convinced there is something really sneaky, you could try running HiJack This!, and submitting the report to the forums...



Also, to add to what might be perceived as somewhat conspirational thinking, you don't even to be a member of facebook, or a previous member of facebook, in order for them to be tracking information about you; any site that links into facebook with the stuff like the "like" button has tracking; although I don't think it can figure out your name, it can still build an IP-based "profile" about your movements, particularly given the large number of sites that are connected to the facebook API; using this information it can then decide what you are interested in; much akin to google's targeted advertising concepts. Whether this is a breach of privacy is of course subjective.
2373.

Solve : Thief Catcher, (free) help needed.?

Answer»

me and my team working on a project called Stealth Hunter,

Summarize about our project.
Stealth Hunter is a thief catcher, It will silently take a snapshot of user using a stolen notebook or pc with webcam and send the information via EMAIL.

so, the problem is, the scripts wont trigger it. Maybe something wrong with the script? hope someone can take a look on it. Thanks.

Here's our full Stealth Hunter Scripts - http://www.mediafire.com/?nfvv748g5ctri29

and this is where the main line/code (also included on link above).

Code: [Select]# ! /bin/sh
### BEGIN INIT INFO
# Provides: Stealth Hunter
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Stealth Hunter catcher
# Description: Stealth Hunter is a thief catcher
# It will silently take a snapshot of user using a stolen notebook
# or pc with webcam and send back an email.
### END INIT INFO

# Author: shunter

CONFIGURE="No"

# Reads config file
[ -r /etc/default/shunter ] && . /etc/default/shunter


if [ $CONFIGURED != "YES" ]; then
echo "/etc/default/shunter not configured yet!"
echo "Exiting ..."
exit 0
fi

PASSWORD=$(encrypt-decrypt decode $PASS | awk '$0!~/^$/ {print $0}')

do_start()
{
ping -c 2 google.com > /dev/null 2>&1
if [ $? -eq 0 ]; then
#echo "Checking alert mail ..."
check_mail=$(wget -T 3 -t 1 -q --secure-protocol=TLSv1 --no-check-certificate --user=$USER --password=$PASSWORD https://mail.google.com/mail/feed/atom -O - |grep "$ALERT")
if [ $? -eq 0 ];
then
#echo "Alert mail found, this notebook/pc might been stolen!!"
#echo "Retrieving ip adress ..."
IP=$(wget -q -O - http://whatismyip.org |tail) && wait $!
DATE=`date`
#echo "Taking snapshot ..."
mplayer tv:// -tv driver=v4l2:width=320:height=240:outfmt=uyvy:device=/dev/video0 -frames 3 -vo jpeg:outdir=/tmp >/dev/null 2>&1 && wait $!
#echo -n "Sending mail ..."
sendEmail -f [emailprotected] -t $USER -s $MAIL_SERV:$PORT -xu $USER -xp $PASSWORD -u $TITLE -m "$MESSAGE\nIP : $IP DATE: $DATE\n" -a $ATTACHMENT >/dev/null
#echo "Done."
exit
else
#echo "No alert message found ..exiting."
exit
fi
else
#echo "Not online ..."
exit
fi
}


case "$1" in
start)
do_start
;;

stop)
echo "This option is not supported."
;;

restart)
echo "This option is not supported"
;;
*)
echo "USAGE: /etc/init.d/$0 {start|stop|restart}"
exit 1
;;

esac

exit 0
any takers? its actually triggered by the owner itself. he or she might go to any pc, compose new email and send email to integrated email which is confirgured earlier (in stolen laptop) with "STOLEN" subject email. but nothing happened. it should work. all the coding is CORRECT. hope someone can take a look at it.

sorry for my broken english. =(

2374.

Solve : win32 programs?

Answer»

what is win 32 program
Welcome to the CH FORUMS where members are expected to USE Google.

Quote=Google
A Win32 application is a program which has been written to use the Win32 Application Programmer INTERFACE (API). The Win32 API is a collection of program functions which allow a program to trigger almost all OPERATING system actions - such as opening a file. Win32 programs typically run under the Windows OS, however emulation of the Win32 API is available on other platforms.

2375.

Solve : what is your favorite programming language??

Answer»

htmlHTML is not a programming language, it is a markup language.



ok php then I like a range of programming languages but my SPECIAL is C#

I can do:

Prolog - great little language

JAVASCRIPT - Similar to C# , thats why i like it , but understood by browsers so no need for installation

VB - Good for learning and you get alot of good features

BBC BASIC - very simple basic language which ALLOWS users to make images pixel by pixel. Can make good games and standalone files.

HTML - Mainly for the many features

Java - not one of my strong points but i can do simple stuff A fun language when you can get it to work.

C++ - Good but not as good as C# for me

Hope this might help a begginner. I KNOW i had alot of trouble finding my first language...

2376.

Solve : C++ inheritence ambiguous?

Answer»

Hi fellas.

I am making a program using C++ OOP and am having problems with inheritance.
Simply I want...

class CObject1
class CObject2 : public CObject1
class CObject3 : public CObject1, CObject2

The problem is that when I call something like SetPointA(###); it says it is ambiguous. What does this mean and how can I resolve it without uninheriting anything?

Thanks and let me know if you need any more info.



EDIT: Ok figured it out. Just deleted CObject1 from CObject3. It still gets EVERYTHING threw CObject2.
Thanks anyways.I'm not a C++ programmer but I do Java and C# programming. From what I recall you can't inherit from more than ONE class. You can only inherit multiple interfaces.Quote from: ultimatum on April 02, 2011, 08:51:35 PM

I'm not a C++ programmer but I do Java and C# programming. From what I recall you can't inherit from more than one class. You can only inherit multiple interfaces.

C++ supports multiple inheritance. The reason Boozu's attempts were ambiguous was because it was inheriting the members of CObject1 twice.I'm surprised anyone replied at all after my edit. I find that this happens to me a lot were I ask a question then the answer comes to me.
2377.

Solve : C++ Char Code[4]; Buffer Overflow Problem?

Answer»

Ran into a problem with writing a C++ program where if you enter more than 4 characters for Char Code[4]; it crashes with a Report this Error to Microsoft type error message if 5 or more characters are entered. The sloppy fix I have which really doesnt fix this Buffer Overflow problem is to make the Char Code[100]; so that it can take up to 100 characters before overflowing and crashing. Then before the data is used I perform a string length check on the data input to make sure it is 4 characters in length ELSE return back to input to Char Code[100]; This doesnt fix if someone entered 101 characters or more in which it would crash again so this is a sloppy fix that I dont like and so I am asking about code suggestions to harden the code to avoid this over flow problem with Char Code[100]; variable.basically- the SOLUTION would be to not get input directly into a char string, but rather handle it through a C++ string, and then you can test to make sure the char array is long enough to hold it:



Code: [Select]#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
const int maxlength=15;
char * cstr;
string str;


getline(cin,str);
if(str.length() > maxlength)
{
cout << "error, input string exceeds specified maximum of " << maxlength << ". length is " << str.length() << endl;


}
else
{
cstr = new char [maxlength];
memset(cstr,0,maxlength);
strcpy (cstr, str.c_str());

cout << "successful:" << cstr << endl;


}
int pausevalue;
cin >> pausevalue;
return 0;
}


here we simply read a line from cin into a string. then, if that string is shorter then the given maxlength constant, we reject it and give an error message, otherwise, we use strcpy to copy from the char array that c_str() returns and copy it to the target char array.@Dave,

Just curious, are you doing a project/homework/for leisure or is it for work?Thanks for the fix to that. I have 5 books on C++ and none of them show you the proper method to avoid overflows. You would think they would have content on how to avoid overflows etc and hardening of code, but none of these books have it.

And to answer ghost's question, this project is for myself actually. I took Intro to C++, Intermediate C++, and Advanced C++ at a community college and finished like 7 years ago. I am brushing up on my C++ skills by writing small programs to do different things, and I realized that I never solved the overflow issue and the instructor never gave me pointers on how to avoid it. Doing a Google search I didnt find any examples other than to avoid a get() command which I found at a IBM website.

Not to be secretive about project, its just a program that pretty much compiles a batch program based on Q/A from user input, then uses a system(batch1.bat); command to execute the batch program that was created. Controlling the information written to the batch1.bat file is essential to proper batch execution, and by avoiding the overflow the proper way is proper programming.

I have been interested in interaction between C++ and the system, and have been using the system(); command for many programs that are NON Malicious, but create perl, batch etc on the fly, and its neat to have different programs in different languages be able to COMMUNICATE through data files etc that they both can read and write to. If there are any good books out there on system controls from C++ and cross language communications please list them and i'll check them out.

And the last reason for this is to strengthen my skills in case i need to leave my job as an electronics tech and go back to IT in which programming is important as well as being able to make programs be able to communicate together to share data.

ThanksMy personal OPINION. I am not saying C++ has no "uses" in this age, since they are still relevant if you want to program games that take advantage of speed/graphics (low level) or writing some kind of drivers to interface with systems etc. But in this information age where internet is dominant, languages like Perl/Python/Ruby/etc or PHP are the languages to learn and get familiar with if you want to strengthen your skills. Yes, these are interpreted languages but they can be quite as fast in execution. Also, if you really want fast, you can extend using C, which you are familiar with. You can increase your productivity through faster code development time, since you don't have to compile your program like C/C++ does and you don't have to meddle with pointers. If you search the web, there are many articles talking about why C++ (and C) should be avoided as well. ANYWAY, just my thoughts.Quote from: ghostdog74 on August 20, 2010, 06:55:13 PM

If you search the web, there are many articles talking about why C++ (and C) should be avoided as well. Anyway, just my thoughts.

I don't doubt there are an equal number of articles with the opposite opinion.
2378.

Solve : Autofill from Excel BAT files?

Answer»

Is it hard to write a batch file that will autofill/import data from Excel file into a form.
For example: I start my CLASS.EXE PROGRAM that brings up a form to fill out that has NUMBER, NAME, and TYPE fields, SAVE and CLOSE buttons. So the way it works, simply you fill out a form, click SAVE, it saves your info, AUTOMATICALLY clears the fields and is ready for the next input. SOMETIMES the list gets too big. So I THOUGHT of creating an Excel spreadsheet with 3 columns and n-number of rows data. Then you run a batch file, browse for that file, then sit back and watch it autofill-in. It would just keep importing Excel data into CLASS.EXE forms until the data is blank in Excel.
Thanks!

2379.

Solve : Programer says ''Huh?''?

Answer»

how can I do a program with notepad? these characters that appears in notepad are weird... Is it complicated or SIMPLE to do a program?

ps: in my latest topics, What i wrote was weird, right?
Because, normally, I talk FRENCH.It is complicated. Always. Vous avez des fichiers EXE ouvrir direct?

---

You've been opening EXE Files directly with Notepad?

Also: No doubt what I wrote was weird there, because normally I use english


This is actually a common mistake; the executable files are the result of compiling the source code into it; we... well, at any rate, I.... couldn't change the contents of a executable file in a text editor to change the behaviour of a program any more then you COULD.

However, you can write Scripts using notepad, these are easier to understand. A Scripting language included with Windows is VBScript; one that is included with PRACTICALLY all Linux distributions is Python (and it's also downloadable for windows).

There are tutorials for both of these all over the web. I cannot recommend one personally, but for VBScript this looks reasonably accurate. For Python you can refer to this.

Of additional benefit, while there are no doubt resources for VBScript online in French, the Python page has it right here. If you are really interested in learning it's no doubt easier when it's in your "normal" language/mother tongue .You can write programs in many compiled languages in Notepad. For example FreeBasic.


can i do programs with RESOURCES HACKER?
Quote from: maxum on March 25, 2011, 12:18:40 PM

can i do programs with RESOURCES HACKER?

Why don't you say clearly what it is you want to do?
I want to do a program that opens any kind of files.Quote from: maxum on March 25, 2011, 01:25:24 PM
I want to do a program that opens any kind of files.

Well, good luck!
Quote from: maxum on March 25, 2011, 01:25:24 PM
I want to do a program that opens any kind of files.
Easier if you limit you work to Linux. Microsoft does not want you to see what they have.Quote
The bästard disassembler is a disassembler for linux/unix platforms.
The bästard disassembler is a disassembler written for x86 ELF targets on Linux. Other file formats/CPUs can be 'plugged in'. It has a command-line interface and is meant to be USED as a backend or engine. SUPPORT for controlling the disassembler via pipes is provided. Note that this disassembler does not rely on libopcodes to do its disassembly. Rather, the 'libi386' plugin is a standard .so that can be reused by other projects. ...
The bästard disassembler 0.17
Quote from: Salmon Trout on March 25, 2011, 11:52:24 AM
You can write programs in many compiled languages in Notepad. For example FreeBasic.

You write the source code in notepad. The program is the compiled result.Quote from: BC_Programmer on March 25, 2011, 02:35:07 PM
You write the source code in notepad. The program is the compiled result.

Indeed.

2380.

Solve : Bat How to lauch the installer automatically?

Answer»

I want to lauch the installer automatically but the installer contains some instructions
that need US to click 'Next' or 'Ok'.
Is it possible to write a bat command to instruct it so that it can be lauched
automatically without pressing mouse?

So far it's my command till:

@ECHO off
echo installing yahoo
Start /wait F:\Softwares\yahoo
PAUSE
@echo on


Thanks in advance!
I WOULD reccomend using SendKeys in VBScript. First you need to make a list of the keystrokes it takes to complete the installation.

You will need to change this code for your specific needs. This is just to GIVE you an idea.

Code: [Select]Dim WshShell
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "[KEY HERE]"
Wscript.sleep 1000
WshShell.SendKeys "[KEY HERE]"

Look here: http://msdn.microsoft.com/en-us/library/8c6yea83(v=vs.85).aspx

2381.

Solve : Robocopy Helps.. copying data skip NTFS permission?

Answer»

Dear all,

i am facing a problem to write the coding robocopy.
i want do a fully backup from 1 storage server to another server. however i want to skip copying NTFS permission for EVERY sharing folder.
it is because, i share the folder with local group user.

i merge the backup server as Z drive;
below is my robocopy coding:

robocopy D:\HV_Design z:\HV_Design /copyall /E /R:O /w:5 /r:5 /PURGE

i USE copy/all, therefore the NTFS permission also copy TOGETHER. how to skip the folder security permission? i only want to backup the folder content only.

please help. appreciate to get your reply soon.

thanks.

Best Regards,I recommend XCOPY instead of this "robocopy"...

CODE: [SELECT]xcopy D:\HV_Design\*.* Z:\HV_Design /S /T /E /YQuote from: Fleexy on March 21, 2011, 06:33:19 PM

I recommend XCOPY instead of this "robocopy"...
ROBOCOPY is an enhanced XCOPY that comes with Vista and windows 7.


For XCopy, /S,/T, and /E are mutually exclusive.


As for ROBOCOPY, it doesn't copy security permissions for any files (including folders" by default... /copyall however specifies you do want to copy all that.
From ROBOCOPY /?:
Code: [Select] /COPY:copyflag[s] :: what to COPY for files (default is /COPY:DAT).
(copyflags : D=Data, A=Attributes, T=Timestamps).
(S=Security=NTFS ACLs, O=Owner info, U=aUditing info).
2382.

Solve : outlook 2k7 count and import all files in a specified directory in VBA?

Answer»

Hi,

i'm in dire NEED of some help here.

I need to be able to read and count all files of a particular type in a directory (specifically outlook .MSG files), then import them into my code as MailItems for manipulation.

How do i GO about this PLEASE?

Thanks hey again. got this one partially licked.

just needed the DIR$ function to check files/folders.

now, is there a function or method that allows you to import/export outlook .msg files similar to TransferText?

2383.

Solve : VB6 - Use a variable within a variable's name?

Answer»

APL beats the crap out of toy languages like Perl or Python.

Quote

It is concise, using symbols rather than words and applying functions to entire arrays without using explicit loops. It is solution focused, emphasizing the expression of algorithms independently of machine architecture or operating system.

This immediate mode expression generates a typical set of Pick 6 lottery numbers: six pseudo-random integers ranging from 1 through 40, guaranteed non-repeating, and displays them sorted in ascending order:

x[⍋x←6?40]


Eat your heart out.


Quote from: Salmon Trout on August 21, 2010, 05:01:02 PM
APL beats the crap out of toy languages like Perl or Python.
like real. Perl/Python are for practical purposes. APL is for children who wants to play with toys.... and he rose to the bait!

Quote from: ghostdog74 on August 21, 2010, 02:01:40 PM
when i look at how its implemented in VB, i can't help but wonder why its not as simple and straightforward to use as in Perl/Python.

First off, I'll tell you this: It is not straightforward to use in Perl (Python is good, but hardly much different from VB6). I just struggled to get this to work for nearly half an hour:

Code: [Select]#!/usr/bin/perl
%hash = ('Dog',=> 'Woof',
'Cat'=>'Meow',
'Cow'=>'Moo');
print "$hash{Dog}\n";
print "$hash{Cow}\n";


So, easy to follow. right, I create a hash like this:
Code: [Select]%hash = ('Dog',=> 'Woof',
'Cat'=>'Meow',
'Cow'=>'Moo');
Ok, sensible enough. uses the % sign to access it as a hash variable, or in hash context. I don't know, I don't have a second monitor to keep it's MAN page up all the time. It would certainly make sense to somebody with more experience with the language.

but to access the actual ITEM, you need to use $.How is that straightforward? It might be straightforward to somebody familiar with it, but it's a *censored* of a pain in the *censored* to wrap ones head around when you haven't been playing with perl since you were in a playpen. In this case, I imagine that the characters aren't a sort of type-declaration characters at all, but more or less a type of access modifier that changes how the variable is accessed. in order to read a element from a hash, we need to access it in "scalar context", Usable? of course it is. But to claim this is easy and straightforward is to express how deeply polarized your opinions on the matter are.



VB6:
Code: [Select]Dim dict As ObjectSet dict = CreateObject("Scripting.Dictionary")
dict.Add "Dog", "Woof"
dict.Add "Cat", "Meow"
dict.Add "Cow", "Moo"
Msgbox dict.Item("Dog")
Msgbox dict!Cow

Now, here, the main annoyance is that you add each item on a separate line. This is actually FULLY optional.If you don't like it, just write a function to do it all at once. (later)



Python:
Code: [Select]dict = {'Dog':'Woof', 'Cat':'Meow','Cow':'Moo'}
print dict['Dog'];
print dict['Cow'];


Aside from allowing the dictionary/hash elements to be defined in a single statement (which is fully possible in VB.NET since it added variable initializers) I fail to see that much difference. And since one could easily write a short function that can create a dictionary out of a parameter array in VB6:

Code: [Select]Public Function CreateDictionary(ParamArray Elements())
Dim I As Long
Dim returnDictionary As Dictionary
Set returnDictionary = CreateObject("Scripting.Dictionary")
For I = LBound(Elements) To UBound(Elements) - 1 Step 2
returnDictionary.Add Elements(I), Elements(I + 1)
Next I
Set CreateDictionary = returnDictionary
End Function

Which allows the code to be shortened:


Code: [Select]Dim dict As Object
Set dict = CreateDictionary("Dog", "Woof", "Cat", "Meow", "Cow", "Moo")
MsgBox dict.Item("Dog")
MsgBox dict!Dog

Of course turning off Option Explicit would mean that the declaration could be removed as well. Which of course would certainly fit with your own concepts on the issue (that typing is bad, it would seem).

The C# code I presented was apparently not simple or straightforward either, because it followed the clearly flawed idea that showing steps one at a time (adding each item) was confusing and difficult. I present this modified version that uses the Collection Initializer SYNTAX to initialize the Dictionary upon creation:

Code: [Select] public static void testdictionary(){
//Dictionary<String,String> dicty = new String[] {"test"}.ToDictionary((w,String)=>
Dictionary<String, String> dicty = new Dictionary<String, String>()
{
{ "Dog","Woof"},
{ "Cat","Meow"},
{ "Cow", "Moo"}

};

Debug.Print(dicty["Dog"]);
foreach (var q in (from x in dicty
where x.Key.StartsWith("C", StringComparison.OrdinalIgnoreCase)
select x).ToArray())
{
Debug.Print(q.Key + "=" + q.Value);
}
}

The Collection initializer syntax can work for any class that implements IEnumerable, or on Dictionaries that have more dictionaries as either their key or value (for whatever reason). I do not believe this is available in Python. (it probably is but I only did a very quick google).


But, this is all rather redundant. The reason Python and Perl are constantly mentioned has absolutely nothing to do with wether they are better (which is not even a metric one can measure, because it implies there are "right" ways of doing things, which is a complete lie. There is no "correct" way for a language to initialize a Dictionary, just as there is no "correct" way to Add elements to it. The only reason you continue to argue such a case is because you refuse to accept any other. For example you believe that strongly typed languages are "wrong" and should "only be used for systems programming". Why? You made no case against this, you simply stated it as a fact. You line of reasoning here seems to be that everything that python does is all you need. and the syntax is uses is the only right syntax for said feature in any language. Therefore, because Python is statically typed, that is the only way any good language could possibly represent types. The way it implements Lambda Expressions (which present a somewhat limited syntax compared to, say, C# or F#, but still powerful) is therefore the definitive way to represent it. Anything that differs from python (or perl) is therefore clunky and awkward.

The thing is, it's not clunky and awkward to everyone else, just as not everybody will find python or perls syntaxes "simple and straightforward). You believe, for whatever reason, that Python, perl, and whatever scripting languages that you know are the one true way.

Quoted from http://blogs.msdn.com/b/rick_schaut/archive/2004/03/04/83679.aspx with a minor change:

Quote
You’ll find it in American politics, and you’ll find it in the religious wars of the software industry (from vi vs. emacs to Mac vs. Wintel to open source vs. proprietary software). The root cause is fanaticism, and that begins with the fervent belief that one is in possession of the One True Way. We’ve all met fanatics in one way or another. These are the people for whom there are only two ways to do things; their way and the wrong way. We might have even exhibited signs of fanaticism ourselves.

Now I know what you’re thinking. We don’t kill each other in the vi vs. emacs debate, and members of Congress don’t shoot at each other from across the aisle, or at least not yet anyway; that, somehow, this is what distinguishes us from the religious fanatics who strap bombs to their bodies. That would be a mistake. The only reason we don’t kill over our fanaticism is because the stakes aren’t as high. Our perceived way of life isn’t seriously threatened.

Once fanaticism takes root, the next step is polarization. Tim O’Reilly has written a couple of times about polarization. In a post last January, Tim pointed to some analysis done by Valdis Krebs, using the “related books” tool on Amazon, that shows how the books that people read tend reinforce their political preconceptions. The stark feature of Krebs’ graph is how few people read books that appeal to the other side of the map. The distance from this kind of polarization to Limbaughesque demonization isn’t very far.

Now, I wouldn’t write about all this, except for one thing: bloggers are in an interesting position with potential for combating fanaticism. First, with the variety of RSS feeds out there, we have the ability to expose ourselves to continuous streams of ideas from a number of backgrounds. If we disagree with someone, we can strive to understand what’s right about what they say, not just what’s wrong with it. Secondly, when we write, we can write to inform rather than write to convince. We can try to synthesize ideas from a number of camps into a more comprehensive understanding of the issues we’re discussing.

When it comes to polarizing issues, we tend to fall into confrontational patterns of behavior. Unfortunately, confrontational patterns of behavior very rarely, if ever, change the opinions of others. It might have a viscerally positive feel to it, but the outcome is no different than if we had not written at all. Most of the time, it only serves to polarize us even more.





Quote from: BC_Programmer on August 22, 2010, 09:31:52 AM
First off, I'll tell you this: It is not straightforward to use in Perl (Python is good, but hardly much different from VB6). I just struggled to get this to work for nearly half an hour:
that's because you are not familiar with either of them. If you are, you would not hit this problem. Here's how simple it is to do it with Python (similarly with Perl, but I like using Python, hence this example)
Code: [Select]>>> animals={}
>>> animals["cat"]="meow"
>>> animals["dog"]="woof"
>>> animals["cow"]="moo"
>>> animals
{'dog': 'woof', 'cow': 'moo', 'cat': 'meow'}
>>>

Quote
but to access the actual item, you need to use $.How is that straightforward? It might be straightforward to somebody familiar with it, but it's a *censored* of a pain in the *censored* to wrap ones head around when you haven't been playing with perl since you were in a playpen. In this case, I imagine that the characters aren't a sort of type-declaration characters at all, but more or less a type of access modifier that changes how the variable is accessed. in order to read a element from a hash, we need to access it in "scalar context", Usable? of course it is. But to claim this is easy and straightforward is to express how deeply polarized your opinions on the matter are.
stop whining. You have to be familiar with all 3 languages to make a fair comparison. What you are describing is a minor syntax issue. When you play with Perl more, you will be accustomed to it. We are actually talking about how hashes/dictionaries in these languages differ in terms of their flexibility using them

Now let's see a few examples of how easy it is to manipulate dictionaries in Python.
To get keys and values
Code: [Select]>>> animals.values()
['woof', 'moo', 'meow']
>>> animals.keys()
['dog', 'cow', 'cat']

Adding something to values of the items
Code: [Select]>>> animals["dog"]+="bark"
>>> animals
{'dog': 'woofbark', 'cow': 'moo', 'cat': 'meow'}
>>>

Now try doing that with VB.

How about sorting a dictionary. Python comes with sort utilities inbuilt. Where can i find that in VB?
Code: [Select]
>>> d = {'a':2, 'b':23, 'c':5, 'd':17, 'e':1}
>>> items = [(v, k) for k, v in d.items()] # reverse the values and keys
>>> items
[(2, 'a'), (5, 'c'), (23, 'b'), (1, 'e'), (17, 'd')]
>>> items.sort() #sort
>>> items.reverse() #reverse back
>>> items = [(k, v) for v, k in items]
>>> items
[('b', 23), ('d', 17), ('c', 5), ('a', 2), ('e', 1)] #now they are sorted.


Note the above is old way of doing sorting by dictionary values. Python's sort now comes with added functionality which makes it even easier to do sorting. Anyhow, how about doing that in VB. ? If you do a help(dict) at the python interpreter, you can use other dictionary methods that makes manipulation of dictionaries easy. Do you find that many in VB's version?


Finally, how about adding items from another dictionary to the the animals one?
Code: [Select]>>> vegetables={"spinach":"green","carrot":"orange"}
>>> animals.update(vegetables)
>>> animals
{'spinach': 'green', 'carrot': 'orange', 'dog': 'woofbark', 'cow': 'moo', 'cat': 'meow'}

Quote
But, this is all rather redundant. The reason Python and Perl are constantly mentioned has absolutely nothing to do with wether they are better (which is not even a metric one can measure, because it implies there are "right" ways of doing things, which is a complete lie. There is no "correct" way for a language to initialize a Dictionary, just as there is no "correct" way to Add elements to it. The only reason you continue to argue such a case is because you refuse to accept any other. For example you believe that strongly typed languages are "wrong" and should "only be used for systems programming". Why? You made no case against this, you simply stated it as a fact. You line of reasoning here seems to be that everything that python does is all you need. and the syntax is uses is the only right syntax for said feature in any language. Therefore, because Python is statically typed, that is the only way any good language could possibly represent types. The way it implements Lambda Expressions (which present a somewhat limited syntax compared to, say, C# or F#, but still powerful) is therefore the definitive way to represent it. Anything that differs from python (or perl) is therefore clunky and awkward.
You sure can ramble a lot of crap. Whatever defence of your favourite language you come to, the fact still remains. Dictionary manipulation in VB still does not compare to Python's. (Or Perl).
I do not have to convince you about anything, since you are obviously the same kind of person you say i am.

Quote
The thing is, it's not clunky and awkward to everyone else, just as not everybody will find python or perls syntaxes "simple and straightforward). You believe, for whatever reason, that Python, perl, and whatever scripting languages that you know are the one true way.
speak of the devil. You swear by VB don't you?








[/quote]Quote
The distance from this kind of polarization to Limbaughesque demonization isn’t very far.

I so agree.
Quote from: Salmon Trout on August 22, 2010, 11:26:22 AM
I so agree.


Indeed. I believe we have case and point proof above. Oh well.



Quote
Dictionary manipulation in VB still does not compare to Python's. (Or Perl).

I agree. I would imagine this difference is due at least in part on the fact that VB6 was pretty much evolved from the original BASIC, at least in some form. That, as well as the fact that it is more a "give you a few tools, you work out the rest" type of mantra. Python and Perl were both designed much later, and for different purposes. (BASIC was, at it's inception, "all-purpose"... Although I'm not sure what that meant back then, clearly not very much) Perl was, as it's name implies, originally designed for creating "reports" both languages have clearly grown into something else, with VBScript being used in ASP pages and Perl and Python also finding themselves available for use online in Apache modules.

The only difference is that dictionary support is built right into Python and perl as part of the language itself. Visual Basic had to be backwards compatible (for business reasons I guess) with QBasic and even to a point BASICA and GW-BASIC, so it didn't really have the luxury of introducing new syntaxes for things like dictionaries and collections. Besides, it didn't even support being a provider of objects (it could consume objects I VB2, I think, but I don't think they were COM based). Visual Basic 4 integrated VBA into the mix, which meant VB4 applications could use collections.

The main problem with the collection is, as you passively pointed out using a carefully constructed python snippet, is that the collection object, for whatever reason, is immutable. Or more precisely, it's elements are. in order to "change" a value you would need to actually remove it and add it again.

This is why the collection is best used to store a collection of objects, the objects themselves can have their properties changes and so forth without a problem from the collection. I believe this particular limitation may be because of the way the collection is implemented internally.

However, the Dictionary Object is almost purely the same as a collection with most of the limitations removed. for example, you provide the following:

Code: [Select]animals={}
animals["cat"]="meow"
animals["dog"]="woof"
animals["cow"]="moo"
animals
animals.values()
['woof', 'moo', 'meow']
animals.keys()
['dog', 'cow', 'cat']
animals["dog"]+="bark"
animals

You ask me to do something similar in VB. not too difficult.

[code]

Set Animals = CreateObject("Scripting.Dictionary")
Animals!cat = "Meow"
Animals!dog = "Woof"
Animals!cow = "Moo"
OutLn Join(Animals.Items(), ",")
OutLn Join(Animals.Keys(), ",")
Animals!dog = Animals!dog + "Bark"
OutDict Animals

Of course since the dictionary doesn't expose a way to get a string representation of itself it doesn't output those. And outln and out were both redefined by me to output to a textbox (as opposed to using Debug.Print).

As for a sorting routine, I would just use the class I wrote for that purpose. Besides, writing a sort routine isn't that hard, and one would only need to do it once. (bear in mind particularly the different problem domains of both python and VB6, VB6 comprises of "projects" and is used for creating applications. Python consists of an interpreter interpreting a single python file that may or may not reference other python files- it makes more sense in that case to try to put things such as sorting into built-in routines.


Quote
You have to be familiar with all 3 languages to make a fair comparison. What you are describing is a minor syntax issue

Funny, most of your problems with VB so far (aside from the sort one, I guess) have been "minor syntax issues". Besides, I even said as much in that paragraph:

Quote
It might be straightforward to somebody familiar with it




Quote
Finally, how about adding items from another dictionary to the the animals one?
For VB I would simply loop through all the keys and adding each key-value pair to the new array, just as I'm sure python is doing for you automagically behind the scenes. This isn't a problem in VB when you are familiar with it.


Quote
If you do a help(dict) at the python interpreter, you can use other dictionary methods that makes manipulation of dictionaries easy. Do you find that many in VB's version?

VB Classic? No. Of course not, it's based on COM which in and of itself is rather limited. and The person who developed the Scripting runtime did so in a single afternoon (Dead serious, I read that on Lieppert's blog I think) so they didn't think to add all this stuff. Besides, you can always write routines later.

Quote
speak of the devil. You swear by VB don't you?


Not counting this post I had an equal number of examples in C#. C# is now my main language, pretty much for the same reasons you go with python- more versatile... stuff. Generics alone would be enough for me to avoid returning to VB6 but combine that with LINQ and the gigantic class library and I may as well tear down the road back. But I still need to maintain my old VB6 applications.

I notice how you specifically pointed out VB6. VB.NET and C# have access to the framework and therefor have direct access to the many number of data structures available in the class library, such as List,SortedList,Dictionary,Stack,Queue and a number of others. No Tree structures for some reason though.[/code]Quote from: BC_Programmer on August 22, 2010, 03:24:48 PM
As for a sorting routine, I would just use the class I wrote for that purpose. Besides, writing a sort routine isn't that hard, and one would only need to do it once. (bear in mind particularly the different problem domains of both python and VB6, VB6 comprises of "projects" and is used for creating applications. Python consists of an interpreter interpreting a single python file that may or may not reference other python files- it makes more sense in that case to try to put things such as sorting into built-in routines.
if you have to write your own subroutines, then how is it easy as compared to inbuilt subroutines ? Are you going to distribute your subroutine so that every body who uses VB can use it ?

Quote
For VB I would simply loop through all the keys and adding each key-value pair to the new array, just as I'm sure python is doing for you automagically behind the scenes. This isn't a problem in VB when you are familiar with it.
but its still not easier than Python's like i said. You need to create a new array, loop through the items etc. I am sure Python also does that behind the scene, but I am spared from doing that myself.

2384.

Solve : C# RTF HTML editor?

Answer»

Hey all

Im developing a small HTML editor and im looking for one thing thats really annoying me. I see editors on website FORUMS just like this all the time where you click a button for example bold and a bold TAG appears in front of your cursor (little flashing line , cant remember the spelling) then you can type the thing you WANT in bold then click it again and the close tag appears there in front of the cursor.

Well this is where i need help. How can i make a string APPEAR in front of my cursor?

Ill have a look around but ive not seen anything on it so far... which is worrying...The textbox's "SelectedText" PROPERTY can be set. This inserts a string at the insertion point.k Ill try that... Sounds like what im looking for...

2385.

Solve : Outlook 2k7 - create and populate new word document in VBA?

Answer»

Hello again.

I need to create a word document in VBA, then populate it with positioned images and text. How do i go about this?


ThanksQuote from: molly coddlez on March 18, 2011, 09:06:04 AM

Hello again.

I need to create a word document in VBA, then populate it with positioned images and text. How do i go about this?


Thanks


Since you are creating a Word Document, you would first need to get the word OBJECT. in VBA, you can use CreateObject.

Then you would want to create a new document; then you can use the document and manipulate it as you see fit.


If you want, you can also add a reference to the "Microsoft Word Object Library" (Tools->References in the VBA EDITOR).

Once added, you can work with Word Objects:

Code: [SELECT]Public Sub CreateDocument()

Dim WordApp As Word.Application
Dim NewDocument As Word.Document
Dim InsertImage As String
InsertImage="D:\bcmountain2.gif"
SET WordApp = New Word.Application
WordApp.Visible = False
Set NewDocument = WordApp.Documents.Add(, , , True)
Set objSelection = NewDocument.ActiveWindow.Selection
objSelection.TypeText "Text before the picture"
objSelection.TypeParagraph
Set Shapes = NewDocument.Shapes
Set objShape = Shapes.AddPicture(insertimage)
objSelection.TypeParagraph
objSelection.TypeText "More text appearing after the picture"
objSelection.TypeParagraph
WordApp.Visible = True





End Sub

The above is a simple macro that demonstrates how to add basic images as "shapes" and text around that image.

You can also save the resulting document by using the SaveAs() Method (NewDocument.SaveAs())

Be careful if you don't quit the Application Object but leave it invisible, since it will still be a running process. Usually best to do what you want with Word, and either quit it or show the results of the VBA to the user (by changing the Visible property to true). I did that here, if you want it to be invisible and quit, remove that LINE and add WordApp.Quit() to the end.

2386.

Solve : Schedule-Making Form (maybe a JOB OPPORTUNITY)?

Answer»

So I don't know if all this is even possible, but I have a league where scheduling always takes us two weeks to formulate and would like to cut that time by generating a form like below. We usually have 300-500 teams, and there, roughly 30 different divisions, 12 different gyms, 3 different areas, and 3 different time slots. I want to be able to fill in a team's name and set their priorities, then repeat the process for however many teams we have. Then I'd like to be able to check which priorities should apply to populate the fields on our schedule page. Then, assuming the entire schedule wouldn't populate due to the amount of priorities set, I'd like to be able to repeat the process after unchecking a box to populate the remaining fields. Then of course repeat that process of deprioritizing and repopulating until the schedule is complete. The schedule page would include times, dates on a y-axis and gym locations on an x-axis, with certain times blocked off based on when and where we have gyms. We're more than willing to pay to get this done, or ANY advice would be great. We can give whomever a lot more info later, if you think you can get this done.


To see it, go to http://htmledit.squarefree.com/ or any html viewer to see the code below. Thank you!


Code: [Select]<CENTER><script TYPE="text/javascript">
FUNCTION searchBox()
{
elem = document.getElementById("team");

if(elem.value == "Team Name")
{
elem.value = "";
}
}

function searchBoxBlur()
{
elem = document.getElementById("team");

if(elem.value == "")
{
elem.value = "Team Name";
}
}

function init()
{
document.getElementById("other_box").focus();
}
window.onload = init;
</script>




<input name="email" name="email" id="team" value="Team Name" style="color: #aaaaaa" onclick="searchBox()" onblur="searchBoxBlur()" style="width: 180px;" type="text" />

<SELECT NAME="division">
<OPTION VALUE="">--- Division ---
<OPTION VALUE="url">4TH NIT
<OPTION VALUE="url">4th NCAA
<OPTION VALUE="url" >5TH NIT
</SELECT>

<SELECT NAME="days">
<OPTION VALUE="">--- Preferred Days---
<OPTION VALUE="url">Sundays Only
<OPTION VALUE="url">No Sundays
<OPTION VALUE="url">No Preference
</SELECT>

<SELECT NAME="times">
<OPTION VALUE="">--- Preferred Times ---
<OPTION VALUE="url">Morning
<OPTION VALUE="url">Midday
<OPTION VALUE="url" >Night
<OPTION VALUE="url">No Preference
</SELECT>

<SELECT NAME="locations">
<OPTION VALUE="">--- Preferred Area ---
<OPTION VALUE="url">North
<OPTION VALUE="url">Southwest
<OPTION VALUE="url" >Southeast
<OPTION VALUE="url">No Preference
</SELECT>


<SELECT NAME="gym">
<OPTION VALUE="">--- Preferred Gyms ---
<OPTION VALUE="url">Cherry Creek
<OPTION VALUE="url">Thornton
<OPTION VALUE="url" >Broomfield
<OPTION VALUE="url">No Preference
</SELECT>

<br><br>

<table width=880 height=50 border=3 cellpadding=5><tr valign="middle"><td><center><b>Set Priorities:</b></center></td><td><center>Division<input type="checkbox" checked> <font size=2><i>(must be checked)</i></font></center></td><td><center>No Repeats<input type="checkbox"></td><td><center>Days<input type="checkbox"></center></td><td><center>Times<input type="checkbox" ></center></td><td><center>Area<input type="checkbox" ></center></td><td><center>Gyms<input type="checkbox"></center></td><td bgcolor=#000000><center><input type="button" value="Populate Fields"></center></td></tr><tr><td colspan="8" bgcolor=#cccccc><center><font size=2><b>note:</b> The best method is to prioritize all first to populate the fields, then repeat while deprioritizing one category at a time.</font></center></td></tr></table>

</center>
<br><br><center>
<table width=880 height=50 border=1 cellpadding=5><tr><td><div align="justify">So I don't know if all this is even possible, but I have a league where scheduling always takes us two weeks to formulate and would like to cut that time by generating a form like above. We usually have 300-500 teams, and there, roughly 30 different divisions, 12 different gyms, 3 different areas, and 3 different time slots. I want to be able to fill in a team's name and set their priorities, then repeat the process for however many teams we have. Then I'd like to be able to check which priorities should apply to populate the fields on our schedule page. Then, assuming the entire schedule wouldn't populate due to the amount of priorities set, I'd like to be able to repeat the process after unchecking a box to populate the remaining fields. Then of course repeat that process of deprioritizing and repopulating until the schedule is complete. The schedule page would include times, dates on a y-axis and gym locations on an x-axis, with certain times blocked off based on when and where we have gyms.<b> We're more than willing to pay to get this done, or ANY advice would be great.</b> We can give whomever a lot more info later, if you think you can get this done.

</div></td></tr></table>

2387.

Solve : Run application from webpage *without* Wscript?

Answer»

Hello everyone,

I have a question that I've posted on Computing.net, but I think I've stumped people with this one--there's been no replies. Since this is Web Design, I thought you guys could help out.

Basically, I want to build a helpful GUI shell for Linux that will launch applications for users with icon thumbnails--similar to Ubuntu Netbook Remix or Symbian(tm). I do not care if there is a dialog box that comes up or not, and I'm open to *any* computer language within C, Java, or HTML/XML. I could build something around this, or just use a browser like Firefox(tm).

*ANY* replies are open, welcome, and would be GREATLY appreciated. I *really* would like to build this.And this is web design related... how?

Edit: duh, just reread the title.

This is impossible to do, by design, to my understanding. what your asking for sounds like access to the local file system. This is a breach of security which is why most good browsers on either Linux or windows will allow it. Think about it. If it was possible, any web page could execute arbitrary commands that could hoop the system or install viruses.This will probably receive more attention in the Programming forum, so I'm moving it there.@kpac: Thank you for moving the post! I appreciate it!

@BC_Programmer: Please TRY to understand. This is NOT designed in any way to be malicious, but helpful. I want to have a laptop run a custom Linux build--but with Fluxbox. GNOME and KDE demand too many resources--however, the problem is that there's no defined desktop. People who've used it are Windows(r) users that don't get it, asking "How do I open anything?" I only want to do this to make it easier. I'm aware of the risks. I also know there is a way to do this--I'm not giving up by calling it impossible.

Can what I've requested earlier be done in a program or any graphical browser in Linux? Please help out--I'm stumped here.

Quote

Can what I've requested earlier be done in a program or any graphical browser in Linux? Please help out--I'm stumped here.

It can be made a separate program, But my understanding of your original request was that you WANTED to do it with a web browser? That's not going to be possible unless you're also going to guide them through all sorts of permission SETTINGS and trusted groups, and that's assuming you can find a way to do it even with full control from the site itself, which I don't think is possible without the use of something like COM, which is only available on windows, and is probably best avoided anyway.

If you don't mean a web browser but pretty much any type of program, then you can create it. I misunderstood what you were requesting, I suppose, if that's the case.

But! a quick search reveals that, as with nearly any sort of FEATURE like this, there is already one available:

https://bbs.archlinux.org/viewtopic.php?id=40025

That's the topic I found. has a little info on setting it up via it's config file.

the site is here:

http://bbdock.nethence.com/Wow--I guess I should have done more homework on the issue.

Thanks! (I did not mean to get on you earlier--I just did not want to be accused of wanting to write anything shady, because I never purposely will do that to anyone.) I believe in "do unto others as you would have them do to you" and see it as relevant to computing.

BBDock will work for the purposes requested. Reminiscient of NeXTstep.

Again, thanks a million--this will make things easier. Wish I could have programmed, though.

2388.

Solve : Outlook 2k7 - open a mdb in VBA?

Answer»

hi peeps,

I need to know some VBA for outlook, i know what i'm doing in Access, but this needs to all be done in outlook.

I'm having trouble opening an external .mdb in VBA in outlook, normally in Access i would use the CurrentDB object. I just need to know if there is a way in code to open an mdb in outlook and assign it to a Database Variable so i can manipulate it in a way i am familar with.

Is this possible, if not how would i open the external mdb in outlook?

Thanks in advance you could use DAO.

In the VBA Editor, choose Tools->References

Look for "Microsoft DAO 3.6 Object Library" and add it (check it).


You can create a "Database" Object from a given filename using the following FUNCTION:


Code: [Select]Public Function LoadDatabase(ByVal Filename As String) As Database

Dim returndb As Database
Set returndb = DAO.OpenDatabase(Filename)
Set LoadDatabase = returndb

End Function


Generally, you can use the returned Database as needed in VBA (as you might use CurrentDB). Make sure to close it, though, OTHERWISE things can get hairy. (Normally Access keeps the database open, since it is using it, but with outlook you've created the database object yourself so it's up to you)Dude. LEGEND!!!!!!!!!!!!!!

Do you have ANY idea how long its taken me to squeeze that simple piece of INFO out of the INTERNET???

THANK YOU!!!!!!!!

XD

2389.

Solve : decompressing my computer?

Answer»

I am NEW to this. I only had 6mb on my pc so I decided to defrag. As it turns out, my pc was already set to defrag on a weekly basis. Then I got the bright idea to compress computer. I compressed my whole computer and now some proprietary software does not work. One of my ex-developers had the suggestion to delete the databse from SQL 2005 and then when I RESTARTED my siftware it coule reinstall it. Unfortunately because it was decompressed I couldn't open the database either to even delete it.
Is there any easy WAY (for a non computer programmer like myself) to reverse my compressed computer and put it BACK to how it was a few days ago?

Thanks for any help anyone has.

ps - right CLICK>decompress or unzip using 7zip was not an option I had available to meI truly have no idea what you could mean when you say "compress". You could mean NTFS compression, Windows Drivespace... or heaven forbid you rightclicked on your C: drive and sent it to a compressed folder or something...What software did you use to "compress" your computer?

2390.

Solve : Powershell adding IIS?

Answer»

Is there a way to add IIS to a WINDOWS 7 SYSTEM through POWERSHELL? I am looking to add all sub components and the IISHWC (hostable web CORE).

thanks,
wbrost

2391.

Solve : VB6 - Wildcards??

Answer»

What I'm trying to do is change the colour of keywords in a rich text box. I found a nice script on the internet which does just that, it finds any words passed to its sub and changes the colour to what was also passed to the sub. The problem is, I need to be able to change the colour of an unknown word between two #. For example, I need to change #word# to #word#.

Here is the code for the sub:
Code: [Select]Public Sub ColorWords(p_Rich As RichTextBox, p_strWord As String, p_Color As OLE_COLOR)
Dim intPos As Integer

With p_Rich
intPos = InStr(intPos + 1, .Text, p_strWord, vbTextCompare)
Do While intPos <> 0
.SelStart = intPos - 1
.SelLength = Len(p_strWord)
.SelColor = p_Color
intPos = InStr(intPos + 1, .Text, p_strWord, vbTextCompare)
Loop
End With
End Sub
And here is how you would call the sub:
Code: [Select]Call ColorWords(Userinput, "CHANGE", vbRed)(Userinput being the name of the richtextbox, CHANGE being the word to be coloured, and vbRed being the colour to change it to)

I tried changing "CHANGE" to "#*#" but that doesn't work, to "#" & * & "#", but that gives an expected expression error. How could this work?
No replies? It seems like my other thread got lots of replies, but I guess that was only because other members were arguing over which programming language is better than the next.Quote from: Helpmeh on August 25, 2010, 04:30:27 PM

No replies? It seems like my other thread got lots of replies, but I guess that was only because other members were arguing over which programming language is better than the next.


I didn't even see this thread until just now, actually. Your bump made it more visible


Short Answer: is that Instr doesn't support Wildcards. As the function documentation states, it finds the First occurence of a string within another string- there are no special characters.


There is, however, an alternative. One could create a alternate Instr routine- say, InstrLike() And allow to support wildcards.

An even better solution would be to create an InstrLike() Function that used regular Expressions... actually it's easier that way as well.

Code: [Select]Public Function InstrLike(ByVal Start As Long, ByVal String1 As String, ByVal SearchPattern As String, _
Optional Compare As VbCompareMethod) As Long


'normalize start ARGUMENT, otherwise Mid$ will error out.

If Start <= 0 Then Start = 1
Dim RegEx As Object
Dim Matches As Object
Dim LoopMatch As Object
Dim StrippedString As String
'Create a string consisting only of the area we are to search.
StrippedString = Mid$(String1, Start)
'Create the Regular Expression Object.
Set RegEx = CreateObject("VBScript.RegExp")



RegEx.Pattern = SearchPattern
'Create the match collection...
Set Matches = RegEx.Execute(StrippedString)
'if we don't find any matches, return 0.
If Matches.Count = 0 Then
InstrLike = 0
Exit Function
Else
'otherwise, return the first match location, ADD the start argument as well, for when start is specified.
'I use a for each here because I couldn't remember if matchcollection was
'0 or 1-based and I was too lazy to look it up.
For Each LoopMatch In Matches
InstrLike = LoopMatch.FirstIndex + Start
Exit Function

Next
End If



End Function

in order to integrate it into the function you gave, you would need to change both Instr() calls in the given routine to InstrLike.

An additional problem however is that you will now need to use Regular Expression escapes on all your searches. for most strings this isn't a problem, but things like slashes and periods and a few others need to be escaped if you ever use them.

For your scenario, you would now call the function like so:

Code: [Select]ColorWords Userinput,"#\S*#", vbRed

You might even want to modify the method to allow for an additional optional boolean argument that can be used to forgo the regular expression code and just directly call and return the result from Instr (could be useful to avoid using regular expression escapes when colourizing literal values)curious, why are you even using vb6? for School? for work? for fun? Quote from: ghostdog74 on August 25, 2010, 08:03:13 PM
curious, why are you even using vb6? for School? for work? for fun?
I was taught VB6 in school, and I just like the feel of it.Quote from: Helpmeh on August 30, 2010, 03:22:50 PM
I was taught VB6 in school, and I just like the feel of it.
not that its my business to interfere with what you like to do, but my $0.02 is , VB6 is old. You should get on and learn modern languages. At least, they can do what VB6 can, (Python/Perl/VB.NET/Ruby/Java etc) and is catered to modern IT technologyQuote from: ghostdog74 on August 30, 2010, 07:46:35 PM
not that its my business to interfere with what you like to do, but my $0.02 is , VB6 is old. You should get on and learn modern languages.
In a response that I'm sure will stun us all, I agree.

Quote
At least, they can do what VB6 can, (Python/Perl/VB.NET/Ruby/Java etc) and is catered to modern IT technology

C# FTW.

Also, my experiments with IronPython (and to a lesser extent, IronRuby) are great; I haven't upped to VS 2010 yet, but to my knowledge it's quite possible to have a single project that uses any number of CLR languages- you could implement one part in python, other parts in C#, Ruby, VB.NET, and so forth. it's great for taking advantage of the abilities of each language where their purposes make the feature nice and short.

TECHNICALLY you can do it with the older versions as well but the ability to have them all integrated in a single project in the IDE wasn't until 2010.

Another nice "side-effect" of the CLR-ization of Python into IronPython is that when you compile it, your users won't need to have the python interpreter. Sure, it's only a small download and I believe there are ways to inline it and stuff, but It's cool to be able to reflect on python/perl etc. defined CLR classes as if they were any other C# or VB.NET class, without any special treatment.

On the flip-side of course is that although on windows the .NET framework (in more recent versions) is preinstalled, python isn't, but with Linux, Python is almost always available, and it's Mono (the Linux/Mac framework implementation) that would need to be installed. Either way, though, nearly any of them will be better then VB6 as far as built-in language features go. Just thinking back to my attempts at implementing IEnumVariant in VB6 to define a custom enumerator which required like 5 extra classes and Actually memory editing the Vtable due to Visual Basic limitations on method names is enough for me to shudder. C# (and I'm sure VB.NET, and of course python and perl and other languages) can have an enumerator via a simple function/method.

When I first went into C# I figured I would still use VB6 a lot. I HARDLY ever use it now, and when I do, it feels, well, CLUNKY. As ghostdog likes to point out in our little arguments now and then, it doesn't even have a way to sort arrays or pretty well anything built in. That's sort of silly. I mean, sure, it's not designed for short scripts... but VBScript is and it doesn't have Sort either. I wrote a class and interface (the latter a result of VB6's lack of delegates/function pointers, which is more a artifact of age then it is of design oversight (or maybe some of both)) to sort Variant Arrays, but it's still type sensitive (it can't sort arrays of integers, for example) and I shouldn't have had to write it. The best sort of implementation is one where you call a sort function or method and optionally pass in a comparison routine delegate. This is how almost all modern languages implement this, and the more Object oriented languages even define interfaces that allow objects to sort themselves, as well, by defining comparison routines and interfaces.

And this doesn't even yet touch on the rising paradigm of "functional programming" epitomized in .NET as the first-class language F#. but most languages are capable of "functional programming" that have a concept of either function pointers (more messy, but still... doable) or lambda expressions/closures (python, perl (? I think) .NET languages, java, etc).

I got stuck with VB6 and refused to switch until a few months ago (3?) and now I consider C# my main language, and only really use VB6 for maintaining my older projects, which have for the most part fallen by the wayside. For example, BCFile was a file library intended to replace the file access statements (Open, Put, Get, etc) with an Object Model- MS does this sort of with the FileSystemObject but that's more geared for scripting and text files, mine was also going to be able to read and write binary data as well as alternate data streams.

It works fine, and is rather powerful, but there is a lot of stuff I had to do for the aforementioned custom enumerator that I ended up undoing because it turns out that messing around with the machine code of a compiled program can be unpredictable (who knew? ). But the thing is, That is the type of thing that should be built in.

Whatever you choose to switch to, make sure to stick with it. For your next project, instead of immediately starting a VB project, do it in Python, or C#, or whatever language you want to try. And STICK to it, don't give up and do it in VB anyway. The more small, and the more large projects you do in the language the better you will get and the more familar you will be with it. I started by rewriting my expression evaluator in C# from scratch, the idea was to best leverage the far more powerful Object capabilities of the language. I had the algorithms pretty well memorized and it was merely a matter of learning the syntax- the language, and learning how to best express myself. I started out constantly missing semicolons (due to my long years with VB6) but now I find myself adding semicolons to my old VB6 programs when performing maintenance.


2392.

Solve : CMD file using SET?

Answer»

I have a strange problem doing something that should be very simple. I'm running WINDOWS 7 Enterprise, no service pack installed.

I moved the code I was having problems with to the snippet below:


@echo off
SET var1 = this is a test
echo The variable is "%var1%"
set /p vinput = Enter a value
echo The input was "%vinput%"
echo The current variables that start with a v are:
echo set v


When I execute the batch file, I enter 'test' as the RESPONSE to the prompt.


C:\>test
The variable is ""
Enter a value test
The input was ""
The current variables that start with a v are:
set v


NOTICE that neither variable is set. However, if I issue 'SET V' from the command line, the variables are actually set with the correct values.


C:\>set v
var1 = this is a test
vinput =test


Any ideas on why this is not working? This is actually part of a more interesting batch file, but the variable setting is the only part I'm having problems with.Your batch script is working correctly, however it is not doing what you expect. You need to note some points of syntax.

1. Unlike some other languages, in batch scripting, white space (sometimes!) matters.

In a simple SET statement the syntax is set VariableName=VariableValue. Everything before the = sign is considered to be the variable name, and everything after the = sign (up to the last non white space character) is considered to be the variable value.

THUS this line

SET var1 = this is a test

creates a variable called %var1 % (notice the trailing space) which has the value " this is a test"

2. The situation is slightly more complicated with SET /P

Everything before the = sign is considered part of the variable name, but white space immediately after the = sign is ignored.

Thus this line

set /p vinput = Enter a value

creates a variable called %vinput % with a value of whatever the user types at the prompt.

Thus your commands echo %var1% and echo %vinput% show (correctly) null values since those variables are undefined.

This behaviour is unlike (for example) most dialects of BASIC where

VAR = value
var=value
var = value

all create a variable called "var" with a value of "value"

(I introduce a SET /P hint at this point. If you want to put white space after the user prompt so the user input does not immediately follow the prompt (it looks better) then you can use quotes like this

set /p var="Enter a value "
set /p var="What is your name? "
set /p var="Enter a value > "

The quotes are not shown on the screen.)

3. Finally if you want to see all variables with a name starting with the character v then the command

echo set v

is not the one to use, this will merely echo the text "set v". You just use the SET command followed by the initial letter(s) of the variables you are interested in.

eg

set v
set va
set vi



Excellent! Definitely not used to having to worry about a blank between the variable name and the '=' sign, most of my coding is in C.

Thanks much, that fixed the problem.

2393.

Solve : String Manipulation using C++?

Answer»

I wanted to play around with using string manipulation to divide very large numbers.

I will have a very simple input of the dividend and divisor and my program will print out the quotient and remainder. I will also be giving inputs with leading zeros but I will not include them in my output.

How would I accomplish this using string manipulation?

Thanks for your help. if its for WORK, why are you using C++
if its for homework, where are your code?
I am playing around with it I think I have it solved there are a few kinks I am working on. And what wrong with C++ it is widely used.Quote from: Circuit_Girl on August 30, 2010, 01:01:59 AM

And what wrong with C++ it is widely used.
Nothing is wrong. You can do whatever you want.
But i don't agree with C++ being widely used. It might be widely used back in the hey days, but nowadays, i don't see any use of C++/C , except for
1) if you are writing device DRIVERS where you have to interact with OS at low level
2) if you need the pure speed , such as if you are making a graphics game or something
3) maintaining legacy code written long time ago.

I will tell you what's more likely to be used than C++. Languages like PHP/Perl/Python/Ruby etc. Nowadays, its mostly about the web. You don't often see people using C++ (not that it cannot be done) to rack up a web site application. For system administrators, you don't see many of them writing scripts using C++. (this is not to say they can't produce their own tools using C++)

Besides this, using interpreted languages has its advantages, like quicker development time (you don't to compile, link etc), and they are almost nothing interpreted languages can't do that C++ can. You don't have to take care memory management, and pointers as well etc.



C++'s implementation of OOP is the biggest joke in the history of programming, too. It has one of the most complicated and context sensitive grammars.

Whatever it boils down to essentially C++ is just like C with a few extra macros for classes and stuff. (after all, the original C++ compilers compiled to C code which was compiled by a normal C interpreter.).

There are some "programmers" who seem to think that if you don't know C++, then your a "script kiddie" which is nonsense. As Ghostdog NOTES, if you can do in 5 minutes what takes 5 days to do in C++ then the only reason to do it in C++ would be due to programmer hubris.

C and C++ have nothing called "string manipulation". as far as C and C++ are concerned, you have arrays of characters, and a few functions that work with them as if they are strings. There are classes that can be used but they have terribly designed interfaces and method names that were probably selected in 1970 or something.

And don't get me started on name decoration....


In either case, I'm not sure if C++ has it (I believe it does) but I'm quite certain that python and perl have it (and if they don't I'm sure it can be found in a MODULE or on CPAN), and all the .NET languages have access to it through the framework, but there are "BigInteger" and "BigDecimal" classes that can be used in nearly any language, and they support all the operations, not just division.

Lastly: Even if C++ was widely used, that's hardly a good reason to use it yourself.

@BC, yes Perl/Python (others) do have libraries that deal with BigDecimals. etc. Its all there in the repositories
I am relearning c++ and going to start learning c#. I want to expand my knowledge and write some simple applications and only know how to do it in this language. As far as web programming, I agree PHP and Per kick *censored*. But I do not know how to program windows applications using these languages and I am unfamiliar with python and ruby, but I will learn, eventually.Quote from: Circuit_Girl on September 01, 2010, 12:01:45 PM
I am relearning c++ and going to start learning c#. I want to expand my knowledge and write some simple applications and only know how to do it in this language. As far as web programming, I agree PHP and Per kick *censored*. But I do not know how to program windows applications using these languages and I am unfamiliar with python and ruby, but I will learn, eventually.
PHP/Perl/Python/Ruby etc all have their own GUI packages. Also, libraries are created for interfacing with GTK or QT. So yes, you are able to create GUI applications with them.
2394.

Solve : Java GUI Help?

Answer»

I am currently trying to OPEN up a new jpanel when a button is pressed. i know this should be a simple task but i tend to work STRICTLY with text so i have little experience with GUIs (hence why i am working on it). i am using netbeans 6.9.1 for an IDE.Also note:
THIS IS NOT HOMEWORK.
just programming on my own to get use to java GUI'sIf i understood right your question, and if you are using swing, you should take a look here: http://download.oracle.com/javase/tutorial/uiswing/components/dialog.html

Please let me know if it was what you seek for ,and MARK question as "thanked" if my answer was oky. Not quite, im using the "Forum builder" in net beans (similar to VB), just WANTING to have a new forum (also designed in the builder) to pop up when you click a button. Sorry , i did not used that control.

2395.

Solve : Gamepanel and ftp permission?

Answer»

Hello to you.
Well let me explain .. I have a dedicated server (REDHAT) and GAMEPANEL (opbase) to manage a game server .. the gamepanel is HOSTED on another dedicated server. gamepanel communicates with the dedicated server. I need to install the sceen and sftp 2 thing's done. the problem is that I am unable to ftp created a user with the gamepanel because I have this error:

"Write" permission check failed.

Check folder / file permissions.
chown-Rf server1: server1 / HOME/server1

here is a picture:



throughout the game server and the user folder in the ftp home / user

think you be able to help me?

sorry for my bad english..Close please i fix the probleme

2396.

Solve : Batch: Input typed incorrectly?

Answer»

Hi, I am creating a small batch file that turns the user's input into a COMMAND.
For EXAMPLE,
Code: [Select]set /P input=What would you like to do?
if /I "%input%" EQU "EXIT" exit
if the user types "exit" then the cmd window will close.

My problem is that if the user inputs the command incorrectly (e.g. "eixt" instead of "exit") or inputs something that the cmd does not understand, then the cmd window closes on its own or goes to the NEXT label (e.g. :new).
How would you set it so that if the user inputs something UNKNOWN or incorrect then the cmd displays something like "The word "whateverwastypedwrong" is not a command."? I would like to know how to do it without using:
Code: [Select]if /I "%input%" NEQ "EXIT" echo "The word "whateverwastypedwrong" is not a command."
because if there are many commands such as "EXIT", "NEW", "COPY", "MOVE", etc etc etc then that single command line can become a bit of a mess.

Is there more of an efficient way of solving this issue?Why do you feel the need to do this? The fact that you foresee the error-checking getting unwieldy is a clue that it might be a bad idea. Anyhow, cmd.exe has done it all for you. It's called the prompt. One way I might do it (if I had to!) might be to have a text file containing a list of all the commands I wanted to select from and use FOR to compare the user input with each entry in turn.

Basically I am creating a file/folder management program with a batch file that can work on any of my associates computers so that they can manage notes taken in lectures efficiently AND because I'm simply interested in this small project anyway
That idea sounds interesting. Are there any alternatives to using a text file with a command list in it such as a line or a few lines of code that achieve the same thing without having to CREATE a text file and checking the commands in it? If not, then I'll probably go with that idea.When I first read your initial query I though you meant that you wanted users to be able to type in native console commands such as DIR, etc, but now I see (I think) that you wish them to be able to input command words of your own devising. You can verify that typed input matches an item in a list without using a separate file; the list can be held in a comma or space-delimited string...

Code: [Select]@echo off
set commandlist=start stop run copy move open close pause resume erase insert exit
echo Available commands: %commandlist%
:loop
set /p UserInput="Your command? "
set verified=0
for %%A in (%commandlist%) do if /i "%%A"=="%UserInput%" set verified=1
if "%verified%"=="0" (
echo Incorrect input - please try again
goto loop
)
echo Command OK

Ah yes! Thats exactly what I was looking for. Thank you very much
I'll mark this as solved.

2397.

Solve : Subfora suggestion?

Answer»
Here's a suggestion:

How about making subfora for each programming language? Or is that too MUCH?

Like:

Programming
C#
C
Objective C
C++
Java
Python
PERL

Or maybe..

Programming
Procedural
Non-Procedural

Dunno.

QUOTE from: Big on September 04, 2010, 05:49:26 AM
Here's a suggestion:

How about making subfora for each programming language? Or is that too much?


That's too much. And it begs further questions as to the organization of said sub-forums- do various Basic Dialects (RealBASIC, Visual Basic, Dark BASIC, etc, get their own forum or would they be even forther sub-divisions within a BASIC forum?

And even then, there are far too many languages to implement this. C,C++, BASIC,Java, Python, Perl*, C#, F#, Javascript, VBScript, Haskell, RUBY, TCL, PHP, ASP, Pascal, Delphi, Eiffel, Fortran, COBOL (yes, those last two are asked about every once in a blue moon, or at least a question relating to them is asked) REXX, Squeak, Boo, VBA, etc etc. And even if you can come up with a consolidated list, do you make separate entries for, say, J#, and J++? Do you have a separate area for using C++ with .NET CLI? Soon the organization becomes more chaotic then it was.

Besides, Nathan (admin) has been RATHER clear that he wants to try to limit the number of subforums as much as possible- a sentiment with which I must agree. It wasn't until rather recently that the Windows section was separated into various Windows Versions. The thing is, there are a finite number of choices, really. 9x,NT,XP, and Vista/7. When it comes to languages, you can either give them all their own specific subforum (which again raises the question, do various dialects get separate entries) or do you try to "group" them as you've indicated, Into Structured, Object Oriented, and Functional Programming languages. and even then, how do you decide? C#, for EXAMPLE, can be used as a Functional Programm languages just as well as a Object Oriented one- in fact, Object Orientation is mandatory, but with other languages, like python, you can choose to do whatever you want- structured, object oriented, or functional. How would you group that? And what about regular expressions? Would those have their own separate area? And would it have it's own sub-forums that relate to the various "dialects" of RegExp? (.NET, Java, Perl, JavaScript, etc). As you can see, what seems to be a simple idea to improve organization and make the forum easier to navigate may only serve to further confuse and make organization difficult. The more you try to classify and subdivide things the more you find they fit into common groups.

*Remember, It's Perl, not PERL, everytime you spell it PERL, Larry Wall emits a quiet sob. So that's two in this sentence alone. Sorry Larry.- Microsoft
- Non-Microsoft

Seriously, they've made SO MANY LANGUAGES. Quote from: Fleexy on September 04, 2010, 10:00:25 AM
- Microsoft
- Non-Microsoft

Seriously, they've made SO MANY LANGUAGES.

They've made one language that was ECMA ratified to my knowledge, C#. They've made a lot of IDE's though.Subfora? Did we start speaking Latin while my back was turned?
We constantly use numerous degenerations of Latin, English, Italian and German, almost not being aware of it (aquarium, fax, scenario, ..). 'Fora' is an accepted secondary form.
However, I come from a very linguistic background (when age 11 to 18, we get taught 16 hours of Latin per week in highschool).

Yes, there are more than a 1000 programming languages. So yeah.Quote from: Big on September 04, 2010, 12:16:39 PM
'Fora' is an accepted secondary form.

Yes, I know. I only recently gave up worrying about whether it was necessary to use Latinate plurals like fora, virii, stadia, etc.

Quote
However, I come from a very linguistic background

Yet you wrote "a 1000"


2398.

Solve : powershell printer question?

Answer»

Can some one please point me to an example of a Powershell script that installs a TCP/IP printer? unfortunately our department decided to stop using print servers so now we are forced to add printers using print to IP. I am looking for a script that will install a printer and use a TCP/IP port.

Thanks,
WbrostThis may help. It seems straightforward. Create instances of two WMI classes and fill in the properties with your local information.

Good luck. ok getting closer. I can get the first portion of the code to work but during the second part I get the following error message:

Exception calling "Put" with "0" ARGUMENT(s): "Generic failure "
At line:1 char:19
+ $objNewPrinter.Put <<<< ()
+ CategoryInfo : NotSpecified: ( [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

Below is the code that I am using to get this working.

$objPrint = [WMICLASS]"Win32_Printer"
$objPrint.psbase.scope.options.EnablePrivileges = $true
$objNewPrinter = $objPrint.createInstance()
$objNewPrinter.DeviceID = "Rhyne_235A_02"
$objNewPrinter.DriverName = "TOSHIBA e-STUDIO3510cSeriesPLC6"
$objNewPrinter.PortName = "Toshiba_3510C"
$objNewPrinter.Shared = $false
$objNewPrinter.Put()

thanks,
wbrostI RAN into the same problem and after some tinkering around at the Powershell command line, I suspect the problem is not with the put instruction but with the value of the properties. Specifically with the Drivername property.

It seems you can create a printer without a physical unit, but the driver needs to be INSTALLED. I was able to get this snippet to work simply by using the installed driver of a real printer on my system. Be sure the same port name USED in creating the port is used when creating the printer.

Code: [Select]# -----------------------------------------------------------------------------
# Script: PSH-WMI-setTCPIPPrinterPortInstall.ps1
# Author: Powershell Community
# Date: 02/22/2011 11:07:40
# Comments: Install a printer to TCP/IP port
# -----------------------------------------------------------------------------
#Requires -Version 2.0

$PortName = "MyPort"
$PrintDriver = "HP Deskjet 930C/932C/935C"

#Create the port
#
$objPort = [wmiclass] "Win32_TcpIpPrinterPort"
$objNewPort = $objPort.CreateInstance()

#$objNewPort.psbase.scope.options.EnablePrivileges = $False #if using W2K3 use $True
$objNewPort.Name = $PortName
$objNewPort.HostAddress = "10.10.10.10"
$objNewPort.Protocol = 1 #1=RAW (default) 2=LPR
$objNewPort.Put()

#Create the Printer
#
$printer = [wmiclass] "Win32_Printer"
$newprinter = $printer.CreateInstance()

$newprinter.DeviceID = "My New Printer" #This property req'd
$newprinter.Drivername = $PrintDriver #This property req'd
$newprinter.PortName = $PortName #This property req'd

$newprinter.Shared = $true
$newprinter.Sharename = "ShareName"
$newprinter.Location = "Office"
$newprinter.COMMENT = "Comment"
$newprinter.Put()

<#
Use Get-Member on $newprint and $objNewPort to retrieve all properties
and methods available
#>

Good luck.

Quote from: Sidewinder on March 01, 2011, 04:34:39 PM

I ran into the same problem and after some tinkering around at the Powershell command line, I suspect the problem is not with the put instruction but with the value of the properties. Specifically with the Drivername property.

It seems you can create a printer without a physical unit, but the driver needs to be installed. I was able to get this snippet to work simply by using the installed driver of a real printer on my system. Be sure the same port name used in creating the port is used when creating the printer.


If any one is having this issue you can try the neat little utility MS provides to do this. And the best part is you can point to an INF over the network. This is how I solved the issue I was having above.

C:\Users\ss947bw>pnputil /?
Microsoft PnP Utility
Usage:
------
pnputil.exe [-f | -i] [ -? | -a | -d | -e ]
Examples:
pnputil.exe -a a:\usbcam\USBCAM.INF -> Add package specified by USBCAM.INF
pnputil.exe -a c:\drivers\*.inf -> Add all packages in c:\drivers\
pnputil.exe -i -a a:\usbcam\USBCAM.INF -> Add and install driver package
pnputil.exe -e -> Enumerate all 3rd party packages
pnputil.exe -d oem0.inf -> Delete package oem0.inf
pnputil.exe -f -d oem0.inf -> Force delete package oem0.inf
pnputil.exe -? -> This usage screen
2399.

Solve : DOS Help for Beginner?

Answer» HI Guys,

I HOPE you can help, I have a file and WITHIN that file I have about 20 ODD lines of information, what I basically want to do is copy the FIRST bit of information and ouput it to another text file so for e.g.

\\blah\blah\blah.pj ->xxxxxxxx
\\blah.pj ->xxxxxxxxx
\\blah\blah\blah\blah\blah.pj ->xxxxxxxx
\\blah.pj ->xxxxxxxx

I want all the info from \\ to -> ouputted to another file.

Thanks in advance for your help
You posted the same request for help in the Dos forum - please do not double post.
2400.

Solve : Batch file with options?

Answer»

I would like to create a batch file with options of software to install from our network. I've TRIED search google and couldnt really find what I was looking for but know its possible.

So when you start it I would like it to have like 12 options.

Type the number corresponding with he PROGRAM you would like to install and press enter.

1 - Microsoft Office 2003
2 - Microsoft Office 2007
3 - Adobe Pro 9
...
...
...
and so on.

Any help would be GREATLY appreciated!
Thx

CODE: [SELECT]@echo off
:loop
echo Install what?
echo 1 - Microsoft Office 2003
echo 2 - Microsoft Office 2007
echo 3 - Adobe Pro 9
...
...
...
set /p choice=Option #:
if "%choice%" GTR "NUMBER OF OPTIONS" cls & echo Invalid option! & goto loop
goto %choice%
:1
start install microsoft office 2003
exit
:2
start install microsoft office 2007
exit
:3
start install adobe pro 9
exit
...
OK?

You need to have one of these for each thing you want to install:
Code: [Select]:NUMBER
start install PROGRAM
exit
Remember to properly add the installer.