File and variable values, function problems (segment start is less than 1 (0))

안녕하세요.

파일 컴포너트로 파일을 처리하고 파일에서 불러온 값을 변수에 저장하는 중에 문제가 발생했습니다.

빨간 경고표시는 없습니다. 전역 변수에 텍스트를 넣고, 앱을 설치하고 실행하면 "invalid txt operation Sagment: Start is less than 1 (0)." 창이 나타납니다.
전역 변수 값 : blocks (2)

그러나 전역 변수 값이 공백인 경우에는 문제가 생기지 않습니다.

그리고 전역 변수 값이 공백일 경우 문제가 없어 잘 실행이 되지만 아래 함수의 반환값이 항상 공백으로 반환
됩니다.

이 함수가 실행되면 파일의 존재 여부를 확인하여, 파일이 존재하지 않는다면 파일을 만들고 나서 만들어진 파일의 값을 반환하고, 파일이 존재한다면 파일의 값을 반환합니다.

하지만 이상하게도 파일이 존재하고, 파일에 텍스트가 채워져 있어도 함수가 반환하는 값은 항상 공백입니다.

    [요약]

] 전역 변수에 텍스트를 저장하면 "invalid txt operation Sagment: Start is less than 1 (0)." 창이 나타나는데, 그 이유는 무엇입니까? 전역 변수에 텍스트를 저장할 수 없는건가요?

] 전역 변수의 초기값을 공백으로 하면 문제가 생기지 않는 까닭은 무엇입니까?

] 전역 변수의 초기값이 공백이여서 더이상 "invalid txt operation Sagment: Start is less than 1 (0)." 창이 뜨지 않지만 함수가 파일을 불러온 값이 왜 항상 공백인 이유는 무엇입니까? 파일은 텍스트로 채워져 있다는걸 확인 했습니다. 그런데도 왜 공백을 반환하는 이유는 무엇인가요?

] 이 문제들을 해결할 수 있는 방법은 무엇입니까? 도무지 이해할 수 없는 문제입니다. 도와주세요.

참고: aia 파일은 중요한 api 키가 있어 드릴 수 없습니다. 블록 이미지는 드릴 수 있습니다.


Hello.

There was a problem processing files with File Component and storing the values imported from the file in variables.
png

There is no red warning sign. When you insert text into a global variable, install and run the app, the "invalid txt operation Sagment: Start is less than 1 (0)." window appears.

Global variable values: blocks (2)

However, if the global variable value is blank, there is no problem.
blocks (4)

In addition, if the global variable value is blank, it runs well without problems, but the return value of the function below is always returned blank.

When this function is run, it checks the existence of the file, if it does not exist, returns the value of the file created by creating the file, and returns the value of the file if the file already exists.

Strangely, however, the value returned by the function is always empty, even if the file exists and is filled with text.

    [Summary]

] When text is stored in a global variable, "invalid txt operation Sagment: Start is less than 1 (0)." Why? Can't you store text in a global variable?

] Why is there no problem if you leave the initial value of the global variable blank?

] When the initial value of the global variable is blank, the window "Evaluate incorrect txt operation: Start is less than 1" no longer appears, why is the value returned by the function always blank? I checked that the file was filled with text. So why are you returning the blanks?

] How can we solve these problems? It's a problem that I can't understand at all. Help me.

Note: Aia file cannot be given because it has an important api key. I can give you a block image.

Can you provide a simple aia project that demonstrates this bug ?

버그를 재현하기 어려워 api key를 제거하여 올렸습니다.

전역 변수 'global variable of problem' 가 문제입니다. 이 전역 변수의 초기값에 공백을 저장하면 이 문제가 생기지 않습니다. 그러나 텍스트가 들어갈 경우 오류가 발생합니다.

'Ctrl + F' 를 이용하여 'global variable of problem' 찾아보시기 바랍니다.
그리고 'global variable of problem' 전역 변수에 .

문제가 발생함 : blocks (5)

문제가 발생하지 않음 : blocks (6)server_write.aia (531.6 KB)

OK, from what i can see you have a couple of issues:

  1. You have created a "delay" procedure. This will not work properly in AI2. You have to use a clock timer.

  2. Your file read workflow is wrong. You read the file then try to get the output of the read in the same procedure, this is probably why you get the error?

The file read process should be like this ( I believe I picked the right blocks):

감사합니다. 덕분에 문제를 해결했습니다.

문제의 원인은 '문제의 전역 변수' 가 텍스트로 초기화 되었을때, 어떤 함수는 그 변수의 수학적인 숫자값을 가져오기 때문이였습니다. 변수에 텍스트가 있어 수학적 숫자값을 읽어올 때 문제가 생긴것 같습니다.

그래서 텍스트형 전역 변수와 숫자형 전역 변수를 따로 만들고 따로 핸들러가 작동되게 하였습니다.

덕분에 문제를 해결하였습니다. 감사합니다

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.