Forum > General

Absolute file path in {$include %file%}

<< < (2/6) > >>

KodeZwerg:

--- Quote from: simone on October 03, 2022, 09:40:49 am ---Is there any way to get the full path name?
--- End quote ---
How is that meant?
You want to find out at runtime where the source of {$I} was?

simone:
The following code in the filename "C:\Users\Desktop\test\project1.lpr"


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program project1;begin  writeln({$include %file%});  readln;end.
shows project.lpr, while while I would need to have: C:\Users\Desktop\test\project1.lpr

wp:
I think that the IDE changes path to the directory with the project file. So, you could try this:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program project2;uses  SysUtils;begin  writeln(IncludeTrailingPathDelimiter(GetCurrentDir) + {$include %file%});  readln;end. Don't beat me if this is wrong... For example, I could imagine that when a project is structured in subfolders you might not get the subfolder of the file...

MarkMLl:

--- Quote from: wp on October 03, 2022, 12:31:59 pm ---Don't beat me if this is wrong... For example, I could imagine that when a project is structured in subfolders you might not get the subfolder of the file...

--- End quote ---

Except that that's an unholy mix of compile- and runtime behaviour :-)

On unix you could possibly use %PWD%

MarkMLl

simone:
I'm trying a similar approach:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program project2;uses  SysUtils;begin  writeln(ExpandFileName({$include %file%}));  readln;end.

but i'm not sure if it is correct in all possible cases, for the reasons explained by MarkMLI in the last post.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version