PDA

View Full Version : Opening files



rhfurniture
09-04-2006, 05:57 AM
Hi,
Can someone fill me in on the right way to open files from a part program. I don't seem to get past:
OPEN "shopbottempZvalue.sbp" FOR INPUT AS 1
or
OPEN "shopbottempZvalue.sbp"
or anything in between the two.
I'm probably just being stupid, but the programming handbook seems confusing at best on this one.

Thanks,

R.

rhfurniture
09-04-2006, 07:31 AM
I've tried everything, including:
OPEN "shopbottempZvalue.sbp" FOR INPUT AS #1
OPEN "shopbottempZvalue.sbp" FOR INPUT AS £1
OPEN "shopbottempZvalue.sbp" FOR INPUT AS 1
OPEN "shopbottempZvalue.sbp" FOR INPUT AS /1

Driving me bonkers....

r.

phil_o
09-04-2006, 08:00 AM
If I understand correctly what your question is "Can someone fill me in on the right way to open files from a part program?" The answer is: go to the file menu in the SB control software, the first menu item is Part file execute. Or simply type FP. This will open the folder from which you can select the file you want to cut.

rhfurniture
09-04-2006, 08:10 AM
Sorry Phil, I should have been more explicit.
This is for a statement in a part file I am writing whose purpose is to open an external file (it could be anything.txt) to write a z value for temporary safekeeping.

As an alternative, there may be some user accessable system variables, but I cannot find any documentation for that (Bill?????).

R.

r.

Ryan Patterson
09-04-2006, 08:42 AM
Rh,
The first one in the your list should be right. You will need to use the drive letter and directory of the file.
Ryan

bill.young
09-04-2006, 08:53 AM
Hey,

If you want to write a value to a file you'll want to open it for Output, not Input. It also helps to create a variable with the full file name and path and then use that in your OPEN statement. Try something like...

&outname = "C:\sbparts\shopbottempzvalue.sbp"
OPEN &outname for OUTPUT as #1

..and see how that works. Also don't forget to close the file when you're done with it with

CLOSE #1



Bill

bill.young
09-04-2006, 09:09 AM
Sorry..I missed your second question.

*) Variables in ShopBot are persistent which means that once you give them a value they'll hold onto it until you either give them a new value or close the ShopBot software...that wipes the slate clean. So if you just want to save a value during a cutting session you could create a new variable and save your z-axis vaue in it like this...

&savedZ = %(3)

...and then use that variable later on in any file and it would still have that value (as long as you haven't shut down the ShopBot software).


*) If this is a value that you want to use a lot and that won't change very often, another option would be to write it to it's own file as a line like this...

&savedZ = 1.23

...and then you could call that new file within any of your part files with an FP command and that variable would be loaded and usable. That's the way the "my_variables" file works in the "C:\sbparts\custom" folder...it's called by the zeroing routines and loads all your tool-specific values.

Hope this helps,
Bill

rhfurniture
09-04-2006, 09:27 AM
Ahhhhh
Works now.
Thanks.

PS: howz about an uptodate, comprehensive, one document, programming manual?

R.

rhfurniture
09-06-2006, 05:08 AM
Hi,
Now I'm stuck with the following:

&oldZ=%(3)
'Press Enter to adjust Z to saved zero setting
PAUSE
&outname = "C:\sbparts\shopbottempzvalue.sbp"
OPEN &outname FOR INPUT AS #1

dvanr
09-06-2006, 08:11 AM
It looks like your missing a comma

INPUT #{number}, &variable1, &nextvariable, &and_so_on

It does work as I used it write and read to do a spiral.

For more details.
Try the documentation in Shopbot\Developer Tools\Docs
Read SbW_ShopBotProgrammingStatements
(part of the software package download for the SB3 controller)

Not real obvious , I stumbled across it when Bill talked about his VB File Runner program.

rhfurniture
09-06-2006, 08:32 AM
I quote (cut&paste) from my current programming handbook:
INPUT #(openfilenumber) &variablename { ,&variablename, &variablename,
etc }

Comma?
Ok, so it is in the file you mention, BUT they still send out the 03 programming handbook which is HOPELESSLY out of date with the current PRT program

PLEASE can somebody pull it all together.
I NEED a correct full reference. It is costing me HOURS.
Rant over. (hair falling as I speak)

I'll see if it does the trick next time shopbot stops.

paco
09-06-2006, 09:28 AM
Aren't you looking at WRITING in the file instead of reading in a value?

Check out 'C:\Program Files\ShopBot\Developer Tools\Docs\SbW_ShopBotProgrammingStatements.txt'

---------------------------------------------------------------------------------------------------------
INPUT, INPUT #
Works like it has, except that INPUT calls up a message box for user input that provides OK/Cancel Buttons. Cancel removes the box and ends the program. OK enters the values in the box. If the box is empty and only one variable is expected, it treats variable as empty string and continues. If more than one variable is expected, an empty box is the same as a cancel. INPUT #_ reads in variables from a file as strings or numbers.

INPUT "Optional Text Message" &variable1, &nextvariable, &and_so_on
INPUT #{number}, &variable1, &nextvariable, &and_so_on
---------------------------------------------------------------------------------------------------------
WRITE
(note comma vs semicolon in the syntax below ... this is all pretty much the same as DOS version)
Write #?, (data list, items separated by comma) ... This is the standard way to use Write function. Separate each data item by a comma and they will be evaluated and separated by commas in the output file. A semicolon as the last character will surpress the line feed in the file being printed to.

Write #?; (data list; items separated by semicolons) ... This is an alternative Write function in which all spacing characters are surpressed except those explicitly supplied in data list. A semicolon as the last character will surpress the line feed in the file being printed to. For example, to generate: &myVar = 23.5 in the generated file you would use:

&someVar = 23.5
Write #1; "&myVar = "; &someVar

Or if you wanted to generate: M2, 23.5, 23.5 you would use

&someVar = 23.5
Write #1; "M2, "; &someVar; ", "; &someVar

Thus, the Write #?; version of the Statement gives the most explicit control of punctuation in the output file. Alternatively, the last statement could have been produced more simply with:

&someVar = 23.5
Write #1, "M2", &someVar, &someVar

** Currently can not have a comma inside quotes to write with Write #?, but you can accomplish this using the more explicit controls of Write #1; ...

-------------------------------------------------------------------------------------------------------

I find it this doc most of the latest stuff... don't hesitate to get in touch with SB support for help.

rhfurniture
09-06-2006, 09:51 AM
Paco,
I'm looking to read from the file in this instance. Apparently you open the file with an OUTPUT flag if you want to write to it and open a file with an INPUT flag if you read from it. This is the reverse of what I am used to in autolisp.

R.

PS Please can we all put pressure on shopbot for a unified, up to date, CLEAR, and comprehensive programming manual.

bill.young
09-06-2006, 07:53 PM
Hey Ralph,

Dick is correct...we try to keep the most current changes to the Programming commands in that SbW_ShopBotProgrammingStatements document. As soon as we get some time we'll redo the programming manual...it's definately on the todo list...but until then that doc is the best place to look. Hopefully I'll cover some of these issues in the next couple of Bill's Corner articles as well.

If you find changes that are not in that doc it would be a big help if you would email them to me and I'll make sure they get put in.

Bill

rhfurniture
09-07-2006, 04:53 AM
Bill,
It's been on the todo list for at least a Year now. (we've had this conversation before...). Could I suggest you include the document as a version ammendment *alongside* the programming handbook in both the control software and the download section of the web site.
Does it mean, by the way, that if I write a file to the current standard, it will not work if I re-instate 3.1.14? (my last favourite)

Thanks,

R.

rhfurniture
09-07-2006, 06:20 AM
OK, it works now, thanks to Dicks comma..

r.

bill.young
09-07-2006, 08:08 AM
Ralph,

All the programming commands should work the same in 3.1.14 as they do now, and except for the new commands like PLAY and some changes to the way text is handled and message boxes are displayed they should work the same way as they did in the DOS software.

That said, 3.1.14 was pretty early in the evolution of the Windows software and my guess is that there may be some commands that may not have worked correctly back then, especially in Preview mode. If so it's not from changes to the commands but from bugs in an early version of the software.

Bill