IonicWind Software

IWBasic => General Questions => Topic started by: src243 on September 16, 2009, 05:03:25 PM

Title: Confusion
Post by: src243 on September 16, 2009, 05:03:25 PM
I have a program with integer and double precision variables. When executing the values are altered but not by any code. In some instances, the value changes when the variable is used in a calculation.

Title: Re: Confusion
Post by: LarryMc on September 16, 2009, 05:04:45 PM
OK?

Larry
Title: Re: Confusion
Post by: src243 on September 16, 2009, 05:06:05 PM
There is no reason for the value to change. The code does not assign a new value.
Title: Re: Confusion
Post by: LarryMc on September 16, 2009, 05:14:16 PM
OK?

You do understand that if you want some help you need to post the code that is giving you the problem along with the specific results you expect vs what you're getting?

Otherwise, all we can offer is "Sorry to hear you're having problems".

Larry
Title: Re: Confusion
Post by: src243 on September 16, 2009, 05:31:03 PM
How do I add the code and the data associated data file?
Title: Re: Confusion
Post by: LarryMc on September 16, 2009, 05:57:50 PM
put your .eba file and the data file into a zip file

post a reply
at the bottom left corner of the area you type your post there is a link 'Additional Options'
click that
browse to where the zip file is.
click on the zip file and then click open
now your zipfile appears in the edit control next to the word Attach.
now click post.

Larry
Title: Re: Confusion
Post by: src243 on September 16, 2009, 07:23:50 PM
I have attached the files.
The problem occurs at line 686 where the value of FAVG changes for the i=3 as indicated in the print out of the value at 733. At this point, the value of FAVG changes for <1 to 21.
Title: Re: Confusion
Post by: LarryMc on September 16, 2009, 08:05:41 PM
Scott

Looking at the values while the program is running.

every execution of line 660 where i=3 the value of FAVG is 21....
and at the end of all the looping the value of FAVG[3] at line 733 is the same exact 21....

so the value of FAVG[3] is not changing between those 2 lines as you suggest.

Larry
Title: Re: Confusion
Post by: billhsln on September 16, 2009, 08:29:26 PM
Quick thing that needs to be fixed:  Line 289, 682, and 699.  You have END IF, should be ENDIF (no space).  Surprised the compiler does not complain about them.

Also, you need to note that every thing in EBasic is Base of 0 (zero), so:

DEF freq[7,60] as FLOAT

FOR I=1 to 7
  FOR J=1 to 59
    freq[I,J]=0.0
  NEXT J
NEXT I

Should be:

FOR I=0 to 6
  FOR J=0 to 59
    freq[I,J]=0.0
  NEXT J
NEXT I

For FREQ I of 7 is out of range.

The END could give unpredictable results.

Bill
Title: Re: Confusion
Post by: Ionic Wind Support Team on September 16, 2009, 08:45:42 PM
Bill,
The compiler allows both forms.  Same with END SUB

Paul.
Title: Re: Confusion
Post by: Ionic Wind Support Team on September 16, 2009, 08:50:53 PM
Scott,
You need to review the manual on arrays.  Arrays in Emergence are 0 based, not 1 based.  This section of code for example:

FOR I=1 to 7
FOR J=1 to 59
freq[I,J]=0.0
NEXT J
NEXT I


is exceeding the dimension of the array.  You have freq defined as:

DEF freq[7,60] as FLOAT

Which has valid indices of [0-6, 0-59]

By using FOR I = 1 TO 7 you are overwriting 59 * 8 bytes of memory beyond the array.  You have made this error throughout your code, so I will leave it to you to find the rest.

Paul.
Title: Re: Confusion
Post by: src243 on September 17, 2009, 05:48:35 AM
It was the array size. THanks,

src243