Author Topic: Validate file/folder exists  (Read 3621 times)

Benjamin Dasari

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 95
    • View Profile
Validate file/folder exists
« on: December 18, 2017, 11:08:58 AM »
Purpose:
Checks if a file or folder exists in the specified location.

Syntax:
system.queryExists("file/folder path");

Liquid UI Code:
----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPLSMTR_NAVIGATION.E0100.sjs       // Easy Access
----------------------------------------------------------------------------------------------------------------------------------------------
function isBlank(jvar){
   return(jvar == null || jvar == "" || jvar == void(0));
}

function fileRead(){
   // Check if the file/folder exists or not and returns boolean
   if(!system.queryExists("C:\\LiquidUI\\Scripts\\file.txt")){
      message("E: Cannot find the file to be read");
      enter("?");
      goto SCRIPT_END;
   }

   openfile('file.txt', {"delimiter":","});
   READ:{
      readfile('file.txt', {"z_first_&V[idx]":true, "z_second_&V[idx]":true, "z_third_&V[idx]":true});
   }

   set("V[z_currField]" , "&V[z_first_&V[idx]]");
   if(isBlank(z_currField)) {
      goto FILE_END;
   }

   idx++;
   goto READ;
   FILE_END:;
   closefile('file.txt');
   SCRIPT_END:;
}

// User Interface
clearscreen();
pidx = 0;
idx=0;

text([0,0],  "Material" , {"size":20});
text([0,22],  "Item" , {"size":20});
text([0,44],  "Description" , {"size":20});

CREATE:{     
   inputfield([pidx + 1,0], {"size":20, "readonly":true, "name":"z_first_&V[pidx]" ,"nolabel":true});
   inputfield([pidx + 1,22], {"size":20, "readonly":true, "name":"z_second_&V[pidx]" ,"nolabel":true});
   inputfield([pidx + 1,44], {"size":20, "readonly":true, "name":"z_third_&V[pidx]" ,"nolabel":true});
}
pidx++;

set("V[z_checkfld]", "&V[z_first_&V[pidx]]");
if(isBlank(z_checkfld)){
   goto END;
}

goto CREATE;
END:;
pushbutton([1,67],"@0V@Enter","?",{"process":fileRead});


See attachments for code samples!
« Last Edit: August 06, 2018, 02:31:32 PM by Benjamin Dasari »