I found a problem when I use the ip 142.250.187.100 for test but now not responding. This affect then read only variables named INTERNET and INTERNET$. Revision 7 fix the problem.
We can bypass INTERNET functionality by using a global group INTERNET which return a value (so call a function without using parenthesis postfix on the name):
global Internet=lambda (a$="100")-> {
group a {
ip$="142.250.187."+a$
value {
declare client client
With client, "NoError", True
Method client, "SetTimeouts", 100, 300, 200, 300
Method client, "connect", .ip$, 80 As connect
=connect
}
}
=group(a)
}() // ("10") is ok
module inner {
? internet 'our global using 142.250.187.100 which not working
? @internet ' original - version 14 revision 7 return true, all other return false
}
Inner
The Inner module can call original internet using @. Global Grouo Internet { } not bypass then original Internet read only value, but using a simple global variable which get the group by a function do the job.
This module show how we can use a group to do the same job as internet$ do.
module testB {
global internet$="" ' need this to bypass the original internet$
function mockup(a$="100") {
group z$ {
ip$="142.250.187."+a$
value {
=" 0"
declare client client
With client, "NoError", True
Method client, "SetTimeouts", 100, 300, 200, 300
Method client, "connect", .ip$, 80 As connect
if connect then
declare HttpsRequest HTTPS.REQUEST
With HttpsRequest,"BodyFistLine" As RESP$
Method HttpsRequest, "HttpsRequest", "HTTPS://ifconfig.co/ip" As OK
if OK then =RESP$
end if
}
}
=group(Z$)
}
global internet=mockup()
? internet$
let internet=mockup("10")
? internet$
list
}
testB
? internet$ ' this is the original
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.