+  HandyCache форум
|-+  Главная категория» English forum» Transferring the variable across Events
Имя пользователя:
Пароль:
Страниц: [1]   Вниз
  Отправить эту тему    Печать  
Автор Тема: Transferring the variable across Events  (Прочитано 3500 раз)
0 Пользователей и 1 Гость смотрят эту тему.
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« : 07 августа 2017, 21:30:45 »

Hi. How to transfer the variable across Events?

I have script, for testing. What is wrong?
Код:
--[[ <HCExtension>
@name Test - SL
@author truefriend-cz
@version 1
@event BeforeViewInMonitor
</HCExtension> ]]

function BeforeViewInMonitor()
hc.call_me_for('AnswerHeaderReceived')
hc.call_me_for('BeforeRequestHeaderSend')
end

function BeforeRequestHeaderSend()
hc.put_msg(1, 'Test OK: 2'..var) --no show var
end

function AnswerHeaderReceived()
var = re.find(hc.answer_header, [[^Content-Length:\s(.+)\r\n]], 1) -- i do not used local var for sharing variable between functions (and small bug, i do not set quality regex for show size only.. show size and other strings in header)
hc.put_msg(1, 'Test OK: 1'..var)
end
« Последнее редактирование: 07 августа 2017, 21:40:36 от truefriend-cz » Сообщить модератору   Записан
Михаил
Gold beta tester
*****

Репутация: +337/-14
Offline Offline

Сообщений: 5513



« Ответ #1 : 07 августа 2017, 21:49:16 »

BeforeRequestHeaderSend preceeded AnswerHeaderReceived.
May be you mean BeforeAnswerHeaderSend ?
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #2 : 08 августа 2017, 00:48:10 »

No. I have two LUA files.

Processing way:
1.lua (main entension) where on events:

BeforeViewInMonitor()
define file types for saving + create variable accept='yes'
...

RequestHeaderReceived()

if hc.cache_file_name == '' and accept == 'yes' then
    hc.action = 'save'
    for_saving = 'yes'
else
    hc.action = 'dont_update'
end
...

2.lua (module extension for limited/blocked bigger and smaller files than limit) where i testing how react on 1.lua (variables).

2.lua: Event RequestHeaderReceived()
is for_saving == 'yes' then apply limited functions and hc.action=dont_save and insert.table string for monitor message 'Filetype blocked. Smaller than..., bigger than..., limit.'

1.lua on BeforeAnswerHeaderSend()
monitor_show message and no saved to cache.


The problem is that I can not get the file size between RequestHeaderReceived() and BeforeAnswerHeaderSend() for activate limit functions in 2.lua
« Последнее редактирование: 08 августа 2017, 01:35:01 от truefriend-cz » Сообщить модератору   Записан
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #3 : 08 августа 2017, 21:13:45 »

This solution does what I want (randomly). I want to ask if this is correctly or is it incorrectly solution?
(Code for get size is not optimized yet - it is for testing now)
(This Lua's must sorting in HC Extensions as 0.lua upper than 1.lua)

0.lua:
Код:
--[[ <HCExtension>
@name Test 0.lua
@author truefriend-cz
@event BeforeViewInMonitor
</HCExtension> ]]

function BeforeViewInMonitor()
hc.call_me_for('BeforeAnswerHeaderSend', 'get_info_header_size_code_num')
end

function get_info_header_size_code_num()
local _,_,x = string.find(hc.answer_header, '[cC]ontent%-[lL]ength: *(%d+)')
local size_code = tonumber(x)
local size_code_num = (size_code)/1000
local numdecimal = '2'
local mult = 10^(numdecimal or 0)
local size_code_num = math.floor(size_code_num * mult) / mult
hc.set_global('size_code_num', size_code_num)
end

1.lua:
Код:
--[[ <HCExtension>
@name Test 1.lua
@author truefriend-cz
@event RequestHeaderReceived
</HCExtension> ]]

function RequestHeaderReceived()
local size_code_num = hc.get_global('size_code_num')
hc.put_msg(1, 'Test OK: 1: '..size_code_num)
end
« Последнее редактирование: 08 августа 2017, 21:44:51 от truefriend-cz » Сообщить модератору   Записан
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #4 : 10 августа 2017, 00:38:13 »

Why no success this script?
In documentacion have re.answer_header worked on RequestHeaderReceived, BeforeRequestHeaderSend, BeforeRequestBodySend,       AnswerHeaderReceived, BeforeAnswerHeaderSend, BeforeAnswerBodySend

but working on AnswerHeaderReceived, BeforeAnswerHeaderSend only.

Код:
--[[ <HCExtension>
@name Test 1a
@author truefriend-cz
@event RequestHeaderReceived/Test
</HCExtension> ]]

function Test()
local x = re.find(hc.answer_header, [[^Content-Length: (.+)]]) --format from documentation
local size_code = tonumber(x) --with and without this line some problem
hc.put_to_log ('AAA = '..size_code)
end

In LOG show as: attempt to concatenate local 'size_code' (a nil value)
« Последнее редактирование: 10 августа 2017, 00:49:12 от truefriend-cz » Сообщить модератору   Записан
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #5 : 10 августа 2017, 15:05:38 »

Please help me.
For testing i create next simply variation, but not accept.
I tested combination with "required", "dofile", "assert(loadfile(filename)", etc. But no accepted all.

0.lua:

Код:
--[[ <HCExtension>
@name Test 0.lua
@author truefriend-cz
@event AnswerHeaderReceived/Test0
</HCExtension> ]]

function Test0()
var_nul = 'OK transfer from 0.lua'
hc.put_to_log ('Result: '..var_one)
end

1.lua

Код:
--[[ <HCExtension>
@name Test 1.lua
@author truefriend-cz
@event AnswerHeaderReceived/Test1
</HCExtension> ]]

function Test1()
hc.put_msg(1, 'Result:  '..var_nul)
var_nul = 'OK transfer from 1.lua'
end

Output from 1.lua: OK transfer from 0.lua
Output from 0.lua (log): attempt to concatenate global 'var_one' (a nil value)
« Последнее редактирование: 10 августа 2017, 15:14:43 от truefriend-cz » Сообщить модератору   Записан
Михаил
Gold beta tester
*****

Репутация: +337/-14
Offline Offline

Сообщений: 5513



« Ответ #6 : 10 августа 2017, 15:24:21 »

Some posts ago you ask to help with script named "Test - SL"
I start discussion. But you break it at once without any sorry reason.
And then asked for another scripts named "Test 0.lua" and "Test 1.lua".
I think this is disrespect.

Now you asked for help in another script. If I'll try to do this, you may break discussion again.
There is no any desire to help in such situation.
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #7 : 10 августа 2017, 16:00:50 »

So here we are dealing with social affairs as a greeting, disrespect, or whoever he's been doing, saying how he is, how he feels, how he looks and how he looks. Or we can solve technical issues - what does not work, how it could work, etc. I try to best describe the problem in the technical field. Here are some examples. If you want to solve social problems, I can not help you. It's contradictory. I have nothing against you, you are quite technically technical. I have already mentioned that some people in the social field are doing bad things or difficulties. In addition, when I was socially at a very high level where I grew up, I appreciated people, things, etc. So the people around them started to abuse up to the level where I was dead on the street, and even at that moment the co-drivers did not help me - the problem is In the fact that I have no idea how to say, and that people can see the motionless person directly beside them is not enough. So I'm sorry, but I've left the social pages. I'm not interested in working socially. Even though I'm not saying that all people are bad. So I went back to the area where I'm interested in computers, technology where I could sit down all day at the server room for my life. Do not see anyone and I could buy what I needed. Food, etc., until a few people started to cut me off from work, property, friends, schools, etc. However, I try to keep what I have left behind, even though I seem to be little social. Again, I repeat that the social side has destroyed me all my life, so I have no interest in any social affiliation anyway. I have a broken family, friends, school, partnership, work and health. Due to the social or social system. The only problem was that I was led to my whole life to be successful. And when I was successful in both work and relationship, and I could have my own family, politicians and other people took everything to me. They did not work so they did not know about it. When I'm socially respectful, decent and kind, people will complain that there is a lot. When I cough people, they will complain that there is not much. If they did, they would do more. Just like here on the forum. I do not know what you want socially for me. Helping you, I have offered to put you in the script, and it is technically possible for you to be helpful or to show you respect. I'm sorry I do not show you the respect in your given way.

I'm currently studying LUA and from a programming perspective I take your advice to my heart and try to follow them. Or I can still send you smails as other people do here in the forum but I think it's better to write than send smail ( Улыбка Подмигивающий Веселый Злой Грустный Шокирован Показывает язык Непонимаю :Улыбка Плачущий Help me! Читай доки! lol Смущен Благодарю Отлично!). While I have no doubt that when I do not send smail senders, people will complain that I do not send smails messages. And when I send them, I send them. I'm not doing this. The people around me and the Internet yes. I am trying not to solve this problem and to do something, to cooperate, etc.

I have already been respectful to the people and I consider it a life mistake. It's invariable, it's statically stored. I did not save this "feature" to my head but saved to my head others peoples. I can not do anything about it if I wanted to. And not tergiversation. I am sorry.

Sorry bad English
« Последнее редактирование: 10 августа 2017, 16:19:46 от truefriend-cz » Сообщить модератору   Записан
hc.addict
Новичок
*

Репутация: +1/-0
Offline Offline

Сообщений: 21


« Ответ #8 : 12 августа 2017, 21:30:34 »

Too bad for you @truefriend-cz. You got attitude problem.
Сообщить модератору   Записан
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #9 : 13 августа 2017, 02:04:07 »

I do not think so. It depends on the point of view. I'm doing something, I've had a project. Man, here he pretended to be grateful. In a private report, I offered him a collaboration on this project by saying that as a person who helped me, he refused, but wrote that he would like to help me. After that, he wrote that I'm not quite grateful. I did not propose any solution or suggestion how to be grateful to me. Other ways of gratitude do not argue with me. For every help I thanked him and offered to put him in my scriptures. I have some idea that I realized but I'm not such a good programmer so I can put it into detail and before I can learn the language properly in detail, so here you are no longer killing me for how terribly swine I'm going to spend Up to 100% of the time, so you'll have shit. I'm gonna have shit and you'll have a very good feeling about how you turned me. That's what makes me people in my life for about 6 years. Where they also abuse the police of the Czech Republic. Instead of being interested in things, they drive as stupid and confiscate property, throw me out of places where I am, where I have programmed before, and nobody hugged anyone. People just bothered that I just did not sit on my ass and do something. When I was sitting on my ass and doing nothing, then it was a bother to do it, and they gradually built up the structure of functioning up to the level where they taught the police and criminal police to work that I do not have any protection. I still try to program myself. If I had something pre-programmed, then they helped me or I could be grateful, or the way of gratitude I chose to see it is functional ... So I'm shit, you're shit and you have at least something and I have prevented the attacks , From you people, as people do to me personally, so I gave you what I made available to you. Some remorse that somebody helped me with something, I have neither nervous nor any attitude and I do not find it a mistake. I find it a mistake that the social system is incapable of removing this property on a global scale from people. I'm just interested in or just interested in enjoying myself and family. They do not respect people, and they have not repaid if I need money to enjoy myself and my family. And if they knew I had a partner, they took it for my own benefit (political intention, politics) and when I tried to get him, they blocked me. The same thing with my mother, the same thing with my friends and all that is sanctified by the police, of which they basically made friends too. So maybe it seems to me that I'm acting overly or illogically. But consider it so much that I already know how this social system works, and that activity that seems like banality to you now has such consequences that you too would look like a fool. It matters whether you have something to offer to people or you are a jerk who can only be from morning to evening somewhere in the car and sweep dust. Or you can bring something that solves not only that it does not "sweat" anywhere. Unfortunately, the bitch of this company, it is a social competition and I can not only answer you here that I do not play games. It does not mean that you compete with each other and they take people, things, partners, and space. It helped me to do something. I do not suppose you will like it, or you will not blame me in any way. Because people have been doing me for 6 years, I'm 4 years on the street where I still try to do it. And when I do not do it, people complain again that I'm not doing that ... because they always find enough stupid people to reward them for complaining than for doing it. So if you mind if I write this, just do not read or write to me. I will not write to you in the feedback. You will die in peace and I, too.

From a programming perspective, I confess that I am anxious and socially so unlikely, but I can also have a different, perhaps better, view on things. It depends on you whether you can use it or kill me for it. People in the social field are trying to kill me for about six years. Where I can neither program nor work. It holds me violently on the street, through slander, manipulation with the police, politics in our region, etc. Everybody knows it, but international institutions ignore it. I've already come to terms with it and when I see that something like that is happening somewhere or starting to happen, then I think maybe in your view, I may act actively or incomprehensibly, but believe that I know very well how it would go on. The problem is not what or how I do. Again, if you did not favor social matters such as the one who faces, or who speaks, writes, or expresses gratitude, then you will be satisfied. What the people take to me is space. The same here. I need the space for that, and it's not an excuse. This space is at the level of what I have begun to build or what to do at the social level. The people around me have begun to demolish my relationship and give priority to pushing my nose, restraining and eliminating everything, and pointing out that there are two people together, resulting in total destruction of everything, including attacks on the lives of those people. Blocking any communication, etc. And I can not work and I can not and I can not. On those things I need to concentrate and have peace of mind and not to figure out who is as stupid as to whom he smiled. When I behaved peacefully and kindly to people, my people and my partner were cheating, stealing and destroying the family and the relationship to the level of politicians, and they continue at various levels without any limit. When it is defiled, people smile and they react that when they smile, everything is fine and they are further demolishing me. Still, I'm still trying to do it ... I was trying to do something to do something, learn something, learn a new programming language, and so on. These people will not let me, and on some level, people are doing it in the forum. So I'm not interested in both you and the co-worker on what to do here. For help, I thank the principal author of the application. May62, I did not feel this property there. At Paul, yes, which is one of the main tester, and this mode of social functioning is also transferred to my work and I do not want it. I'm just making bigger mistakes. What the people do on a social level is that they're overwhelming me, trying to solve one thing for years ... at least, so that I can meet my own partner and abuse it for my own benefit where they block me from being with him He could not communicate anyway, and they favor each other, but they can turn around so that people around them seem the same or how they fit them. When they cough him, they complain that they cough him.

If I do not fool him, they complain that I do not fool him. And when my things are exactly what they think, they just find another stupid thing, or another stupid thing they do the same. And it's over and over, including police and criminal police, and when I'm on the street, they still point out that I'm incompetent because I'm homeless. But the fact that I was able to have had a partner, had a product of a very high amount, so it never told anyone again and the people would not let me say anything. Nobody wants to hear anything, but when it comes to getting me in jail, it's all active now and I'm driving cars, ordering, ordering, forbidding, shouting, and still trying to do it. If you want to speculate on it, speculate and drown yourself. While you are dealing with these social stupid things, I could have done it somehow. You do not want to do it anymore, and do the scripts you want. In connection with how people are behaving here, I give up any benefits, here to learn to program in LUA, or to realize the idea of ​​my project. Maybe it will be something for you. I have some other expectations from life. The fact that I came here for help with something that I do not think of as advice is something that is somehow a disgrace and someone else complained that I am not generous enough or that I do not consider myself enough I do not know how I have Appreciate something. If it is not enough to publish the person who helped me as a person who helped me or to thank him for every part of the script, I apologize, but I can not do more. And another thing: It would then be appreciated that someone to be grateful to me does not matter to me because I'm also programming just for other people who would then have the project or the scripts and whether or not me Someone grateful depends on those people and not me or the programmer. We are technicians, we see the brothel and we try to make the user as cotton. If these technicians already solve one another, as gratitude or as someone who smiles, I think that there should be no such thing among the people, and that it does not belong to this society either. Developers. I'm just trying to get it done as soon as possible, while doing some things collectively. And then use the thing and make it to the benefit. Then do other things, go for a beer, talk about something else, or be grateful. But I certainly will not combine at the time I do it to be interested in dealing with social issues. I can be grateful to be, but if that person wants me to be grateful here, and defacto himself does not know how and he does not attack me, and he bases on ot that it does not help me if I'm not grateful, so sorry, but get everyone Product shit. I'm not a social hitter here who wants to do it, and then again, and best to do 20 things at a time, because it all would cost shit. Both programming and social issues. What I do, I needed to concentrate on it, if you prefer these social things, then ok, let everything go and we can all be thankful all the way to the fuck and the whole forum can be based on how we all can wonder about the beauty of the shit. And then when we talk about it, we will find out that we have actually done total shit all the time and we are too lazy to do anything else so it pays off to just wait till we dead. I do not know who I am. But I know this is happening.

I apologize for that point of view, but it is today's reality. I just describe what reality is. If someone does not agree, then I recommend, visit the Czech Republic and live a few months on the street. I do not think it's a problem for the Republic. Those stupid will not come to it in a few years. Those smarter in a few weeks.

Bad English - Google Translate
« Последнее редактирование: 13 августа 2017, 02:13:20 от truefriend-cz » Сообщить модератору   Записан
truefriend-cz
Постоялец
***

Репутация: +3/-1
Offline Offline

Сообщений: 118


« Ответ #10 : 13 августа 2017, 03:28:14 »

In the environment where I find myself, I am all the people unconditionally built in that the right attitude is to steal, murder, minipulte with people, forced to smile, reshape, which I do not do all my life, and even for this I do not have a trained mimic like these people. This is how the attitude is defined, unconditionally in the Czech Republic. And if I do not behave, I'm destroyed. If I behave like that, the bubu is locked in jail. The other way of working the political system and the social system in the Czech Republic does not diminish, because it takes people for such a funogation of space, so that one is dependent on politics, social system and was not able to feed himself by means of these methods of functioning. If they steal a group of people or have their acquaintances, they are also favored by state components. If he does not behave, he is blocked because he is an individual and restricted and punished that he steals, does not blame, does not pounce, as they do ... if he does, they point out to the public and seduce him that he Everything bad and hence the group of people can continue to work. When the man is upset by this system (scratch), he can not do anything about it because he is locked in jail. Another way of working is not accepted. If I did not work, people would persecute me and restrict me for not working and I'm not very efficient. If I work and I will be successful, they will confiscate property, steal people, etc. without any possibility or protection to do so - there is no element in the state that would restrict this behavior, and when one dies on the street, so It is already in a situation where people do not see what has been done, believed, and respond to the general impression that these people define across the media. Even people who do not believe in the street because they are more responsive to the general impression than to the reality.
Of which the whole society lives in our country. They have something to complain about, or to whom they point out, even in the level where the person does not endanger anyone and tries to make choking out of a peaceful situation where I need to focus on work, family, etc. Nobody respects and does not respect and nobody He does not care. But to make everybody in a violent way and with the means of coercion he wants money for me. How to stand, people around. But the fact that I have to earn them somewhere does not care about anyone and I get the things I need for it. Including families, but they point out that I am unable to have a family, but they have manipulated the partner, but they are able to work with it so it seems that it may or may not be so. It's not my system, but theirs. But they began to interfere with my system and liquidate them, because a debilitating person defines them as any kind of operation that is not such that a person survives or dies but needs to be destroyed.
Сообщить модератору   Записан
Страниц: [1]   Вверх
  Отправить эту тему    Печать  

 
Перейти в: