Author Topic: select file of the list  (Read 5499 times)

03.jose

  • Guest
select file of the list
« on: July 30, 2012, 09:09:38 AM »
hello I wanted to ask if anyone knows how to open a file you select from a list, the file has extention txt or asm. other than FileName db "\problemas\ ejemplo2.txt", 0 as it is very static, I want something more dynamic because I know the name of the file will be called

attached the file I am where I am working

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: select file of the list
« Reply #1 on: July 30, 2012, 09:22:35 AM »
LB_GETTEXT and ShellExecute are your friends, José :t

03.jose

  • Guest
Re: select file of the list
« Reply #2 on: August 01, 2012, 01:57:28 AM »
can you giveme an example please??

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: select file of the list
« Reply #3 on: August 01, 2012, 03:12:27 AM »
No, but you can search the forum.

03.jose

  • Guest
Re: select file of the list
« Reply #4 on: August 17, 2012, 03:31:19 PM »
hello I still have the same problem ... I think I not understand LB_GETTEXT use, the problem is that I could not pass (send) the file path to open (display contents), could help me please?

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: select file of the list
« Reply #5 on: August 17, 2012, 04:20:06 PM »
Post your code, with comments telling us what you have tried so far, and we'll see :icon14:

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
Re: select file of the list
« Reply #6 on: August 17, 2012, 05:54:24 PM »
To open a file you use this function:
Quote
      ;----------------------------
      ;  open a file for read
      ;----------------------------
invoke CreateFile,addr pathopenfile,GENERIC_READ,NULL,\
               NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
         .if eax==INVALID_HANDLE_VALUE
            mov retour,eax
            jmp somewhere
         .endif
         mov hFile,eax

If you are on a treeview,read the nod.This one can use a short path(only the name),you need the fool path (directory + name) to open it.
Search this name in a list of full path (you have to made this one) and pass the full path to the createfile function.






Fa is a musical note to play with CL

03.jose

  • Guest
Re: select file of the list
« Reply #7 on: August 18, 2012, 07:38:44 AM »
yes, something like that is what I tried. this is how I've been until now the treeview

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: select file of the list
« Reply #8 on: August 18, 2012, 08:29:47 AM »
Your filename is no good - this reserves one single byte:
FileName    DB          ?

This works (hola mundo) but it's a bit clumsy because I extract the true filename from mbp.lpszText:

Code: [Select]
        mov eax, mbp.lpszText
.Repeat
inc eax
.Until byte ptr [eax]=="="  ; get start of filename
.Repeat
inc eax
.Until byte ptr [eax]>" "  ; without whitespace
.data?
pFile dd ?
.code
mov pFile, eax  ; store begin of filename
.Repeat
inc eax
.Until byte ptr [eax]<=" "  ; find whitespace (won't work if your filename has spaces!!!)
mov byte ptr [eax], 0  ; delimit filename
        ;mov  FileName, mbp.lpszText

        invoke CreateFile,pFile,\
                GENERIC_READ or GENERIC_WRITE ,\
                FILE_SHARE_READ,\
                NULL,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,\
                NULL

03.jose

  • Guest
Re: select file of the list
« Reply #9 on: August 19, 2012, 12:49:59 PM »
hello, thanks for the help they give me.

Now what I'm trying to do is to work the code you gave me when you select a file to asm these are in the "soluciones (asm)", not because it does not.

the other thing I wanted to ask is because EjecutarExe calls to run an exe file, and to probe the function separately (ShellExecute) and worked, not because here it does not, what is it I am doing wrong so that do not call?

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: select file of the list
« Reply #10 on: August 19, 2012, 05:55:35 PM »
Attached version opens ejemplo.txt in Notepad. Check for badcode in the *.asm source

You are pretty closen now :t

03.jose

  • Guest
Re: select file of the list
« Reply #11 on: August 20, 2012, 10:58:07 AM »
excuse me, i have a problem with RichMasm

You cannot use the MasmBasic library with ml.exe version 6.14, sorry - try JWasm or ml 6.15

##########################
\masm32\MasmBasic\MasmBasic.inc(176) : error A2052: forced error
 TestMasmVersion(7): Macro Called From
  \masm32\MasmBasic\MasmBasic.inc(176): Include File
*** Assembly Error ***

but i copy the JWasm in the \masm32\bin

the ml.exe version 6.15 i not found

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: select file of the list
« Reply #12 on: August 20, 2012, 11:30:23 AM »
Just add this somewhere:

; OPT_Assembler   JWasm





03.jose

  • Guest
Re: select file of the list
« Reply #13 on: August 20, 2012, 02:50:42 PM »
you were right, I forgot to add the line told me.

but still not open asm files or run exe files, why is if you have the instructions?

another question: why did not you show me icons similarly if the user already has?

jj2007

  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: select file of the list
« Reply #14 on: August 20, 2012, 03:40:16 PM »
Hi,

I have no idea, but you can find out:
- in line 3, set useMB=1
- in line 581, insert this (see here for help):
    deb 1, "Line 580", eax, ebx, $tvi.pszText

You will see that tvi.pszText is always on ejemplo1.txt, so the error is before this line. Use the deb macro to find out where...