3D Clipboard

A place to discuss 3D Clipboard

Version 1.5 - Template Examples

Austin
Posts: 12
Joined: Wed Jul 06, 2011 9:16 pm

Version 1.5 - Template Examples

Postby Austin » Thu May 03, 2012 11:11 pm

Since version 1.5 of 3DClipboard (3DC) was recently released with the great new feature of Templates, I thought I would throw one out there to show some of the functionality that it could be used for.

Since I do a fair bit of Oracle programming, I created the template below to give me a skeleton function so that I can just begin to write my function. It uses much of the Templating syntax that 3DC currently supports and is usable in my everyday work environment. I simply have to select this Template, which by the way is also a Sticky, fill in the function name when prompted, and my basic function structure is created. Thanks 3DC!


Code: Select all

CREATE OR REPLACE FUNCTION {3DC:Schema:SCOTT}.{3DC:FunctionName} RETURN NUMBER
IS
/******************************************************************
  DESCRIPTION:  This function will
 
  CREATOR     DATE                COMMENTS
  -------------------------------------------------------
  Austin      {3DC$Time(%b %d, %Y)}        Created Function
******************************************************************/

  l_return_value NUMBER;
BEGIN
 
  RETURN l_return_value;
END {3DC:FunctionName};

Jesse
Posts: 8
Joined: Wed Jul 27, 2011 8:52 pm

Re: Version 1.5 - Template Examples

Postby Jesse » Tue May 29, 2018 11:51 pm

Well, I just worked out some improvements to the above.

This version does not require you to supply a Max from a clipboard entry, instead it completely ignores what clipboard entry you invoke it upon and uses an InputBox to ask you what maximum value you want to use.

My code defaults to 1e9 (that's lazytype for 1E09 aka 10^9 aka one billion), but feel free to change the default on line 1 if you wish.

Pressing cancel or entering a blank field (which VBscript views as indistinguishable) silently exits.

Entering a string, or a number less than 1 results in a helpful error message.

Entering a floating point value will behave identically to if the fraction were lopped off your input.

Result will be announced in a Message Box for the benefit of whoever just wanted to see the random number (without having to inspect clipboard or paste somewhere to see it), and results will also be pushed into the clipboard so all bases should now be covered. :D

Code: Select all

Dim max,result
max=InputBox("Max Value?", "Random Number Generator", "1e9")
If(max <> "") Then 'Detects cancel click, silently exits
  If((not IsNull(max)) and IsNumeric(max)) Then
    If(max>=1) Then
      Randomize
      result = CStr(Int(CLng(max)*Rnd))
      MsgBox("Random Number selected, and placed in your clipboard! :D"& vbCrLf & vbCrLf & CStr(result))
      clipboard.value = result
    Else
      MsgBox("Sorry, we need max to be one or greater, not "& CStr(max) &".")
    End If
  Else
    MsgBox("Sorry.. """& CStr(max) &""" isn't really a valid max value.")
  End If
End If


Return to “General Discussion”

 

 

cron