Can i put a delay in my script

Can you send the full code in a text file and I’ll try and debug it?

int:

Tset 1,0 //Initialize the timer and turn it off
Onchange “EW_1”, “@delaytest()”
Ontimer 1, “@timeroff()”

Function delaytest()
Tset 1,5 //In this example once the function is started, it will create a 5 second delay
Print"timer started"
Endfn

Function timeroff()
GOTO “WRITE_DI1”
Print"Function was executed after a 5 second delay" //In this section you can perform the actual delayed function
Tset 1,0 //Turns the timer back off afterwards
Endfn

end

WRITE_DI1:

DIStatus$ = “” //REM - Because I will be saying open/closed instead of 0/1 I need a string to track this.
IF(DI_1_MEM@ = 0) THEN
DIStatus$ = “DGITAL INPUT OFF”
ELSE
DIStatus$ = “DIGITAL INPUT ON”
ENDIF
//REM - Now below we will verify if the file exists on first cycle. If it doesn’t we will create the file and write the header. If it does exist we will just append the tag data.
SETSYS PRG, “RESUMENEXT”, 1
CLOSE 1 REM - Close the file just in case.
OPEN “file:/usr/DI_1_TEST.csv” FOR BINARY INPUT AS 1
ErrorReturned = GETSYS PRG, “LSTERR”
IF(ErrorReturned = 33) THEN
CLOSE 1
OPEN “file:/usr/DI_1_TEST.csv” FOR BINARY OUTPUT AS 1
PUT 1, “Time,TagName,TIME RAN (MIN),COUNTS (ON)”
PUT 1, CHR$(13)+ CHR$(10)
PUT 1, Time$ +","+ DIStatus$ +","+ STR$ DI_1_TIME@ +","+ STR$ DI_1_COUNT@ +","+ CHR$(13)+ CHR$(10)
CLOSE 1
ELSE

CLOSE 1
 OPEN "file:/usr/DI_1_TEST.csv" FOR BINARY APPEND AS 1

PUT 1, Time$ +","+ DIStatus$ +","+ STR$ DI_1_TIME@ +","+ STR$ DI_1_COUNT@ +","+ CHR$(13)+ CHR$(10)

CLOSE 1

ENDIF
END

Can you send it as a backup.tar file from ebuddy with the support files included?

MOVED TO STAFF NOTE (36.5 KB)

I sent a reply with the backup file but I do not think its uploaded properly.

If it did you will see used “//” to omit the code I added, when I was testing the code I omitted, the ONCHANGE “EW_1”, “GOTO WRITE_DI1” in the INT section.

Hmm it might be easier if I take a look at this on teamviewer

Is there a number I can call you at as well?

Whoops wrong teamviewer link:

teamview is up and running, should i put my phone number here in the forum?

I’ll edit it so it can only be seen by hms internal

CELL PHONE IS
(Hidden)

The program was working till I deleted the user file now I get the following error
IO Error (33)62 : OPEN 'file:/usr/DI_1_TEST.csv" FOR BINARY INPUT AS 1
all other log files work fine

What do you mean when you say that you deleted the user file?

I have my script working to log the tags I want to log. For testing I have erased the file using ERASE “/usr/DI_1_TEST.csv” this has erased my DI_1_TEST.CSV file, this is what i wanted however now I am getting the IO Error(33) and its not creating the .csv file for me.

You could try and recreate it using writeebd

image

whats confusing me is that when I use my code in a custom label it works fine, pulls the error 33 and the new document is created but once i put it in with our time delay we worked on yesterday it just does not work and returns the error.
the red line is where the error keeps occurring, I have taken this script from another post on here for a baseline for a custom logger.

SETSYS PRG, “RESUMENEXT”, 1
CLOSE 1 REM - Close the file just in case.
OPEN “file:/usr/DI_1_TEST.csv” FOR BINARY INPUT AS 1
ErrorReturned = GETSYS PRG, “LSTERR”
IF(ErrorReturned = 33) THEN
CLOSE 1
OPEN “file:/usr/DI_1_TEST.csv” FOR BINARY OUTPUT AS 1
PUT 1, “Time,TagName,TIME RAN (MIN),COUNTS (ON)”
PUT 1, CHR$(13)+ CHR$(10)
PUT 1, Time$ +","+ DIStatus$ +","+ STR$ DI_1_TIME@ +","+ STR$ DI_1_COUNT@ +","+ CHR$(13)+ CHR$(10)
CLOSE 1
ELSE
CLOSE 1
OPEN “file:/usr/DI_1_TEST.csv” FOR BINARY APPEND AS 1

PUT 1, Time$ +","+ DIStatus$ +","+ STR$ DI_1_TIME@ +","+ STR$ DI_1_COUNT@ +","+ CHR$(13)+ CHR$(10)

CLOSE 1

ENDIF

Can I jump on teamviewer again and take a look?

I am just headed home ill be up and running again in like 20 min

im home and good now

Just wanted to follow up on this post, It really was answered with the timer functions provided earlier, I do not want to get off topic so others can use this too.

Thanks for the Help!!
Ill be posting elsewhere soon enough.

1 Like

Topic closed due to inactivity.