RosettaCodeData/Task/Program-name/Liberty-BASIC/program-name-1.liberty

42 lines
1.1 KiB
Plaintext

nSize = _MAX_PATH + 2
lpFilename$ = space$(nSize); chr$(0)
calldll #kernel32, "GetModuleFileNameA", _
hModule as ulong, _
lpFilename$ as ptr, _
nSize as ulong, _
result as ulong
lpFilename$ = left$(lpFilename$,result)
print "Path to LB exe"
print lpFilename$
print "current program file (:last one on LRU list)"
print getLastLRU$(lbPath$)
end
Function getLastLRU$(lbPath$)
open lbPath$+"lbasic404.ini" for input as #1
while not(eof(#1))
line input #1, a$
if instr(a$, "recent files")<>0 then [readRecentFiles]
wend
getLastLRU$ = "* Failed: Recent files section not found *"
close #1
exit function
[readRecentFiles]
nRecent = val(word$(a$,1))
'print "nRecentFiles", nRecent
for i = 1 to nRecent
if eof(#1) then
getLastLRU$ = "* Failed: File ended while in recent files section *"
close #1
exit function
end if
line input #1, a$
'print i, a$
next
close #1
getLastLRU$ = a$
end function