Hello, I'm trying to create & write to a CSV file.
Using the CAA library example files I am able to create the directory and the file. The problem is writing to it.
Using a CASE statement I'm using the below FOR loop, the below code only write the last [5,0].sRelayName and it doesn't tab to get the DINT value
I've been at this for a while so I could really use some suggestions. The goal is to write string values to first column and DINT value to second column of CSV file. Then go to next line and re-do till you get to 5 (for loop max number)
Lastly I get these characters after the carraige return and line feed: ÔaŸåPŠà p ãPWãªÔçÅçp‡âùÿÿêãÅç@ ã´@Já@ ã²@Já@ ã´@Já
I'm guessing the reason I get them is because string has default character limit and these characters account for that limit. I'd like to get rid of these characters as I'm going to have to read these values back, if necessary, and I don't want to read these misc. characters
Thank you for your response, I've tried your suggestion and sadly, it still didn't work. Code is only writing the first iteration of for loop and not all.
This surely is exasperating.
If you have any further suggestions please pass them along
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2015-12-24
Originally created by: scott_cunningham
It appears to me you are executing the FOR loop all five times and then calling your filewr(execute) once afterwards. Are you sure you are building a complete string? One of your lines just shows DataString without any array... And it's not clear to my why you are defining a two dimensional array?
It looks to me your code should write the last entry of the FOR loop.
TIP: be careful of FOR loops with PLC coding - machine cycle time can suffer if the loop has high resource demand. It may work fine on high end hardware, but lower end hardware could have problems. Also, CONCAT is "slow". It maybe faster to write each element of the string instead of concating it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, I'm trying to create & write to a CSV file.
Using the CAA library example files I am able to create the directory and the file. The problem is writing to it.
Using a CASE statement I'm using the below FOR loop, the below code only write the last [5,0].sRelayName and it doesn't tab to get the DINT value
I've been at this for a while so I could really use some suggestions. The goal is to write string values to first column and DINT value to second column of CSV file. Then go to next line and re-do till you get to 5 (for loop max number)
Lastly I get these characters after the carraige return and line feed: ÔaŸåPŠà p ãPWãª
Ôç
Åçp‡âùÿÿêã
Åç@ ã´@Já@ ã²@Já@ ã´@JáI'm guessing the reason I get them is because string has default character limit and these characters account for that limit. I'd like to get rid of these characters as I'm going to have to read these values back, if necessary, and I don't want to read these misc. characters
Again I could surely use some help
2:( write text in the file )
Hi,
Try this for the carraige return and line feed:
Regards, Bakkertje
Thank you for your response, I've tried your suggestion and sadly, it still didn't work. Code is only writing the first iteration of for loop and not all.
This surely is exasperating.
If you have any further suggestions please pass them along
Originally created by: scott_cunningham
It appears to me you are executing the FOR loop all five times and then calling your filewr(execute) once afterwards. Are you sure you are building a complete string? One of your lines just shows DataString without any array... And it's not clear to my why you are defining a two dimensional array?
It looks to me your code should write the last entry of the FOR loop.
TIP: be careful of FOR loops with PLC coding - machine cycle time can suffer if the loop has high resource demand. It may work fine on high end hardware, but lower end hardware could have problems. Also, CONCAT is "slow". It maybe faster to write each element of the string instead of concating it.