+ Reply to Thread
Results 1 to 5 of 5

Thread: [E2 Help] Calculator

  1. #1
    Wire Noob Mole2006's Avatar
    Join Date
    Jun 2008
    Posts
    4

    Default [E2 Help] Calculator

    Hey, I have the expression all but working, the only problem is that my screen refuses to display the result when I hit enter .

    Here's the code:

    Code:
    @name Calculator
    
    @inputs N1 N2 N3 N4 N5 N6 N7 N8 N9 N0 Clear Mul Div Add Sub Submit
    
    @outputs Out OutDebug
    @persist Storage:array Value
    
    if(N1){
    	Value = Value*10 + 1
    	Out = Value
    }
    
    if(N2){
    	Value = Value*10 + 2
    	Out = Value
    }
    
    if(N3){
    	Value = Value*10 + 3
    	Out = Value
    }
    
    if(N4){
    	Value = Value*10 + 4
    	Out = Value
    }
    
    if(N5){
    	Value = Value*10 + 5
    	Out = Value
    }
    
    if(N6){
    	Value = Value*10 + 6
    	Out = Value
    }
    
    if(N7){
    	Value = Value*10 + 7
    	Out = Value
    }
    
    if(N8){
    	Value = Value*10 + 8
    	Out = Value
    }
    
    if(N9){
    	Value = Value*10 + 9
    	Out = Value
    }
    if(N0){
    	Value = Value*10
    	Out = Value
    }
    
    
    if(Clear){
    	Value = 0
    	Out = Value
    	Storage = array():clone()
    }
    
    if(Mul){
    	Storage:setNumber(0,Value)
    	Value = 0
    		if(Submit){
    			Out = (Value * Storage:number(0))
    		}
    	}
    if(Div){
    	Storage:setNumber(0,Value)
    	Value = 0
    		if(Submit){
    			Out = (Storage:number(0)/ Value)
    		}
    	}
    if(Add){
    	Storage:setNumber(0,Value)
    	Value = 0
    		if(Submit){
    			Out = (Value + Storage:number(0))
    		}
    	}
    if(Sub){
    	Storage:setNumber(0,Value)
    	Value = 0
    		if(Submit){
    			Out = (Storage:number(0) - Value)
    		}
    	}
    I've been racking my brains with this one, any ideas?

  2. #2
    Wire Sofaking IEF015's Avatar
    Join Date
    Feb 2008
    Location
    London, ON (Canada, eh?)
    Posts
    1,640

    Default Re: [E2 Help] Calculator

    http://www.wiremod.com/forum/wiremod...-tutorial.html

    There, a calculator made with EG2
    "It's my favourite country song. And I hate it."

  3. #3
    Wire Noob Mole2006's Avatar
    Join Date
    Jun 2008
    Posts
    4

    Default Re: [E2 Help] Calculator

    Quote Originally Posted by IEF015 View Post
    Yes, a very good one too, however I did not ask for an example of a calculator I want to know what I did wrong, it helps me learn.

  4. #4
    Wire Sofaking ZeikJT's Avatar
    Join Date
    Dec 2008
    Location
    California
    Posts
    1,391

    Default Re: [E2 Help] Calculator

    Quote Originally Posted by Mole2006 View Post
    Yes, a very good one too, however I did not ask for an example of a calculator I want to know what I did wrong, it helps me learn.
    Are you pressing multiply/subtract/divide/add at the same time as the submit?
    In the code it requires both to be on at the same time to output the value.

    submit alone does nothing.

    Also, it looks like you could be causing divide by 0 errors sometimes:
    Code:
    Value = 0
    		if(Submit){
    			Out = (Storage:number(0)/ Value)
    Against stupidity the Gods themselves contend in vain.
    -Friedrich Schiller

    The flame puts me in the mood to "Do it!".
    -Dart, Legend of Dragoon

  5. #5
    Wire Noob Mole2006's Avatar
    Join Date
    Jun 2008
    Posts
    4

    Default Re: [E2 Help] Calculator

    Ah I see my mistake, thank you for your help ^_^

+ Reply to Thread

Similar Threads

  1. Calculator!
    By Snake5 in forum Gate Nostalgia (Old School Wiring) Discussion & Help
    Replies: 16
    Last Post: 10-07-2007, 04:19 PM
  2. wired calculator
    By ext123 in forum Installation and Malfunctions Support
    Replies: 3
    Last Post: 08-15-2007, 09:04 AM
  3. Cpu: Calculator
    By cold12141 in forum CPU, GPU, and Hi-speed Discussion & Help
    Replies: 10
    Last Post: 05-02-2007, 03:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots