From Clomosy Docs

No edit summary
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert">
function clPathCombine(var FileNameString: String; CombinePathString:String);
</div>
<span style="color:blue">''FileNameString''</span> : Searched file name.<br>
<span style="color:blue">''CombinePathString''</span> : The file path to merge.<br>
clPathCombine is a function that is part of the Clomosy library. This function returns a string data by concatenating the file path and file name.
clPathCombine is a function that is part of the Clomosy library. This function returns a string data by concatenating the file path and file name.


The general usage is as follows:
The general usage is as follows:


clPathCombine(FileNameString:WideString; CombinePathString:String);
<div class="alert alert-secondary" role="alert" data-bs-theme="light">
CombinedPath = clPathCombine('File.txt','C:\Document');
// Now CombinedPath will be 'C:\Document\File.txt'.
</div>


<span style="color:blue">''FileNameString''</span> : Searched file name.
<b>Example</b><br>


<span style="color:blue">''CombinePathString''</span> : The file path to merge.
If the file does not exist in the project directory, it saves the file. If the file exists, it adds a line to it.
When the application runs for the first time, it will not find the file, so it will add it to the file path and display a message.
When run for the second time, a line is added to the existing file.


'''For instance:'''
<pre>
CombinedPath := clPathCombine('File.txt','C:\Document');
var
  // Now CombinedPath will be 'C:\Document\File.txt'.
  strList:TclStringList;
  fileStr:String;
  i : Integer;
{
  strList = Clomosy.StringListNew;
  fileStr = clPathCombine('File.Txt',Clomosy.AppFilesPath);


'''Example:'''
   If (clFileExists(fileStr,Clomosy.AppFilesPath))
:''Base Syntax''
   {
   var
     strList.Add('New Line 1');
    strList:TclStringList;
    strList.SaveToFile(fileStr,0);
    fileStr:String;
     ShowMessage('A line has been added to the existing file. To check, check your file via the file path. File path:'+#13#10+ fileStr);
  begin
   } else
    strList := Clomosy.StringListNew;
    fileStr := clPathCombine('File.Txt',Clomosy.AppFilesPath);
    ShowMessage(fileStr);
    
     If clFileExists(fileStr,Clomosy.AppFilesPath) then
    begin
      strList.Add('New Line 1');
      strList.SaveToFile(fileStr,0);
     end else
    begin
      strList.SaveToFile(fileStr,0);
    end
   end;
 
:''TRObject Syntax''
  var
    strList:TclStringList;
    fileStr:String;
   {
   {
     strList = Clomosy.StringListNew;
     strList.SaveToFile(fileStr,0);
    fileStr = clPathCombine('File.Txt',Clomosy.AppFilesPath);
     ShowMessage('The file has been added to the directory. Directory path: '+#13#10+ fileStr)
     ShowMessage(fileStr);
 
    If clFileExists(fileStr,Clomosy.AppFilesPath)
    {
      strList.Add('New Line 1');
      strList.SaveToFile(fileStr,0);
    } else
    {
      strList.SaveToFile(fileStr,0);
    }
   }
   }
  if (strList.Count <= 0)
    ShowMessage('Empty!');
  else
  {
    for (i = 0 to strList.Count - 1)
      ShowMessage(Clomosy.StringListItemString(strList,i));
  }
}
</pre>


= See Also =
<h2> See Also </h2>
* [[Controls| Controls]]
* [[File_Handling | File Handling]]
{{#seo:|title=ClPathCombine in Clomosy - Clomosy Docs}}
{{#seo:|description=ClPathCombine in Clomosy allows you to merge file paths seamlessly, ensuring smooth file handling in your mobile applications.}}

Latest revision as of 13:23, 24 December 2024

FileNameString : Searched file name.
CombinePathString : The file path to merge.

clPathCombine is a function that is part of the Clomosy library. This function returns a string data by concatenating the file path and file name.

The general usage is as follows:

Example

If the file does not exist in the project directory, it saves the file. If the file exists, it adds a line to it. When the application runs for the first time, it will not find the file, so it will add it to the file path and display a message. When run for the second time, a line is added to the existing file.

var
  strList:TclStringList;
  fileStr:String;
  i : Integer;
{
  strList = Clomosy.StringListNew;
  fileStr = clPathCombine('File.Txt',Clomosy.AppFilesPath);

  If (clFileExists(fileStr,Clomosy.AppFilesPath))
  {
    strList.Add('New Line 1');
    strList.SaveToFile(fileStr,0);
    ShowMessage('A line has been added to the existing file. To check, check your file via the file path. File path:'+#13#10+ fileStr);
  } else
  {
    strList.SaveToFile(fileStr,0);
    ShowMessage('The file has been added to the directory. Directory path: '+#13#10+ fileStr)
  }
  if (strList.Count <= 0)
     ShowMessage('Empty!');
   else
   {
     for (i = 0 to strList.Count - 1)
       ShowMessage(Clomosy.StringListItemString(strList,i));
   }
}

See Also