Crimson 3.0 scripting question

bkottaras

Member
Join Date
Oct 2005
Location
Chicago
Posts
1,789
I'm using a recipe intensive application.
More than 500 and they must be named as numbers.
example "500.csv"
I can write a program running on the G306k to handle the Recipe creation files.
Here's my problem:
I'd like to name the recipe file dynamically.
Instead of CreateFile("Recipe.csv")
I'd like to dynamically assign a name to the CSV
file based on an integer selected from the screen
representing the recipe.
Something like:
CreateFile("Tag.csv")
Am I on the right track here?
 
I havent tried it so might be wrong but i would try

CreateFile("string")

where string is a string variable and is say "500.csv"
 
Supposing an integer tag exists called recipeNum:

Code:
cstring fname;
int hFile;

fname := "recipe" + IntToText(recipeNum,10,3) + ".csv";
CreateFile(fname);
hFile := OpenFile(fname,2);

...but I didn't think you could use these functions on the Kadet models. Am I wrong?
 
Last edited:
I was surprised that my little G304K will do data logging. I have not tried any scripted file creation yet. Soon, I'll have another one here I can play, er uh, 'develop' with. There doesn't so far seem to be much limitation on what the Kadet can do as far as functions.

I think bkottaras has a G306K which includes ethernet and a compact flash slot. I am sure one of the Red Lion guys will be on here to answer the question though.
 
Thanks guys.

I'll give it a shot when i get a chance.

Yes, G06K here.
The customer wants "#.csv" ormat saved on a CF if possible.
 
Here are a couple of programs for saving and retrieving a recipe that I wrote for an application similar to the one that you mentioned. Feel free to use them as a reference, but I can't assume any responsibility if they don't work as intended for your application.

Regards
 
Here are a couple of programs for saving and retrieving a recipe that I wrote for an application similar to the one that you mentioned. Feel free to use them as a reference, but I can't assume any responsibility if they don't work as intended for your application.

Regards
Thanks for the scripts.

I'll work with those as they seem to fit the way I name my tags.

SP_xxx for set points, etc.
Makes life easier wen looking for tags.
 
So far all of the answers have been correct. Unfortunately, one was Kolyur's mentioning that the CF card on the Kadets can ONLY be used for programming. While Data Logging can be enabled on the Kadets, that data is only stored in RAM to be used with Trend Viewers on the screen, it does NOT get saved to the CF card. Also, the Kadets are not able to access the CF card for reading/writing.

Regards,
Dan
 
So far all of the answers have been correct. Unfortunately, one was Kolyur's mentioning that the CF card on the Kadets can ONLY be used for programming. While Data Logging can be enabled on the Kadets, that data is only stored in RAM to be used with Trend Viewers on the screen, it does NOT get saved to the CF card. Also, the Kadets are not able to access the CF card for reading/writing.

Regards,
Dan

Sorry, I missed that. The scripts that I wrote were for a G308A in Crimson 2.0.

Regards
 
Sorry, I missed that. The scripts that I wrote were for a G308A in Crimson 2.0.

Regards
KP I appreciate the scripts.
I have started using both and adding parameters of my own.
Quick qusetion though, is there a limit if local variables I can declare?
I ran into an issue where I'm going over 255 and I get an error.
I did cut down and it seems ok once I'm under 255 (actually i tried 210 local variables) and get no erros.
If this is the case how do I go over the militation? (quick cheat or anything).

Thanks,

Bill K.
 
I switched to a G306A by the way in order to utilize the CF card.
Tag export and import worked like a charm.
Screens though, I had to open 2 instances of the software and do a manual copy (1to 1).
Same with comms, I had to re-define comms and gateway blocks.
i need to read up on the features, maybe there's a better/quicker way to export the entire project and import into a new one with the new hardware selected.
 
Quick qusetion though, is there a limit if local variables I can declare?
I ran into an issue where I'm going over 255 and I get an error.
Wow, 255 variables in one program? I think you should consider using arrays. I don't think you can create them as local variables (not in C2, maybe in C3), but you could create array tags. They are referenced in your program as:
ArrayTagName[index]
...where index can be a constant or a variable pointer.
 
Wow, 255 variables in one program? I think you should consider using arrays. I don't think you can create them as local variables (not in C2, maybe in C3), but you could create array tags. They are referenced in your program as:
ArrayTagName[index]
...where index can be a constant or a variable pointer.

I agree with kolyur, that is a lot of local variables... Usually, if I am doing a recipe of that size, I will use SQL Server. Maybe the RedLion guys have an idea. They are pretty helpful.

Regards
 
255 does seem like an awful lot of locals to declare. I assume you are declaring local strings for each 'ingredient', while this does make the code look nicer, it is not required. For example, in KP_EENG's example program he is declaring a local string Glycerin. Then using DecToText to convert the SP_Glycerin_Preset tag to a string:

Glycerin := DecToText(SP_Glycerin_Preset,0,3,1,0,0);

Later, Glycerin is used in the WriteFileLine function to add this value to the file:

write_file_OK := WriteFileLine(hfile,"Glycerin," + Glycerin);

You could do this all in one line, and avoid declaring the local variable:

write_file_OK := WriteFileLine(hfile,"Glycerin," + DecToText(SP_Glycerin_Preset,0,3,1,0,0));

OR you could create a string array (StringArray in the example below), which you use in place of the local variables, so the program looks a bit nicer:

StringArray[0] := DecToText(SP_Glycerin_Preset,0,3,1,0,0);

then later:

write_file_OK := WriteFileLine(hfile,"Glycerin," + StringArray[0]);

Regards,
Dan
 

Similar Topics

Hey guys, hoping someone here could give me a little advice. I'm working with a CR1000-04000 in Crimson 3.1 and I was interested in adding the...
Replies
4
Views
115
Hi, I'm having an issue in crimson 3.0 when I create a programme using a case statement referencing a fault word that each bit needs to change the...
Replies
4
Views
191
How do you install update on Red Lion Crimson ver 3.1. Do I just need to run the exe file on the host server?
Replies
1
Views
107
Has anyone found a way to convert/replace/update the firmware on old Parker TS80xx series HMIs (i.e. TS8010, TS8006, etc) to accept Crimson...
Replies
0
Views
91
Has anyone setup communications with Red Lion 3.0 MODBUS to Baker Hughes Centrilift GCS VFD? Thanks
Replies
0
Views
89
Back
Top Bottom