gusano79 247 Posting Shark

Try moving the sound playback from the form constructor to an event handler for Form.Load--I'm not sure if this will fix it, but I've run into other kinds of problems related to doing too much in form constructors.

gusano79 247 Posting Shark

So if I'm reading this right, you have a file handle that was returned by io.open at some previous point, but you need the filename that was used to create the handle so you can truncate it. Yes?

For now, I'm assuming that we're talking about Lua 5.1.4 because it's the current release. Are you using anything older than 5.1?

The io library doesn't provide anything that can truncate a file, so it looks like you're on the right track with io.open("somefile.ext", "w+") if you need a 100% standard Lua solution.

I don't think Lua can help you directly on this one. io.open doesn't keep the filename around, so you'll need to keep track of the filename when you open it. The file handles that io.open returns are userdata objects, which you can't modify from Lua, so you can't just stick the filename string in the file handle, either. I think we're left with creating some sort of custom file object--at its simplest, it could be a table with two entries, one for the filename, and one for the file handle.

gusano79 247 Posting Shark

A few seconds with any Internet search will get you any number of articles on that subject you want.

Here's one from Microsoft

...and here's an Internet search if you don't want to type it yourself.

gusano79 247 Posting Shark

One calculator can make two operations (multiply and subtract).
Return the minimum number of operations needed to get to target (or -1).

Example:
Your multiply number is 5
Your subtract number is 7
Your target number is 20

Starting with 1, we have:
1*5*5=25
25-7-7-7=4
4*5=20
Since we used 3 multiplications and 3 subtractions, the total amount is 6

I can't solve this problem because I have problem with the dynamic programming

I think this is the general kind of approach you're looking for.

For your problem, try this type of approach:

  1. Use a data structure that tracks numbers and how many calculator steps it took you to get to those numbers.
  2. Start the list with just 1 (or whatever start number you want), after 0 steps.
  3. Go through the list and figure out which numbers you could get to after one calculator step.
  4. If one of those numbers is your target number, you're done.
  5. Otherwise, ignore the ones you just generated that are already in the list because you already got there in a smaller number of steps.
  6. If all of the numbers you generated are already in the list and you haven't found the target number yet, you're never going to get there; you're done.
  7. Otherwise, put the rest of the numbers in the list, with a number of steps one greater than the number you got them from.
  8. Go back to step 3.

gusano79 247 Posting Shark

Hello all. This is a quick question. I have learned quite a bit of assembly so far. One thing confused me though. Why would one push a register with nothing in it .

for example

push eax

I have see this happen in code even when nothing has been moved into it like. How would pushing an empty register result in anything. Any help please and thanks.

One reason you might do this is to save the value of the register so you can restore it later. In this case, you'd see a matching pop eax later in the code. This usually happens when you're about to do something that will change the value in the register, but you don't want to confuse later code that might assume you haven't changed it. This is common when writing procedures.

gusano79 247 Posting Shark

The program sums correctly but instead of only outputting one row's sum, it sums up all of the rows up until the input row and adds them all together.

This appears to be your problem:

cout<<"Which row would you like to sum? (0-39)\n"; cin>>sumnumber;
		
for(rows = 0; rows < sumnumber; rows++) 
{
	for(columns=0;columns<40;columns++)
	{
		answer += values[rows][columns];
	}
}

cout<<answer;

It does exactly what you say it does... starts at row 0 and goes to row sumnumber - 1 , summing everything along the way. Once you have sumnumber , you don't need to spin over all the rows; you know which row you need to sum:

cout<<"Which row would you like to sum? (0-39)\n"; cin>>sumnumber;
		
for(columns=0;columns<40;columns++)
{
	answer += values[sumnumber][columns];
}

cout<<answer;
gusano79 247 Posting Shark

this code works

cmbPI.DisplayMember = "FirstName"

but how to i append another parameter to the combo box.

In the code i have quoted below the first line works but the second doesn't.Why is that??

cmbPI.DisplayMember = "Firstname";
cmbPI.ValueMember = "LastName";

The MSDN documentation for DisplayMember and ValueMember have all the information you need.

You can put any kind of object you want in a ComboBox. The ComboBox doesn't know what the important properties are for your object, so you'll have to tell it. DisplayMember represents the name of a property to look for on objects in the ComboBox when displaying the list. These would work:

cmbPI.DisplayMember = "FirstName"
cmbPI.DisplayMember = "LastName"

This would not:

cmbPI.DisplayMember = "FirstName" + " " + "LastName"

...because there is no property named "FirstName LastName" on the objects you're putting in the ComboBox.

So—if the objects you're putting in the ComboBox have a single property that returns what you want to display, that's what you put in DisplayMember. ValueMember works in a similar way, but instead of indicating which property to use for displaying list items, it tells the ComboBox which property of your list objects to use for its SelectedValue property.

Read the MSDN documentation; follow links and read more documentation. It may be a little overwhelming at first, but it's the best way to learn exactly what is going on.

gusano79 247 Posting Shark

it give a value "System.Data.DataRowView" in the combo box.The code i wrote is added below.

cmbPI.DisplayMember = "FirstName" + " " + "LastName";

This is happening because there is no property of DataRowView called "FirstName LastName". It couldn't, because there's a space in there.

If you read the MSDN documentation for the DisplayMember property, you'll see that you have to specify the name of an actual property of the object you're putting in the combo box. The DisplayMember property doesn't actually do anything, it just tells the combo box where to get its value.

If there's a property of your DataRowView that will provide the text you want to show in the combo box, specify the name of that property here. If there isn't one, you can create your own class to wrap the DataRowView which provides a string-valued property that is formatted how you want, then put those objects in the combo box instead of using the DataRowView directly.

gusano79 247 Posting Shark

The project will basically need to track changes that occur within a string so they can be highlighted.

It looks like you need some kind of diff feature for your project.

This is a well-understood problem, and you should be able to find an implementation that meets your needs. One example is the Diff.NET, which includes a library called "MeneesDiffUtils" that may work well for you.

Ideally the application would spot that change in the string and prehaps inside a new word at the index of the change, say '<span class="Change">' and then the closing tag at the end of the change.

A diff library will tell you where all of the changes are, but you're on your own for deciding what to do with them. If you expect to be performing lots of string operations, I recommend you use a StringBuilder.

gusano79 247 Posting Shark

why in this code the "codeArray[]" is used??
what does its really means??

void FunctionTwo (int codeArray[]){
     cout<<codeArray[1];
}

When you declare a function parameter as an array, what really happens is that a pointer to the first element of the array is passed, not the entire array. It's basically the same as this:

void FunctionTwo (int* codeArray){
     cout<<codeArray[1];
}

Here's a page with some more explanation.

tux4life commented: It's all good :) +6
gusano79 247 Posting Shark

Im having trouble understanding offsets in computer science.

Segment and offset registers are used to represent memory addresses that are larger than your register size. Two registers are combined to create an address that you couldn't represent using just one register.

Various CPUs do this differently. If you're talking about x86 architecture, here are some Wikipedia articles to get you started.

Not sure if this is right but would this be the same 0:10 where 0 is the start of a segment of memory and 10 is the ending. So there would be 10 memory blocks allocated?

The whole thing represents a single memory location. No blocks of memory are actually allocated--the segment and offset just tell you where to start. See the articles linked above.

gusano79 247 Posting Shark

A port is just an extra number tacked onto your IP address. Basically, they exist so multiple applications can use the same IP address simultaneously when they use different ports.

I recommend Beej's Guide to Network Programming for increased understanding. The section on port numbers has a bit more explanation.

gusano79 247 Posting Shark

I have written a working calculator program but it will not work out negative inputs. For example, 3+2 = 5.0, but, -2+5 = Wrong type of expression (error message).

The user inputs the calculation which is called "expression". I have two stacks, one for operators and one for operands and the input is broken into tokens. I need to add a way of saying, if the first number is a negative do not add the '-' to the operator stack, and, if the number after a '(' is negative do not add '-' to the operator stack. However I cannot figure this out. Can anyone help? Thanks.

This is a little tricky because '-' is dual-purpose. One way to handle it is to keep track of the last type of token you processed (operator or operand). When '-' shows up after an operand, it's the subtraction operator; when it shows up after an operator (or at the beginning of the token stream) it's the negation operator. Then you can handle it whichever way is appropriate.

For more details, read about the shunting-yard algorithm.

gusano79 247 Posting Shark

Please explain about the Right and Left shift operators in java.. I am new to programming concepts.. So please explain me with examples..

Google is your friend.

They are bitwise shift operators. Here are some links to get you started.

thariqrasheed commented: thanks for the post +0
gusano79 247 Posting Shark
gusano79 247 Posting Shark

Thank you Gusano. Actually I found this one. This controls have everything I need for this project.

They look good!

gusano79 247 Posting Shark

I see that myCircle2 lying at the edge of myCircle.
How can I define the stroke style of myCircle such that myCircle2 will lie in the middle of myCircle ?

I'm not aware of any way to change the stroke to make it display the way I think you want it to. I think you are going to need to change the definition of myCircle2 so that it's centered on the same point, but has a smaller radius, for example:

Ellipse myCircle2 = new Ellipse();
myCircle2.Width = 375;
myCircle2.Height = 375;
myCircle2.Stroke = Brushes.Black;
myCircle2.StrokeThickness = 1;
Canvas.SetTop(myCircle2, 12.5);
Canvas.SetLeft(myCircle2, 12.5);
canvas.Children.Add(myCircle2);
gusano79 247 Posting Shark

... but I need something more like MS Project. ... It should be a kind of gant chart where I have to fill in tasks, and user must be able to add other details.

If you want to emulate Project, that's definitely a more DataGrid-like view. You can parse through the XML the same way you would to build a TreeView; just use the tree depth as a guide to indenting the first column of each row.

As for being able to expand and collapse rows in a DataGrid, the only thing I can think of right now is using parent/child tables--it doesn't feel quite right, but it would work.

The best thing would be a TreeView that also provides editable columns. Unfortunately, this isn't standard in the .NET Framework, but there are third-party controls out there. I don't know if the one I linked is right for you (and it's not free, if that's a requirement), but their screenshots look like the kind of thing you'll want.

gusano79 247 Posting Shark

Your original "if" statement mutated into a loop there... let's look at the "if" by itself first.

A basic assembly "if" block might look like this:

cmp a, 80
  jne notequal
  ; a == 80, do something here
  jmp done
notequal:
  ; a != 80, do something else here
done:
  ; program continues...

In your case, it can be a little simpler:

cmp a, 80
  je equal
  inc a  ; only increment when a != 80
equal:
  ; program continues...

You could write your loop using similar code, but the 8086 instruction set includes a LOOP instruction.

A basic assembly "for" loop block might look like this, using CX as your loop counter:

push cx
  mov cx, 80
label:
  ; do something here
  loop label
  pop cx

Note that LOOP counts down to zero.

gusano79 247 Posting Shark

I'm trying to implement windows form with data grid (or anything you say is better) which should represent a hierarchical data. This data are stored in a xml file which structure is as follows:

I would be very grateful if someone could tell me what is the best way to represent this data on windows form and how to do that.

The problem is that I can't use tree structure because I need to enter some data about this elements.

You could make a data grid work for this, but the tree view is much more appropriate for hierarchical data. You can enter data in a tree view; have a look a the TreeView.LabelEdit property. It lets you allow the user to edit tree node labels using the TreeNode.BeginEdit method. The MSDN examples give an idea of how it's used.

gusano79 247 Posting Shark

If I develop an app, and sell it on, would the end user need anything installed?

That depends on what kind of database you want to use... if it's a server-based database, like MySQL, and you don't want to host it yourself, then yes. I don't recommend actually requiring users to install database servers, however.

How do other app developers store data that's quick and easy to access?

The app I am working on needs to store inputted data, and use that data. I've read about SQL with C# but if I use that, won't the end user need SQL installed to?

If the database isn't user-specific, you might consider hosting the database yourself, which avoids the user having to install any extra software. If it is user-specific, you could also design the database for multitenancy, if it's appropriate to your application.

Otherwise, you're left with serverless databases. SQLite (there are ADO.NET providers available) and SQL Server Compact (if you don't mind registering for redistribution rights) come to mind. I'm sure there are others out there as well.

If you're willing/able to consider other options, the .NET framework has a lot of support for XML and related technologies, which I've found very useful for simple data storage and retrieval.

gusano79 247 Posting Shark

I am trying to create a collection that will store boolean relationships between a list of numbers. Normally I would create a 2d array but these numbers will always be dynamically changing. Sometimes there will be more numbers and sometimes less. What collection type can I use to store an unspecified amount of data that behaves like a 2d array??

I recommend some kind of dictionary collection, where the keys are instances of a class that holds the two numbers, and the values are the Boolean relationship. It still works like a two-dimensional array because you're keying the collection using pairs of numbers, but you only have to put in the number pairs you need.

gusano79 247 Posting Shark

My first guess would be that seed could mean a number to pass to the srand function, for random numbers.

That's one of the more common uses of the term. In crytography, you'll see "initialization vector" more often. In general, I'd understand "seed" to mean "initial value(s)"--in this case, values for part or all of the array. As Bench suggests, check with who's asking for details.

gusano79 247 Posting Shark

i have a path from 1 to n and this is a straight line. every line has a value. i need a way where the cost is smallest.

That's the shortest path problem; for any single source and/or destination, you'll probably want to use Dijkstra's algorithm.

gusano79 247 Posting Shark
string host = this.HostAddress.Text.Replace(@"\", @"\\");

Immediate reports host as:
"C:\\\\Program Files (x86)"
When it should report it as:
"C:\\Program Files (x86)"
the original text was:
"C:\Program Files (x86)"

Any thoughts?

Your call to Replace is correct, as you can demonstrate by running the following tests (the third one is supposed to be incorrect):

using System;

class Program
{
    public static void Main(string[] args)
    {
        // No @, double \
        WriteReplacement("C:\\Program Files (x86)");
        
        // With @, single \
        WriteReplacement(@"C:\Program Files (x86)");

        // With @, double \
        WriteReplacement(@"C:\\Program Files (x86)");
        
        Console.ReadKey(true);
    }
    
    private static void WriteReplacement(string text)
    {
        Console.WriteLine(
            "\"{0}\" --> \"{1}\"",
            text,
            text.Replace(@"\", @"\\"));
    }
}

...so I imagine there's something going on with the text in HostAddress .

I have to ask, though--why do you need to escape the slash in the first place? You only have to escape them when you're writing string literals in code. If you're getting typed input from the user, HostAddress.Text will be the correct path string, and doubling them up will confuse the standard IO classes.

gusano79 247 Posting Shark

I am currently running on windows and have and issue when i try to read/write files,the problem being that it just doesn't happen.

That doesn't give us very much to work with; it would help if you could clarify what "just doesn't happen" means. Is it truly not happening, as in the code appears to work but no files show up, or is it something else? Please post some details about exactly what is happening, including a short example of the code that's failing to work correctly.

gusano79 247 Posting Shark

I have a Windows Application which contains functions for Encrypt/Decrypt which is working fine when both the functions are put together as a single code. Now, I wanted to call encrypt and decrypt functions independently of each other, thus, I split the code temporarily in say, function1() and function2() for encrypt / decrypt respectively.

There are few parameters like key etc, which are created only during encryption, i.e. in function1() but will also be used when decryption, i.e. function2() would be called.

I am not able to access the values of the variables being created in the function1() from function2()

Is there any way I can achieve this?
Declaring the functions private or public doesn't make any difference. Also, I cannot create new keys as it would result in improper decryption.

If you're generating the key in function1, but it needs to be used in function2, then you should return the key somehow from function1 (as a return value, or in an out parameter) and pass it to function2 as a method parameter.

In general, I recommend separating key generation from the encrypt/decrypt methods; pass the key as a parameter instead, for example:

AsymmetricCipherKeyPair CreateKeyPair(ElGamalParameters parameters)
{
    ElGamalKeyGenerationParameters ekgParams = new ElGamalKeyGenerationParameters(new SecureRandom(), dhParams);

    ElGamalKeyPairGenerator kpGen = new ElGamalKeyPairGenerator();
    kpGen.Init(ekgParams);

    return kpGen.GenerateKeyPair();
}

byte[] Encrypt(byte[] data, AsymmetricKeyParameter publicKey)
{
    // Return encrypted data...
}

byte[] Decrypt(byte[] data, AsymmetricKeyParameter privateKey)
{
    // Return decrypted data...
}

Then somewhere else you have:

ElGamalParameters dhParams = new ElGamalParameters(p, g, …
gusano79 247 Posting Shark

Can mutation testing be successfully used in an industrial environment?

In general, I think it could. In practice, I haven't heard about anyone using it recently.

Also, by "industrial," do you mean any software development company, or did you have a specific type of business in mind?

Can anyone also let me know their views about whether mutation testing be successfully used to improve TDD from a defect reduction perspective or not?

Even if you're using test-driven design, you have to write the tests, then write the code, and only then can you do mutation testing... There can't be any defect reduction due to mutation testing because you've already written any (hypothetical =) defects before the testing starts; it's more about defect detection. The major advantage (IMO) is that it can help discover defects and deficiencies in your unit tests.

gusano79 247 Posting Shark

If you're only adding .1 or .25 etc, but the result shows up as something which isn't a multiple of .1 or .25, then y was clearly not equal to a multiple of .1 or .25 to begin with. In other words your initial y value must have been something weird; how was y initially set?

More likely it's due to floating point representation, in particular: The decimal value 0.1 has an infinite binary expansion, so it's impossible to represent accurately in a floating-point number.

gusano79 247 Posting Shark

whats going on?

Read about floating point accuracy.

how to get rid of this fuzyness particularly in cases where i know i'm just adding .1.

You might try sticking with integers and using fixed-point math... with the example you posted, you could use a scaling factor of 100: y would actually equal 53900, add 10 instead of 0.1, add 25 instead of 0.25. You'd just have to remember to divide by 100 when printing values.

gusano79 247 Posting Shark

This is the algorithm I am working on, however, I believe it is not working properly because it chooses points that are very close to each other to be centers:

If anyone can offer any insight on this, I would greatly appreciate it. The algorithm seems to only be selecting points far away from the first center (which is chosen randomly outside of the above loop.)

The pseudocode looks okay; I've attached a quick little .NET console program that appears to confirm your approach. This suggests to me that there might be some errors in your implementation of that algorithm. If you post actual code, we could have a look at it.

I am trying to write a clustering algorithm where, given location of certain points (I.e, latitude and longitude) I need to choose 50 of these to be cluster centers such that the diameter of each cluster is minimized. To that end, I believe that the program should choose the next center to be the point that is farthest away from all the previous centers.

Questions:

  • Are you assigning non-center points to the cluster with the nearest center?
  • Are you limited to choosing existing points as cluster centers, or can you use any lat./long. coordinate for a center?
  • Does "diameter" mean the distance from a cluster's center to the farthest point in each cluster?

It sounds like an iterative approach--something like Lloyd's algorithm--might be appropriate:

  1. Pick an initial set of centers (randomly, …
Agni commented: like the spirit :) ... +2
gusano79 247 Posting Shark

what you wrote is a c++ code..but i need assembly code for this(i.e-MIPS)

Ah. It helps if you say what you want when you post a question.

Well,this code is already the recursive implementation of factorial,Since it calls itself in the last line.The other approach for factorial would be the iterative one.

Almost... the return statement is missing, and we can optimize away the multiplication by 1:

int fact(int n)
{
    int i = 1; 

    while(n > 1)
    {
        i *= n;
        n--;
    }

    return i;
}

what you wrote is a c++ code..but i need assembly code for this(i.e-MIPS)

I don't know MIPS assembly, so you're on your own there... I'd recommend the iterative approach if you're doing it in assembly. In any case, the C functions should be more than adequate as pseudocode for your MIPS program.

gusano79 247 Posting Shark

I now the problem is in cout and in x. Can anyone help!

You're not using cout properly in the loop. It looks like you want cout << x . Here are some examples.

Also, the for loop isn't right. Here's a description of how they work. What you want is:

for (x = k; x <= n; x++)
{
    cout << x;
}

Explanation:

  • x = k : Initial statement. You want to start counting with k , so start x there.
  • x <= n : Conditional expression. You want to count all the way to n , so keep looping as long as x is less than or equal to n . You don't want x < n because that would stop your loop at n - 1 .
  • x++ : Loop statement. Add one to x each time around the loop. You don't need an extra x++ inside the loop.
gusano79 247 Posting Shark

what would be the recursive implementation of the following c program:

int fact(int n)
{
    if (n == 0) return (1);
    else return(n*fact(n – 1));
}

That is recursive. You've defined fact --a function that calls itself.

Did you mean "what would be the non-recursive implementation"?

Also, this should probably be moved to the C forum.

gusano79 247 Posting Shark

So an API is like a go between for the different applications right? If I call a certain function in the API, it will do something using the application sitting behind it...

Right. It might help to distinguish between the API and the application behind it--the API is more of a contract that is implemented/supported by the application when your software makes the calls.

gusano79 247 Posting Shark

I'm having trouble understanding the concept of an API. Could someone please explain what exactly and API does? A simple code example (if that's possible with this subject) would be really useful and much appreciated.

API == Application Programming Interface.

Application: You have an existing piece of software you'd like to use. For example, the Flickr API or the Canon SDK.

Programming: You're writing your own software to make use of the existing application. For example, your own version of the Flickr Uploadr or a program to control a camera to do time-lapse photography.

Interface: This is the details of how your software communicates with the existing application. This can vary widely, depending on the technology of the existing application and the language in which you're writing your own program. For example, one way of using the Flickr API is through RESTful Web requests (e.g., upload, delete); the Canon SDK is presented as a native library written in C whose API is a collection of C functions that use handles to refer to specific cameras, sets of configuration parameters, and files on a camera's data card.

APIs can be more fully object-oriented, like MOGRE--or much closer to the hardware, like programming for the Nintendo DS. In the case of the DS, there are a variety of ways to make it work, including …

gusano79 247 Posting Shark

how can i print the number in SI on the screen?

You'll probably need to copy the value of SI to a variable first, but it all depends on what libraries you have (or don't) for printing numbers in the system for which you are developing.

Could you post some information about the environment/system you're using?

gusano79 247 Posting Shark

Hi,

I am implementing a project where I have to use adaptive thresholding on an image. That is, the threshold value must not be global, but must adapt itself with the image. I have thought a lot, but am unable to get a logic. It would be really helpful if someone can help me with the code, or atleast the logic

Here's a link to get you started. Google is your friend. =)

gusano79 247 Posting Shark

File compression/decompression is a pretty complex task.

For that matter, so is encryption. What you're doing barely qualifies; it's a Caesar cipher, which provides no real security. It's fine as a quick and easy substitute in a homework assignment, but you'd never use it in the "real" world.

I want to compress the file encrypted and then decrypt the same original file.

I recommend that you compress first, encrypt second. Encryption usually hides the patterns and structure in data that make compression worthwhile.

Of course, the Caesar cipher you're currently using should compress just as well as the original data, precisely because of one of its weaknesses--it doesn't hide patterns and structure.

gusano79 247 Posting Shark

I wonder, what is picture/ image especially JPEG n GIF format ??
Is it lines of bit, byte, or binary ??

They are represented as sequences of bytes, which themselves are composed of bits, all of which is binary... I'm not sure what exactly you're asking there.

Graphics file formats aren't just "lines"--they have structure which is more complex than I think you think it is. I recommend you do a little research on your own first; these should get you started:

http://en.wikipedia.org/wiki/JPEG
http://en.wikipedia.org/wiki/Graphics_Interchange_Format
http://en.wikipedia.org/wiki/Portable_Network_Graphics
http://en.wikipedia.org/wiki/BMP_file_format
http://en.wikipedia.org/wiki/Tagged_Image_File_Format
http://en.wikipedia.org/wiki/PCX

gusano79 247 Posting Shark

Nah, these things happen to all of us.

gusano79 247 Posting Shark

Looks like your problem is that the for loop is incrementing n , but you're also incrementing it at the end of the loop:

for (n = 0; n < 49; n++) {
  putchar(bstr[n]);
  ++n;
}

That'll print every other character in the string, which is what you appear to be getting. Try this instead:

for (n = 0; n < 49; n++) {
  putchar(bstr[n]);
}
gusano79 247 Posting Shark

Im not sure how to capture the fields and tell the program to email the info.

Briefly:

  1. Create a string with values from the drop-down controls; String.Format is useful.
  2. Create a MailMessage object and assign your formatted string to its Body property.
  3. Create an SmtpClient object and use its Send method to send the email.

Read the MSDN documentation I've linked; it should get you on the right track.

gusano79 247 Posting Shark
<Root><Subject>xyz</Subject></Root>
<Root><Subjects><Subject>xyz</Subject></Subjects></Root>
<Root><Hierarchy><Subjects><Subject>xyz</Subject></Subjects></Hierarchy></Root>

Adding minOccurs="0" to Hierarchy/Subjects element does not suffice the requirement since then it doesnot expect Subject element.

That's because minOccurs only indicates how many times that element may appear; it doesn't relax any restrictions on the structure of conforming XML documents.

If you want the root element to contain different kinds of elements, you have to say it explicitly in the schema. In this case, it looks like you want a choice element, for example:

<xs:schema xmlns:xs="[schema namespace]">
  <xs:element name="Root">
    <xs:complexType>
      <xs:choice>
        <xs:element name="Hierarchy">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Subjects">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Subject" type="xs:string" maxOccurs="unbounded" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Subjects">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Subject" type="xs:string" maxOccurs="unbounded" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:sequence>
          <xs:element name="Subject" type="xs:string" maxOccurs="unbounded" />
        </xs:sequence>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

With this schema, someone writing a conforming XML document can now choose whether to use the "Hierarchy" element, the "Subjects" element, or just write a pile of "Subject" elements into the root element.

At this point, the schema is complex enough that you should start separating out complex types from the structure definition, primarily so you don't have to repeat the "Subjects" element definition:

<xs:schema xmlns:xs="[schema namespace]">
  <xs:element name="Root">
    <xs:complexType>
      <xs:choice>
        <xs:element name="Hierarchy">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Subjects" type="SubjectsType" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Subjects" type="SubjectsType" />
        <xs:sequence>
          <xs:element name="Subject" type="xs:string" maxOccurs="unbounded" />
        </xs:sequence>
      </xs:choice>
    </xs:complexType>
  </xs:element>
  <xs:complexType name="SubjectsType">
    <xs:sequence>
      <xs:element name="Subject" type="xs:string" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
</xs:schema>

For further readability and ease of modification/extension and maintentance, I'd …

gusano79 247 Posting Shark

When the user clicks submit I want the textbox information entered and any selections made in the ddl's to be emailed to the siteadmin(for example: siteadmin@admin.com). I cannot find anything on the web about how to code that submit button to do something like this and the jargon in the textbook doesn't go this in depth. Any help with the code here would be appreciated!

Have a look in the System.Net.Mail namespace in the .NET Framework class library. It provides types you can use to create and send SMTP messages; start with the SmtpClient class. The "remarks" section in the MSDN documentation provides an overview of how to create and send email with SmtpClient.

Of course, you'll need an SMTP server that's available to your application.

gusano79 247 Posting Shark

I am now making the huffman algorithm. I have generated the tree but I cannot generate the codes.. please if anyone can help tell me how?

See this article for a quick explanation and some examples.

From the article:

Traverse the constructed binary tree from root to leaves assigning and accumulating a '0' for one branch and a '1' for the other at each node. The accumulated zeroes and ones at each leaf constitute a Huffman encoding for those symbols and weights.

gusano79 247 Posting Shark

I solve the request properties as Boolean fields. The question is How can I decide which available fax machine can handle my request?

One way you might approach this problem is to start with a list of fax machines and go through it, removing machines that don't support the request. After that, the only machines left in the list are ones that support the request--you'd still have to decide what to do if you ended up with zero or more than one machine in the list.

Also, you'll want to rank features somehow to indicate fax machine support... for example, a B/W fax doesn't support a color request, but a color fax does support a B/W request. This is simple enough for your current problem, but probably needs a more formal solution if you get into multiple-choice options, e.g., fax machines that support one of 150/300/600/1200 DPI.

gusano79 247 Posting Shark

Returning to the original problem, even Java suffers from this risk of falling into infinite loops dues to recursive function calls.

C is designed with the assumption that if the the programmer does something, however strange it seems, it is because he means to do it.

C is notorious for giving you "enough rope to shoot yourself in the foot"--but it doesn't matter what language you're talking about... if it allows you to define a recursive function, you can always define one that never terminates.

Allowing recursion without this possibility is sort of like inventing a language in which untruthful statements aren't grammatical--a warm, fuzzy thought, but such a thing simply doesn't exist.

Sometimes recursion loops are detectable, but no development environment I've ever worked with has even bothered to try.

The halting problem is at the heart of this issue... I recommend you study it if you haven't seen it already. This version is more entertaining.

jbennet commented: thats an interesting link +21
gusano79 247 Posting Shark

Where are my sins?

As a general recommendation, you should read some technical documentation on the x86 instructions... this page is a good start, but the Intel processor manuals are the real deal.

As for your specific questions:

mul 5  ; ERROR Argument needs type override & Illegal immediate

operands to mul are either registers or memory locations; immediate values aren't supported.

cwd ; ERROR Argument needs type override& Illegal immediate ;we convert the word from ax in doubleword, in dx:ax
idiv 7 ; ax=b/7

cwd should be fine... this error might be for your idiv , which has the same restriction as mul --only registers or memory locations.

mov bx,intermed; Err. Undefined symbol Intermed

Not sure what's wrong off the top of my head.

gusano79 247 Posting Shark

Do you know have any assembly compiler can compile it?

Check out Wikipedia's article on the PIC; in particular, gputils might be a good place to start.