Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: ASP Problem 01

  1. #1
    Join Date
    Sep 2004
    Posts
    1,905
    Rep Power
    21

    Default ASP.Net Problem 01

    Create a web service that takes in an fraction and return a jpeg of the fraction. The input is of the xml form <numerator>placeholder</numerator><denominator>placeholder</denominator>
    where placeholder is a string that can be a number like "5" or some leters like "a+b".
    Finally write an asp web page that uses this service to show the fraction 1/4, and allows the user to edit the fraction by two integer fields, num and den.
    Last edited by crosswire; Sep 11, 2005 at 12:03 PM.
    Let's act on what we agree on now, and argue later on what we don't.
    Black men leave Barbeque alone if Barbeque don't trouble you

  2. #2
    Join Date
    Apr 2005
    Posts
    1,333
    Rep Power
    0

    Default Re: ASP Problem 01

    This is maybe a very simplified solution to the problem?


    'create images 0.gif - 9.gif (in numerical order) and slash.gif

    'get the numerator and denominator
    num = txtNumerator.text
    den = txtDenominator.text

    'get the length of numerator and denominator
    numL = len(num)
    denL = len(den)

    response.write "<center>"

    'read each numeral and display a corresponding gif
    for I = 1 To numL
    response.write "<img src='" & left(num, I) & ".gif'>"
    next

    'display the "/"
    response.write "<br><img scr='slash.gif'><br>"

    'read each numeral and display a corresponding gif
    for I = 1 to denL
    response.write "<img src'" & left(den, I) & ".gif'>"
    next

    response.write "</center>"
    The fox was probably right - they could have been sour grapes.

  3. #3
    Join Date
    Jul 2004
    Posts
    264
    Rep Power
    0

    Default

    Yes it is very simplified .... your solution does not take into consideration the fact that variables can be placed within the fraction... i also suppose that there should be some form of parsing of the xml input .... but since i am not a asp bluff i might think about trying it in php and see how it works ... btw ... what is the name of the xml parser object that can be used ....

  4. #4
    Join Date
    Sep 2004
    Posts
    1,905
    Rep Power
    21

    Default

    That solution is very good. I just did not expect it to be done without using .net. Just goes to show that there are many ways of solving a problem.

    Parsing the xml can also be done in VB scripting, as well. It is not complicated when string & parse functions are used.

    I would give you(CyberCat) full credit for the un-simplified version of your program which includes using letters(a+b).

    My solution will be written ASP.net. I would use a xml class in the .net framework to parse the input. (Do you guys use .net?) Then create an image of the numerator by printing a document that has the numerator centered. Do the same for the slash and the denominator. All images so far are printed to memory and they have the same width dimension. Then I use the graphics class to combine all the images, one on top of the other. Then convert the resulting image's fromat to jpg and return that. Honestly, I am not 100% certain that it can be done like this, but it would be good to find out or find another solution.

    In the simpliest form, let a doc = "1/2" then print the doc. And then the problem would be focused on writing the web service's interface, so that another web page can use the image as it wants. I did not specify that in the problem, so your web-service is correct as it is. Whatever fraction that the user inputs into the asp page, he receives the jpeg of that image Very commendable.

    If you choose to persue the problem further. Create a web page that displays the picture using its arguments eg page?num=3+den=4. Then create another web page that has two integer fields for num and den that the user can edit. Set the default to 1/4 for those feilds. Finally, inoke the first web page into the second web page by passing the parameters, num and den. Note that both pages may run on different servers with different urls. The result should be a web page that displays another web page.

    At aonekilla,
    You mentioned php, glad to see that you are thinking out of the box. The php way is OK.

    It will be a while before I post my solution since I am not the guru of web design.
    Let's act on what we agree on now, and argue later on what we don't.
    Black men leave Barbeque alone if Barbeque don't trouble you

  5. #5
    Join Date
    Sep 2004
    Posts
    1,905
    Rep Power
    21

    Default

    It was dumb of me to think that this could not be done easily in other languages other than .net, so I looked out for similar classes that I would use in other libraries. I got two ideas.

    1) based on C++ and the knowledge of the bitmap file. Create one wide bitmap with all the characters in the alphabet from a-z and 0-9. Then load that file into memory in a 2D array, just by copying the bytes while reading the file. Then index through the array and select a certain size of bytes and it will return a character of the alphabet. This method kind of stressing, even for some one who is good in C++/java

    2) this method uses the class in java awt (Abstact Window Toolkit)
    http://www.oreilly.com/catalog/javawt/book/index.html
    public abstract void drawString (String text, int x, int y)
    The drawString() method draws text on the screen in the current font and
    color, starting at position (x, y). The starting coordinates specify the left end
    of the String’s baseline.
    This is very similar to drawing letters to pictures, I will be using something similar in .net. Where you guys aware of this function? I am aware that the solution presented by Cybercat was simply, and you could have downlaod code from the internet to do this problem as well, so I appriciated that you tried you own code. However, be aware that you can use any popular comercial or open library. I am copying this snippet from a book "Excellent Html".
    Code:
    import java.awt.Graphics;
    import java.applet.Applet;
    public class HelloWordApplet
    {
    	public void paint(Graphics g) {
    		g.drawString("Hellooo world !", 20, 30);
    	}
    }
    The remainding factor, I guess, is on which machine will the code 'run' on, and must it be windows. I also would not know how to integrate this into ASP just yet...
    Let's act on what we agree on now, and argue later on what we don't.
    Black men leave Barbeque alone if Barbeque don't trouble you

  6. #6
    Join Date
    Sep 2004
    Posts
    1,905
    Rep Power
    21

    Default

    Spent all day reading on ASP, ASP.Net, DHTML, and XML Web Services. And I start to look at Cybercat response as the simpliest of all my implementations. I finished a part already in .Net, and I am just working on some more "issues" or rather reading.
    Let's act on what we agree on now, and argue later on what we don't.
    Black men leave Barbeque alone if Barbeque don't trouble you

  7. #7
    Join Date
    Apr 2005
    Posts
    1,333
    Rep Power
    0

    Default

    All this .net stuff is over my head for now. I have not the time to get into .net yet.

    Still playing around in ASP.
    The fox was probably right - they could have been sour grapes.

  8. #8
    Join Date
    Sep 2004
    Posts
    1,905
    Rep Power
    21

    Default

    It would be cool to do some asp pages. Whenever I go through some tough ones, I'll give the problems. I renamed this post from ASP to ASP.NET.

    A web service that does the reverse would be cool, though. That is, one that takes in the image then outputs the text. It would use a tough C++ algotrithm, or something.
    Let's act on what we agree on now, and argue later on what we don't.
    Black men leave Barbeque alone if Barbeque don't trouble you

  9. #9
    Join Date
    Sep 2004
    Posts
    1,905
    Rep Power
    21

    Default

    Quote Originally Posted by crosswire
    The remainding factor, I guess, is on which machine will the code 'run' on, and must it be windows. I also would not know how to integrate this into ASP just yet...
    *such a noob I am better than this *
    Let's act on what we agree on now, and argue later on what we don't.
    Black men leave Barbeque alone if Barbeque don't trouble you

  10. #10
    Join Date
    Feb 2005
    Posts
    73
    Rep Power
    0

    Talking

    I like going off the beaten track. Like useing flash to solve problems, well.... I just like using flash even if it is the common answer... Anyway, Pass the formula as a string to the swf file. It would be fairly easy but is that too far outside the box? It is not really a jpg or gif any more, but it does give you more flexability. For example you could send Formula=1/sqr((a/b)/5(x/y)) if you wanted to build a fancy parser in flash, which also wouldn't be too hard.

    hope that confuses the issue just a little

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •