mewindy
-
Content Count
19 -
Joined
-
Last visited
Posts posted by mewindy
-
-
one solution i have found is to disable all the unnecessary android library files in the project configuration/libraries (right hand pane)
-
goodbye to this forum where you have people like this on here posting like this
-
OK. for some reason
having a tchart
on the tlayout
is the problem when using tlayout.makescreenshot
if I set the tchart to not visible then no error
-
ignore
-
OMG
you are correct!
I should have spotted that
its working now
thanks Remy!
-
HI
thanks for the help so far
here is the raw data to st as
{"data":{"did":"001D0A710197","ts":1557136813,"conditions":[{"lsid":223656,"data_structure_type":1,"txid":1,"temp": 52.7,"hum":66.3,"dew_point": 41.8,"wet_bulb": 46.2,"heat_index": 51.7,"wind_chill": 52.7,"thw_index": 51.7,"thsw_index": 49.7,"wind_speed_last":0.00,"wind_dir_last":0,"wind_speed_avg_last_1_min":0.00,"wind_dir_scalar_avg_last_1_min":null,"wind_speed_avg_last_2_min":0.00,"wind_dir_scalar_avg_last_2_min":null,"wind_speed_hi_last_2_min":0.00,"wind_dir_at_hi_speed_last_2_min":0,"wind_speed_avg_last_10_min":0.00,"wind_dir_scalar_avg_last_10_min":null,"wind_speed_hi_last_10_min":0.00,"wind_dir_at_hi_speed_last_10_min":0,"rain_size":2,"rain_rate_last":0,"rain_rate_hi":0,"rainfall_last_15_min":0,"rain_rate_hi_last_15_min":0,"rainfall_last_60_min":0,"rainfall_last_24_hr":0,"rain_storm":null,"rain_storm_start_at":null,"solar_rad":0,"uv_index":0.0,"rx_state":0,"trans_battery_flag":0,"rainfall_daily":0,"rainfall_monthly":0,"rainfall_year":0,"rain_storm_last":null,"rain_storm_last_start_at":null,"rain_storm_last_end_at":null},{"lsid":223554,"data_structure_type":4,"temp_in": 69.1,"hum_in":38.2,"dew_point_in": 42.6,"heat_index_in": 66.8},{"lsid":223553,"data_structure_type":3,"bar_sea_level":29.932,"bar_trend": 0.028,"bar_absolute":29.404}]},"error":null}
if I use the code like
JsonValue := TJSONObject.ParseJSONValue(st);
if JsonValue <> nil then
try
JsonObject := JsonValue as TJSONObject;
JsonData := JsonObject.GetValue('data') as TJSONObject;
JsonConditions := JsonData.GetValue('conditions');
if (JsonConditions is TJSONArray) then
begin
JsonObject := (JsonConditions as TJSONArray).Items[0] as TJSONObject;
Branch:= JsonObject.GetValue('temp').Value;
memo1.Lines.add('Parsed temperature '+branch);JsonObject := (JsonConditions as TJSONArray).Items[1] as TJSONObject;
Branch:= JsonObject.GetValue('bar_sea_level').Value;
memo1.Lines.add('Parsed barometer '+branch);end;
finally
JsonValue.Free;
end;then the second part to get the bar_sea_level causes an access violation error (i.e I have tried access as items[1]
so I must be still doing something wrong
-
I might have found the problem
a global variable that was initialised at form create needing to be re initialised when used in a for loop (it must have been going out of range of the loop)
will know after more testing if that was it ...and nope after testing more..one day I might figure it out!
-
HI all
just need a bit of help using Delphi's json functions please 🙂
I have this code working OK
e.g
st := tempstr;
JSonObject := TJSonObject.Create;
JsonValue:=JSonObject.ParseJSONValue(st);
JsonValue:=(JsonValue as TJSONObject).Get('data').JSONValue;
JsonValue:=(JsonValue as TJSONObject).Get('conditions').JSONValue;
if (JSONValue is TJSONArray) then
begin
Branch := ((JSONValue as TJSONArray).Items[0] as TJSonObject).Get('temp').JSONValue.Value;
end;JSonObject.Free;
but I want to get data from a data pair that is on a second bracketed data
ie. it works as above for the first data array
but the json data has another data array
i.e
first data array pairs},{second data array pairs
how to I read from the second data array ?
thanks!
(just putting the name in as in the branch code above that is in the second data array causes an error
🙂
-
i think its a red herring
as its random
I did see a message in the console about memory corruption
so something else going wrong someone else in my code but it just happens to be tripping up at that point?
-
that was not it....the problem is the error is random..does not happen every time
-
OK..progress
it turns out
that I had a tchart on the layout1
and I had set thcart.enabled to false and also locked when doing the layout1.makescreenshot
setting those to false before the makescreenshot seems to have fixed it...
will test more..
so an obscure bug/change from 10.2 to 10.3 that has been driving me nuts lol
-
OK, this is the problem code (illustration, i.e simplified) in 10.3
but not in 10.2
var
forimage:tbitmap;
begin
formimage:=layout1.makescreenshot;
end;
-
update, using try, except,then log the error, i have managed to trap where the error is
not sure what is wrong yet with the code but will try different things
-
a bit more info
If I run the linux program in the compiler its actually an eaccess violation
so I have some variable going out of range
or similar
the problem is I cant get the compiler to show the source code point as it wants to know the location of a .so linux library file..but that is only my linux machine
so I press ignore..the next time the error occurs I try trace into..but I just get the cpu screen...how do I use that info? 🙂
-
I do see one thing I have done wrong in my linux code and that is I have
used
try
obj := TMyObject.Create;
obj.DoSomething;
finally
obj.Free;
end;
instead of
obj := TMyObject.Create;
try
obj.DoSomething;
finally
obj.Free;
end;
which could lead to the object being freed when its still in use?
-
@David Heffernanyes, I do use that method, at least try too!
and yes I had deduced that I will be calling free on an object that that has already been freed or similar
so ARC has actually meant some underlying problem in my code I am getting away with it would seem?
thanks for the replies, I am more clearer now 🙂
-
HI
I see that Delphi 10.3 has done away with ARC on Linux?
now my program is throwing random access violations that I am struggling to figure out why
the same code does not do that , on linux, when compiled with Delphi 10.2 instead of 10.3 (I think 10.2 had ARC for linux)?
Q: should I be using disposeof instead of free under linux with 10.3 ?
-
HI
I am wanting to capture to a bitmap the contents of a paintbox
after doing a paintto that
on FMX
(sample code is for VCL. eg using copyrect)
🙂
Thanks!
Brian
edit
I got it to work 🙂
using this code on the onpaint event on the paintbox
(I create formimage bitmap first)
var
aRect: TRectF;
begin
aRect := RectF(0,0,formimage.Width,formimage.Height);
Canvas.DrawBitmap(formimage, aRect, PaintBox1.ClipRect, 1, False);end;
edit
that works ok on windows for copying the contents of a form (i.e form1.paintto)
but that only ends up with a blank image when run on OSX (Mac)
I know you can use a tlayout and use makescreenshot
but that does not always capture all the elements on the form
is there a way to capture the contents of a tlayout some other way ? (on OSX/FMX)
Execute external program/command and capture output
in Cross-platform
Posted · Edited by mewindy
for MACOS
I use
procedure TForm1.Exec(FileName: PWideChar);
var
Workspace: NSWorkspace;
NSApp: NSApplication;
Nw: NSWindow;
begin
if fileexists(FileName) then
begin
Workspace := TNSWorkspace.Create;
Workspace.launchApplication(NSSTR(FileName));
Workspace.release;
end;
end;
and in the uses:
Macapi.Foundation, Macapi.ObjectiveC, Macapi.Helpers, Macapi.AppKit
to execute another program
or
use
_system(PAnsiChar(p_cmd));
to execute a command (e.g terminal command)
where p_cmd is string e,g '/usr/local/bin/curl "mycommandhere"