gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [open-cobol-list] File path.


From: Michael Anderson
Subject: Re: [open-cobol-list] File path.
Date: Wed, 08 May 2013 11:39:59 -0500
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5

Yes, this is odd.

Not sure if it will make a difference in this case, but...... in C, strings are terminated by null, this is how C determines the length of the string. Without the null your string may include more data than you expected, as the program continues walking though memory until a null is encountered, or until it walks right off the stack and core dumps.

As a "Best Practice" kinda thing, when calling any "C" subroutine I first initialize all strings with LOW-VALUES, which is nulls, and then use string instead of move.

So, I'm curious; If you first MOVE LOW-VALUES (instead of SPACES) to myfilepath and myfilename, will the results be the same?

Is the "" as the last STRING parm in your second example really a null char?
If so, then that is why the results are different.
There is a compiler setting to null terminate all string/char parms in all call statements.
 -fnull-param          Pass extra NULL terminating pointers on CALL statements


Just my $0.02
--
Mike.


On 05/08/2013 10:20 AM, studiok wrote:
Hi,

@ Vince
thank you.

@ all

It seems that:

working-storage section.

01  myfilepath                pic x(50).
01  myfilename              pic x(20).

Procedure division.

move spaces                to myfilepath
                                         myfilename
move "something.txt"   to myfilename

string
         "/abc/def"              delimited size
         "/xyz/"                   delimited size
         "filename"              delimited spaces
         into myfilepath
end-string

------------> that is /abc/def/xyz/something.txt

string
         "/abc/def"              delimited size
         "/xyz/"                   delimited size    
         '"'                           delimited size
         "filename"              delimited spaces
         '"'                           delimited size   
         into myfilepath
end-string

------------> that is /abc/def/xyz/"something.txt"

get different results. First of which file-status 35. Is it possible?

marcellom

Il 08/05/2013 14:29, vbcoen ha scritto:

Hi

 

forgot to add this that sets up the ACAS-xxx vars from the environment that is run before the code I sent last msg:

 

Procedure:

 

accept ACAS_LEDGERS from Environment "ACAS_LEDGERS".

accept ACAS_IRS from Environment "ACAS_IRS".

accept ACAS_BIN from Environment "ACAS_BIN".

if ACAS_IRS (1:1) = space

or ACAS_LEDGERS (1:1) = spaces

or ACAS_BIN (1:1) = spaces

display ST009 at 0505 with erase eos highlight

display ST008 at 1210 with foreground-color 3 highlight

accept ws-reply at 1243

stop run

end-if

if ACAS_LEDGERS (1:1) = "/" *> Its Linux/Unix/OSX

move "/" to OS-Delimiter.

if ACAS_LEDGERS (1:1) = "\" *> Its Windoz/Dos-Box

move "\" to OS-Delimiter.

 

Vince

 

 



------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may


_______________________________________________
open-cobol-list mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/open-cobol-list



------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may


_______________________________________________
open-cobol-list mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/open-cobol-list


reply via email to

[Prev in Thread] Current Thread [Next in Thread]