PDA

View Full Version : Random Numbers



bcammack
05-23-2006, 03:37 PM
I sure do wish that SB control language had a RND() function to return a random number that fell between two passed values. Either that or it had the ability to call external libraries or dlls to extend it in such a fashion.

Why? I am bonding an unetched PC board to an unused area of the worktable to use as a fixed Z-plate. It'd be nice to send the carriage to a random point within the space occupied by that plate before probing to set the Z-axis zero height.

Why? So I don't eventually wear out the copper cladding in a single location that comprises about 1/100th of a percent of the total surface area of the PCB by repeatedly poking it with a carbide bit.

Ryan Patterson
05-23-2006, 04:32 PM
Brett,
I would think you would be able to write your own random number using a variable and a little math. You could use the shopbot.opt file to store this variable for the next time you start the control software. With a little thought it it could be done.
Ryan

robtown
05-24-2006, 06:21 AM
I've never piddled with the progrogramming aspect of the shopbot software, but can you call an external file, like maybe a .vbs file?

Ryan Patterson
05-24-2006, 08:31 AM
No, but you should be able to use the UN command in a part file to change the name of the editor to another progam. Then use the "FE" to open that progam. I have not had the need for this but it should work.

bcammack
05-24-2006, 10:14 AM
So, in some strange way one could possibly call an external program that generates a random number, writes it to a simple text file, closes, and then main program could read that file and apply that random number.

I imagine that the FE call would be asynchronous so I would need to follow it with a PAUSE of sufficient length for the new value to be written out.

Wierd, but, I'll play around with it.

Thanks.

kivimagi
05-24-2006, 10:34 AM
How about creating a text file with a list of random numbers, which you could generate with this:

http://www.segobit.com/rng.htm

And then just grab a new line each time from the text file.

will that work?

paco
05-24-2006, 10:41 AM
How about using RND command/programming statement?!... in document 'calculated_functions.pdf' (C:\Program Files\ShopBot\Developer Tools\Docs\calculated_functions.pdf)

bcammack
05-24-2006, 01:16 PM
These are with out a doubt the most inscrutible manuals I've encountered recently. Thanks, Paco.

I really don't understand why we cannot have a single, monolithic "Language Reference Manual" that contains *all* of the available functions of the language.

I don't know if I'm programming or playing "whack-a-mole" with the documentation sometimes.

patricktoomey
05-24-2006, 01:42 PM
I don't even see that file in my docs folder. I just downloaded 3.4.23PRT and all I have in the developer tools/docs folder are 3 .txt files, SbW_CommandLine_Format.txt, SbW_Limit_Stop_Action.txt and SbW_ShopBotProgrammingStatements.txt Any idea why it wouldn't be in the latest release and am I missing anything else? I'm writing software to do some pretty funky things with the ShopBot and knowing all available commands and functions would help me out a lot.

bcammack
05-24-2006, 02:34 PM
Here's what I wrote to test the concept. I couldn't find INT() documented anywhere, either, but figured that shouldn't stop me from trying it anyway.


&iteration = 0
&result = 0

LOOP:
&iteration = &iteration + 1
IF &iteration > 20 THEN GOTO OUT_OF_HERE
&result = (INT((RND(1) MOD 1.000) * 1000) / 1000)
PRINT &result
GOTO LOOP

OUT_OF_HERE:

mrdovey
05-27-2006, 10:20 AM
I haven't been lurking as much as I should have been...

Brett asked about invoking an external program. I wrote a program (mrd_edit.exe) and set it up as my default editor. I can use it to either invoke a real editor for normal editing (I have gvim set up to do SBP syntax highlighting) or, if the "filename" begins and ends with a '$', the program hands everything between the first and last '$' to a fresh MS-DOS command shell. Obviously, the first "word" of that string should be the name of an exe, com, or bat file. Any additional "words" are passed to the invoked program as command line parameters.

FWIW, on my system FE is synchronous - SBP processing awaits termination of the editor.