Ask Reuben

CLIPPED

Why does this filename have spaces? 

Why does this COMBOBOX item not get selected?

One of the first things junior developers learn the hard way when they are starting out is the importance of using CLIPPED with CHAR variables.  If you forget CLIPPED when concatenating CHAR with code like …

LET full_name = first_name, " ", last_name

… you will wonrder why there is more than one space between first_name and last_name.  This code should be coded …

LET full_name = first_name CLIPPED, " ", last_name CLIPPED

This use of CLIPPED applies elsewhere with CHAR values.  A common place missed is with methods where you might also use STRING.   STRING variables don’t need the CLIPPED whilst CHAR variables typically do.

So if your ComboBox does not recognise what you have selected, make sure you don’t have …

CALL ui.ComboBox.addItem(rec.code, rec.desc)

… when you should have …

CALL ui.ComboBox.addItem(rec.code CLIPPED, rec.desc CLIPPED)

Similar with filename as arguments, it should be …

CALL os.Path.copy(source_filename CLIPPED, dest_filename CLIPPED)

… and not …

CALL os.Path.copy(source_filename, dest_filename)

… when source_filename and dest_filename are CHAR variables

If you forget the CLIPPED you may find you the file is not copied or it has spaces in the filename.