Ciao Dany,
making a C to Basic (thinBasic) translation or parallel is quite a huge work if one want to do it professionally and honestly I do not have the time.
Instead ... maybe we can help more if you ask about the tasks you want to achieve so we can help/suggest something on how to achieve that tasks using thinBasic
Regarding Files, thinBasic has a specific module called "File" that you can load using:
at the beginning of your code and you will have some file/directory specific functions in your script arsenal: http://www.thinbasic.com/public/prod...ileequates.htm
Than check inside \thinBasic\SampleScripts\File\ directory and you should find some examples on how to start.
On memory, I come from old 640KB DOS era when looking at how much memory your program was consuming was a must do task.
In 32bit process (like thinBasic scripts) you have 2GB virtual memory for each process so you do not have to worry about memory unless you really need to load quite big piece of data to be handled at the same time.
In any case if you want to see how to get memory info of current process, you can use the following script. It uses 2 Windows API functions GetProcessMemoryInfo and GetCurrentProcess.
Ciao
Eros
Uses "Console"
'---References---------------------------------------
' https://msdn.microsoft.com/en-us/library/windows/desktop/ms683219(v=vs.85).aspx
' https://msdn.microsoft.com/en-us/library/windows/desktop/ms683179(v=vs.85).aspx
TYPE PROCESS_MEMORY_COUNTERS DWORD
cb AS DWORD
PageFaultCount AS DWORD
PeakWorkingSetSize AS DWORD
WorkingSetSize AS DWORD
QuotaPeakPagedPoolUsage AS DWORD
QuotaPagedPoolUsage AS DWORD
QuotaPeakNonPagedPoolUsage AS DWORD
QuotaNonPagedPoolUsage AS DWORD
PagefileUsage AS DWORD
PeakPagefileUsage AS DWORD
END TYPE
Declare Function GetProcessMemoryInfo Lib "PsApi.dll" Alias "GetProcessMemoryInfo" (BYVAL hProcess AS DWORD, ppsmemCounters AS PROCESS_MEMORY_COUNTERS, BYVAL cb AS DWORD) AS LONG
Declare Function GetCurrentProcess Lib "Kernel32.dll" Alias "GetCurrentProcess" () as Long
'-------------------------------------------------------
'---Get memory usage of current process
FUNCTION MemoryInfo(s) AS STRING
LOCAL sStat AS PROCESS_MEMORY_COUNTERS
local sBuffer as String
GetProcessMemoryInfo (GetCurrentProcess, sStat, SizeOf(sStat))
sBuffer = "Page fault count................." & $TAB & RSET$(FORMAT$(sStat.PageFaultCount, "0,"), 15) & $CRLF
sBuffer += "Peak working set size............" & $TAB & RSET$(FORMAT$(sStat.PeakWorkingSetSize, "0,"), 15) & $CRLF
sBuffer += "Current working set size........." & $TAB & RSET$(FORMAT$(sStat.WorkingSetSize, "0,"), 15) & $CRLF
sBuffer += "Quota peak paged pool Usage......" & $TAB & RSET$(FORMAT$(sStat.QuotaPeakPagedPoolUsage, "0,"), 15) & $CRLF
sBuffer += "Quota paged pool usage..........." & $TAB & RSET$(FORMAT$(sStat.QuotaPagedPoolUsage, "0,"), 15) & $CRLF
sBuffer += "Quota peak non paged pool usage.." & $TAB & RSET$(FORMAT$(sStat.QuotaPeakNonPagedPoolUsage, "0,"), 15) & $CRLF
sBuffer += "Quota non paged pool usage......." & $TAB & RSET$(FORMAT$(sStat.QuotaNonPagedPoolUsage, "0,"), 15) & $CRLF
sBuffer += "Peak page fileUsage.............." & $TAB & RSET$(FORMAT$(sStat.PeakPageFileUsage, "0,"), 15) & $CRLF
sBuffer += "Page file usage.................." & $TAB & RSET$(FORMAT$(sStat.PageFileUsage, "0,"), 15) & $CRLF
function = sBuffer
END FUNCTION
FUNCTION TBMain () AS LONG
dim WasteMem as String
'---Loop while user press ESC key
Do
Cls
'---Allocate some random memory from 1M to 10M
WasteMem = string$(rnd(1000000, 10000000), $nul)
'---Call function that get memory usage and print data
printl MemoryInfo()
printl "Press any key to show again memory usare or ESC to exit" in %CCOLOR_FINTENSEWHITE
loop while WaitKey <> "[ESC]"
END FUNCTION
Bookmarks