G0025 with xlsLoadVars

Hi,

I want to load data from an excel file into Gauss. The good thing is, that here is no problem when I simply loade the data. However, when I create a matrix from these variables in a program, it gives the error message G0025. Here is the Code:

xlsLoadVars("blub.xlsx");

dat=Date~y~z;

Where of course the excel file contains the variables Date, y and z. When load the data by running first the xlsLoadVars command in the Program Input and then the program, it runs. But I don't want to do this every time. What do I do wrong?

 

Thanks!

2 Answers



0



What is happening
When GAUSS runs your program, there are two steps. The first step is the compile phase. This is when GAUSS turns the text on page into something the computer can run. The second phase is run-time where the code created by the compile phase is executed.

During compile time, GAUSS checks for many types of errors. One of these is undefined symbols. The nice thing about compile time errors is that they happen immediately after you run your program. Otherwise you could have a program running for 30 minutes or 3 days and die because of something like misspelling a variable name.

In this case, the variables Date, y and z are not created until run-time in the xlsLoadVars procedure. However, their existence is checked for at compile time--and they are not created yet.

The solution
GAUSS allows you to declare variables at the start of your program, like this:

declare Date, y, z;

This tells GAUSS that you intend to create these variables later, which gives you the flexibility you want, but also allows GAUSS to perform the compile time checking.

Adding the line above should resolve your problem. However, date is a GAUSS function that returns the current date and time as a 4x1 vector. This may cause a problem.

aptech

1,773


0



Thank you very much. Works perfect now (I renamed the variable "date").

Your Answer

2 Answers

0

What is happening
When GAUSS runs your program, there are two steps. The first step is the compile phase. This is when GAUSS turns the text on page into something the computer can run. The second phase is run-time where the code created by the compile phase is executed.

During compile time, GAUSS checks for many types of errors. One of these is undefined symbols. The nice thing about compile time errors is that they happen immediately after you run your program. Otherwise you could have a program running for 30 minutes or 3 days and die because of something like misspelling a variable name.

In this case, the variables Date, y and z are not created until run-time in the xlsLoadVars procedure. However, their existence is checked for at compile time--and they are not created yet.

The solution
GAUSS allows you to declare variables at the start of your program, like this:

declare Date, y, z;

This tells GAUSS that you intend to create these variables later, which gives you the flexibility you want, but also allows GAUSS to perform the compile time checking.

Adding the line above should resolve your problem. However, date is a GAUSS function that returns the current date and time as a 4x1 vector. This may cause a problem.

0

Thank you very much. Works perfect now (I renamed the variable "date").


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy