Jump to content

Recommended Posts

Posted

Ok, it another dum calculator. This code is incomplete. I have not put in error functions yet, and variables need to be localized. I need to know if I am using the right precision and if any other quirks are spotted, Can you please let me know?

 

Thanks,

The Buzzard

UCCv1.zip

Posted

Quick one:

 

you can change this:

 

(setq C:VT (strcat ""(eval U:INT)""(eval T:YPE)""))

 

To this:

 

(setq C:VT (strcat U:INT T:YPE))

 

As U:INT and T:YPE are both Strings.

Posted
Quick one:

 

you can change this:

 

(setq C:VT (strcat ""(eval U:INT)""(eval T:YPE)""))

 

To this:

 

(setq C:VT (strcat U:INT T:YPE))

 

As U:INT and T:YPE are both Strings.

Thanks Lee,

 

I will make those fixes. Feel free to disect it. I put this together fast, But I find sometimes I get in over my head.

Posted

Other than that - looks pretty good.

 

I'll be honest with you, that type of coding is not the kind that I like - its very tedious, and you can't really be very "clever" with the code, as the conversions are there and set in stone.

 

I suppose you could tidy it up a bit, like, for instance convert the answer to a string before the conditionals and set the tile to the result of the conditional - taking out the repetitive functions within the conditional statement, but, other than that, I can't instantly see much more you can do :P

Posted
Other than that - looks pretty good.

 

I'll be honest with you, that type of coding is not the kind that I like - its very tedious, and you can't really be very "clever" with the code, as the conversions are there and set in stone.

 

I suppose you could tidy it up a bit, like, for instance convert the answer to a string before the conditionals and set the tile to the result of the conditional - taking out the repetitive functions within the conditional statement, but, other than that, I can't instantly see much more you can do :P

 

One problem I noticed with it example: Select inches to millimeters enter the value then calculate. Right after that scroll down one or two and repeat. Then select another type of conversion such as temperature and try to calculate it and it will not happen unless you reclick in the convert section on Fahrenheit to Celsius.

 

I know I have to go thru it completely, But I tend to do things sometimes in a rush.

Posted
One problem I noticed with it example: Select inches to millimeters enter the value then calculate. Right after that scroll down one or two and repeat. Then select another type of conversion such as temperature and try to calculate it and it will not happen unless you reclick in the convert section on Fahrenheit to Celsius.

 

This seems to work OK for me - the value is calculated when I click "Calculate".

 

As another option, you could add an action_tile statement to the edit_box such that after the user has entered something, it performs the calculation.

Posted
This seems to work OK for me - the value is calculated when I click "Calculate".

 

As another option, you could add an action_tile statement to the edit_box such that after the user has entered something, it performs the calculation.

 

I guess you mean instead of conditionals setting the the tile.

Posted
I guess you mean instead of conditionals setting the the tile.

 

No, still use the conditionals - but just have it run through the calculation program when the user enters a value in the edit_box :)

 

I'll have a play and see if I can post a few examples of what I mean :)

Posted

For example, something like this to set the answer value variable:

 

 (setq VAL2
   (cond
     ((= "IMPLEN0" CAI)(* VAL1  25.4))
     ((= "IMPLEN1" CAI)(* VAL1   0.305))
     ((= "IMPLEN2" CAI)(* VAL1   0.914))

   ....

   ) ; End Cond
 ) ; end Setq

 

 

Also, you could use your UCC_RAC function to set the values of the tiles, instead of setting them in the COND statements:

 

Changing the UCC_RAC to:

 


(defun UCC_RAC (VAL1 VAL2)

 (set_tile "VAL1" VAL1)
 (set_tile "VAL2" VAL2)
)

 

And altering the relevant action_tile reset statement to

 

(UCC_RAC "" "")

 

I would convert the variables VAL1 and VAL2 to strings before the COND statement, hence:

 


 (setq VAL1 (rtos VAL1 2 1) VAL2 (rtos VAL2 2 1))
 (setq VAL2
   (cond
     ((= "IMPLEN0" CAI)(strcat VAL1 " in"      " = " VAL2 " mm"))
     ((= "IMPLEN1" CAI)(strcat VAL1 " ft"      " = " VAL2 " m"))

     ...

     ) ; end COND
  ) ; end Setq

 (UCC_RAC VAL1 VAL2)

 

Just a few suggestions :)

Posted
For example, something like this to set the answer value variable:

 

 (setq VAL2
   (cond
     ((= "IMPLEN0" CAI)(* VAL1  25.4))
     ((= "IMPLEN1" CAI)(* VAL1   0.305))
     ((= "IMPLEN2" CAI)(* VAL1   0.914))

   ....

   ) ; End Cond
 ) ; end Setq

 

 

Also, you could use your UCC_RAC function to set the values of the tiles, instead of setting them in the COND statements:

 

Changing the UCC_RAC to:

 


(defun UCC_RAC (VAL1 VAL2)

 (set_tile "VAL1" VAL1)
 (set_tile "VAL2" VAL2)
)

 

And altering the relevant action_tile reset statement to

 

(UCC_RAC "" "")

 

I would convert the variables VAL1 and VAL2 to strings before the COND statement, hence:

 


 (setq VAL1 (rtos VAL1 2 1) VAL2 (rtos VAL2 2 1))
 (setq VAL2
   (cond
     ((= "IMPLEN0" CAI)(strcat VAL1 " in"      " = " VAL2 " mm"))
     ((= "IMPLEN1" CAI)(strcat VAL1 " ft"      " = " VAL2 " m"))

     ...

     ) ; end COND
  ) ; end Setq

 (UCC_RAC VAL1 VAL2)

 

Just a few suggestions :)

 

Thanks Lee,

 

I just tried combining the calculation conditional with the answer conditional and it worked. Not sure If I will go with that. I will try out the samples you posted and see what happens.

 

Thanks

Posted

Another thing (major thing here):

 

Why are you using a sub-function with an argument:

 

(defun UCC_CAI (CAI)

 (setq CAI (strcat ""(eval U:INT)""(eval T:YPE)""(eval C:NV)""))
...

 

But immediately setting the value of the argument to something utterly different?

Posted

If you change the Calculation function to handle the argument obtained from the VAL1 tile, it would a much better way to pass data between functions, than using variables that are global throughout the sub-functions.

 

i.e.

 

(defun UCC_CAI (VAL1)

 

And in the action_tile statements:

 

(action_tile "CALC"   "(UCC_CAI (atof (get_tile \"VAL1\")))")

 

Also, you could include an action_tile statement for the edit_box:

 

 (action_tile "VAL1"   "(UCC_CAI (atof $value))")

Posted
Another thing (major thing here):

 

Why are you using a sub-function with an argument:

 

(defun UCC_CAI (CAI)

 (setq CAI (strcat ""(eval U:INT)""(eval T:YPE)""(eval C:NV)""))
...

 

But immediately setting the value of the argument to something utterly different?

 

At the the time I was trying different things and overlooked that. As I said before, I get way ahead of myself.

Posted

Regarding putting the action_tile statement on the edit_box, I have used this technique in this program, to avoid use of an unnecessary button.

 

The tile key in this instance is "wc_str", the user would enter a filter string and hit enter to run the action_tile statement, instead of using a button.

 

Just an option to consider. :)

Posted

Thanks, I will review.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...