Post Reply 
Handy Subroutines
03-19-2015, 02:00 PM (This post was last modified: 03-19-2015 02:02 PM by DrD.)
Post: #1
Handy Subroutines
Over time many handy subroutines have evolved that are especially useful. Things like the recent discussion of TUpper, and its inverse TLower for ASCII case management, for example.

Would having an "Important Thread" item that could warehouse useful subroutines be of any merit?

I can offer this one, which is designed to rescale a data point value from an (old min to old max) range to a (new min to new max) range. I've found it very handy, and have used it in several different prime programs:
Code:

//  ============================================
//                                                                                                      =
//                                      Rescale                                                 =
//                                                                                                      =
//  Input:     Datapoint d in range (old min, old max)      =
// Returns:  Value in range (new min, new max)              =
//                                                                                                      =
//  ============================================
rescale(omn,omx,nmn,nmx,d) 
BEGIN
   RETURN (((d-omn)*(nmx-nmn))/(omx-omn))+nmn; 
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Handy Subroutines - DrD - 03-19-2015 02:00 PM
RE: Handy Subroutines - bobkrohn - 03-19-2015, 03:37 PM
RE: Handy Subroutines - salvomic - 03-19-2015, 04:05 PM



User(s) browsing this thread: 1 Guest(s)