Need to configure view permission over script

I have developed user and role creation over script using system functions. Now I am struggling to assign the view permission for each roles over script.(Privileges for each role.) How Can I assign the view permission over script other than assign over the usual way showed below image
Kindly give your inputs, is it possible/impossible?

Hope somebody can give there input! :slightly_smiling_face: