Crimson Programming Help

TimC114

Member
Join Date
Sep 2012
Location
Danbury
Posts
13
Hello all,

I am having a couple of issues trying to program an HMI using Crimson 3.0. I am no programmer, but I'm learning as I go and I can't seem to figure out a solution for these two issues:

Issue #1: I have successfully created a recipe system so we can save various machine parameters under a product name (ProductID). When a "save recipe" button is pressed, a new .txt file is created named after the current ProductID tag. Everything worked beautifully during testing, as I simply had the recipe files saved to the main directory on the compact flash card. Now, I have set up a "/RECIPE/" directory, since I also want to be able to save logs in a "/LOGS/" directory, and don't want the recipe lookup to see the other files that might be on the card. Since creating the directory, I have no problem saving the recipe files inside the /RECIPE/ directory, but I cannot figure out how to delete them.

What I want to do is have a "delete current recipe" button, which previously performed: DeleteFile(OpenFile(ProductList.ProductID));. This worked just fine until I started putting files into a directory.

Since the currently loaded recipe file name becomes the "ProductList.ProductID" tag, I want to be able to delete the file whose name is currently loaded.

So, I tried: DeleteFile(OpenFile("/RECIPE/+ProductList.ProductID")); But that's not working, since I think the program believes the "+ProductList.ProductID" is part of the syntax its looking for. But, that's basically what I want the program to do.

Can anyone help me figure out how to have the openfile command look for a file within the /RECIPE/ directory, yet have the file name be variable according to the tag?


Issue #2: I have a calculated value that always results in a decimal value (10.8, 11.6, etc.). These values are in inches, and I would like to have the displayed value rounded to the nearest 0.25 inches, or, at worst, rounded up to the nearest inch. Is there a way to do this via programming? Is there a built in method that I don't know about? What I want is 10.8 to show 11 and 11.4 to show 11.5 (nearest 0.25 is preferred).

Many, many thanks in advance.

Tim
 
1.) Are you making sure that the file is not open? (Closing it when finished) Openfiles() requires two parameters (name,Mode), I do not see the mode in your code. Can you post your program?

2.) I have the following from RL for rounding to an integer. You should be able to make it work for what you want.

Returns Integer (arg1 as float)

// this program accepts a Real argument and rounds it before converting to an integer
if(int(Arg1*10)%10 >= 5)
return int(Arg1)+1;
else return int(Arg1);
 
1.) Are you making sure that the file is not open? (Closing it when finished) Openfiles() requires two parameters (name,Mode), I do not see the mode in your code. Can you post your program?

2.) I have the following from RL for rounding to an integer. You should be able to make it work for what you want.

Returns Integer (arg1 as float)
Thanks for your response!

1) The previous program that worked had the mode set as 2:

"DeleteFile(OpenFile(ProductList.ProductID,2))"

2) Thanks so much! I'll try it!
 
I'm not sure what you are doing without seeing your program, but from what you posted
DeleteFile(OpenFile("/RECIPE/+ProductList.ProductID")); is incorrect.

it should be deletefile(openfile("/RECIPE/" + Productlist.productID,2)

Also, I would separate the open file and delete file functions out. If Crimson fails top open the file, it will return a 0. In this instance your command will be Deletefile(0,2) Also it will make it easier to diagnose if the problem is in opening the file, or deleting the file.

Second Verify that your tag productlist.productID is equal to a file on the Compact Flash. Is it possible, that you added the file extension twice (ie... test.txt.txt)
 
Glad to hear it... by the way, I may be incorrect on what open file will return if it fails.... I'm checking on this now.
 

Similar Topics

Hey everyone! Need a little help with some scripting in Crimson 3.0. With this first script I am just trying set a local variable string based...
Replies
8
Views
2,353
I am stuck, pretty new at c "like" programming. Trying to have a program run some comparisons to setpoints and variable data that comes in from a...
Replies
27
Views
5,522
Hi, I have a Red Lion E3 io counting output from weld cells, connected to a PTV station for the visuals. Our number of weld cells is set to...
Replies
2
Views
1,555
Good day I'm looking for a way to let crimson 3 monitor 3 temperatures from modbus then i want crimson to "GotoPage" when these 3 temps have...
Replies
3
Views
1,628
Hello all, First time here, So I want to take an analog input and total it over time. For example, the input would be in ml/s and I would like...
Replies
1
Views
1,484
Back
Top Bottom