Projects > MasmBasic & the RichMasm IDE

Copy into Files$

(1/4) > >>

clamicun:
jj bom dia,

store_file exists

mov hMem,alloc(5000000)
INVOKE CreateFile,offset store_file,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0 
mov filehandle,eax   
INVOKE GetFileSize,filehandle,0 
mov myfilesize,eax
INVOKE  ReadFile,filehandle,hMem,myfilesize,offset BytesRead,0   
INVOKE CloseHandle,filehandle

Is there a possibility to get the content of hMem into Files$ before free hMem   ?

clamicun:
One more question...

Let esi = "C:\"
GetFolders esi   
mov dirs_found,eax
mov eax, ustr$(dirs_found)
Store offset store_file,Files$()

Is there a possibility to write eax=dirs_found somewhere into store_file ?
Preferably as first line. 

Excuse the many questions.

jj2007:

--- Quote from: clamicun on September 03, 2017, 11:24:54 PM ---Is there a possibility to get the content of hMem into Files$ before free hMem  ?
--- End quote ---

The part before is easy:

include \masm32\MasmBasic\MasmBasic.inc         ; download
hMem   dd ?
store_file      db "stored_temp.txt", 0

  Init
  FileWrite offset store_file, "Hello"  ; make sure it exists
  Let hMem=FileRead$(offset store_file)
  Inkey "[", hMem, "]"
EndOfCode

But I assume you want to insert a line before the Store "MyFiles.txt", Files$(), right?

include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  GetFolders "\Masm32\Examples"
  xchg eax, ecx                         ; save the count
  Insert Files$(0)
  Let Files$(0)=Str$("GetFolders() found %i folders in \Masm32\Examples", ecx)
  Store "ExampleFolders.txt", Files$()
  Inkey Str$("%i folders found. Wanna see them (y)?", ecx)
  If_ eax=="y" Then ShEx "ExampleFolders.txt"   ; opens Notepad etc
EndOfCode

clamicun:
beautiful,
thanks a lot.

Let esi="MasmBasic is great"

clamicun:
Think I was a bit too fast with "beautiful".

This is perfect.

include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  GetFolders "C:\"
  xchg eax, ecx                         ; save the count
  Insert Files$(0)
  Let Files$(0)=Str$("%i", ecx)
  Store "Folders_C.txt", Files$()
  EndOfCode

But this is not what I meant.

hMem   dd ?
store_file      db "Folders_C.txt", 0
  Init
  ;FileWrite offset store_file, "Hello"  ; make sure it exists
  Let hMem=FileRead$(offset store_file)
  Inkey "[", hMem, "]"
EndOfCode

But...
Read the existing "Folders_C.txt and mov the content into Files$ for further use.
Something like...

mov hMem,alloc(5000000)
INVOKE CreateFile,offset store_file,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0 
mov filehandle,eax   
INVOKE GetFileSize,filehandle,0 
mov myfilesize,eax
INVOKE  ReadFile,filehandle,hMem,myfilesize,offset BytesRead,0   
INVOKE CloseHandle,filehandle

Now I have the storefile in hMem and want to get it into MasmBasics Files$ 

Navigation

[0] Message Index

[#] Next page

Go to full version