Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Uniface-L] problem

43 views
Skip to first unread message

Zsolt Hoffmann

unread,
Mar 24, 2011, 10:49:25 AM3/24/11
to Uniface User Group Discussion Forum
Hi
I have today a new problem, and I don't know how can it fix.
The code:
entry lp_listaz
    variables
        string vFilePath, vContent, dokument
        numeric N,ikon
endvariables
    clear/e "lista"
    ikon=0
    $valrep(tipus.lista)="1=^u_pdf·;2=^u_excel·;3=^u_regi"
    vContent = $dirlist("G:\dir1\","File")
    N = 1
    getitem vFilePath, vContent, N
    while ($status > 0)
        ;debug
        ikon=""
        ;$2=""
        dokument="%%vFilePath%%%"
        scan dokument,"."
        $1=$result
        $2=dokument[$1+1:$1+3]
        $3=dokument[1:$1-1]
        ;--
            selectcase $2
            case "pdf"
                     ikon=1
            case "xls"
                     ikon=2
            case "xlsx"
                     ikon=2
            case "doc"
                     ikon=3
            case "docx"
                     ikon=3
            endselectcase
        ;--
        if ($2!="")
            creocc "LISTA", -1
              fajl.lista ="%%vFilePath%%%"
              tipus.lista=ikon

        endif
        N = N + 1
        getitem vFilePath, vContent, N
    endwhile
    $prompt=fajl.lista
end

This local proc makes  a list of files in the directory. $2 is the extension of the assigned file. tipus.lista is an image tipe with numeric data type. The ikon gives them a number of wich glyph loaded. The problem: Its all the same,that tipus.lista wich number gets, always loads the first glyph.

I hope I was understandable!
Thanks for the answers!
Zsolt

Luis Vila

unread,
Mar 24, 2011, 4:46:36 PM3/24/11
to Uniface User Group Discussion Forum
Hello

I tried your code and it works without problem.

Is characteristics of field tipus.lista Database or Non-database? I changed it by Boilerplate and the behaviour is similar than you explained but it takes the LAST icon.

And, if you change your "scan" statement by this piece it will be a little bit efficient.
        length dokument
        $1=$result
        $2=dokument[$1-2:3] ;from the end, 3 chars
        $3=dokument[1:$1-4]

Best regards

El 24/03/11 15:49, Zsolt Hoffmann escribió:
_______________________________________________ Uniface User Group Discussion Forum For more information: http://lists.umanitoba.ca/mailman/listinfo/uniface-l To unsubscribe/set options: http://lists.umanitoba.ca/mailman/options/uniface-l


--



Luis Vila
http://www.ab-ratio.com



Oír o leer sin reflexionar es una ocupación inútil.
Confucio



Este mensaje puede contener información confidencial y/o privilegiada. Si Vd. no es el destinatario de este mensaje o ha recibido este mensaje por error, por favor, informe inmediatamente al emisor y destruya este mensaje. Está estrictamente prohibido por la legislación vigente realizar sin autorización cualquier copia, revelación o distribución de este mensaje.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden by current legislation.

Zdeněk Socha

unread,
Mar 25, 2011, 3:58:29 AM3/25/11
to Uniface User Group Discussion Forum
Hello,

first of all, I don't understand, why you use valrep at all? If $valrep() does not work, try $fieldvalrep() instead. But I think better approach is to use just widget type Picture, datatype Image (any source) (or you can use Image (glyph) of course), Interface VC100 (or similar) and then just assing a picture to the widget value, that is something like ipus.lista = "^u_pdf" (if you use "Image (any source)", the first character tells, what it is).

We don't use glyphs here, but it works just fine with common files (like pdf_icon.ico, xls_icon.ico, etc).

Hope, this code you provide us with, is just a quick sample... because it won't work fine for all files. On some OS's, there can be no extension at all... you seem to work on MS Windows OS, but you can't just search for the first dot (.) and assume next 3 characters is extension. Consider the following file name: "this.pdf.is.my.first.one.txt" - this is definitely txt file, but your code would assume, this is pdf file.
In fact, the file name extenstion is located after the last dot (.) and can be 1 - 4 characters long (for example: .Z, .7z, .zip, .doc, .xml, .docx, .xls, .xlsx, .... ).

This would be very easy with regexp (currently not available in Uniface, but it is on wishlist), or with reverse scan (from the end of the string, but AFAIK also not available in Uniface as of now). Maybe, you should have some kind of cycle to look for the very last period (.) and everything after this might be file extension (so in "this.is.my.word.document.docx" - the extension is "docx").

Unfortunately, both replies here gave you also wrong code to find a file name extension (they are fine as long as there is the only period/dot in filename and extension is exactly 3 characters long).

Hope this helps,
Zdeněk Socha

Dne 24.3.2011 15:49, Zsolt Hoffmann napsal(a):

Simon MacLoughlin

unread,
Mar 25, 2011, 5:54:01 AM3/25/11
to Uniface User Group Discussion Forum
Hi
 
Is the field definitely not set as "boilerplate" as a previous correspondent mentioned?
 
Simon


From: uniface-...@uug.org [mailto:uniface-...@uug.org] On Behalf Of Zsolt Hoffmann
Sent: 25 March 2011 09:48
To: Uniface User Group Discussion Forum
Subject: Re: [Uniface-L] problem

Hi

Thanks for this answer, its very useful. This code is only a sample. We use MS Windows OS and the sample files are pdfs,docs, and excel files.
Still does not work...
-I change the tipus.lista control to image(any source)->interface:VC100
-I change the code:
...
if ($2!="")
            debug

            creocc "LISTA", -1
                fajl.lista ="%%vFilePath%%%"
                    selectcase $2
                        case "pdf"
                     ;ikon=1
                            tipus.lista="^u_pdf"
                        case "xls"
                            tipus.lista="^u_excel"
                     ;ikon=2
                        case "xlsx"
                            tipus.lista="^u_excel"
                     ;ikon=2
                        case "doc"
                            tipus.lista="^u_regi"
                     ;ikon=3
                        case "docx"
                            tipus.lista="^u_regi"
                     ;ikon=3
            endselectcase

        endif
...
The result is in pic1.
I dont know, what is the problem.

Best Regards,
Zsolt

2011/3/25 Zdeněk Socha <zdenek...@fullcom-systems.cz>

Zsolt Hoffmann

unread,
Mar 25, 2011, 6:28:49 AM3/25/11
to Uniface User Group Discussion Forum
Hi

The problem is with boilerplate. I changed to non-database, and it works fine.
Billion thanks!

Zsolt

2011/3/25 Simon MacLoughlin <simon.ma...@hisvector.com>

Ulrich Merkel

unread,
Mar 25, 2011, 6:34:31 AM3/25/11
to Uniface User Group Discussion Forum
... not sure where I read it:

something about images not beeing (visually) updated when value was modified via proc-code.

HIH, Uli

BTW: would you provide a little example for us which demonstrates "the problem" so we can test/play/experiment.
A nice ZIP with Sourcecode plus some a set of files if you stay near to your original (and a installation/test instruction).
Makes it easier to exchange info when we all have the same puzzle-pieces in front of us.





-- Ulrich Merkel --
ulrich...@web.de
+49(69)317881
+49 152 2920 8463

Von: "Zsolt Hoffmann" <hoffmann....@gmail.com>
Gesendet: 25.03.2011 10:47:48
An: "Uniface User Group Discussion Forum" <unif...@uug.org>
Betreff: Re: [Uniface-L] problem

Zsolt Hoffmann

unread,
Mar 25, 2011, 6:50:23 AM3/25/11
to Uniface User Group Discussion Forum
Hi

Thanks for help, but the problem is absolved. The only problem is with the control characteristic. I changed to non-database, and it works fine.

Thank You again for your interest and help!
Sure will be more questions!

Best Regards!
Zsolt

2011/3/25 Ulrich Merkel <Ulrich...@web.de>
0 new messages