- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
All,
My routine is doing a formatted read of a character string from a file to the character variable CFOO and I need to add a NULL character to the end of that character string within CFOO. How is that done?
Thanks in advance,
Jeff
My routine is doing a formatted read of a character string from a file to the character variable CFOO and I need to add a NULL character to the end of that character string within CFOO. How is that done?
Thanks in advance,
Jeff
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
you can generate the NULL character using the function CHAR with zero argument i.e. nullchar=CHAR(0). Add it using the stringconcatenate operator '//' thus
string=TRIM(ADJUSTL(string))//char(0)
ADJUSTL moves the characters in 'string' to the left of the space allotted for the string, removing leading blanks and adding trailing blanks on the right.TRIM chops off all trailing blank characters.You then add theh NULL to the end of the TRImmed result and store the result back into 'string' (or another string). If you know the length of 'string' excluding trailing blanks, you could use
string=string(1:length)//CHAR(0)
This works so long as the space assigned to character string 'string' is at least 1 character longer than 'length'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks!!! That was it!
Jeff
Jeff

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page