Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (degenerate_762), 1,114 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
String from R to Zorro #485308
02/22/22 09:03
02/22/22 09:03
Joined: Dec 2021
Posts: 7
B
budfox Offline OP
Newbie
budfox  Offline OP
Newbie
B

Joined: Dec 2021
Posts: 7
Hi there,

I'm currently trying to read strings from R into Zorro. I tried using Rd and Rv but I'm just not getting it.

I was wondering if someone could share a simple example or give me a hint? I included my current status below...

Code

#include <r.h>

typedef struct {
	string Asset1;
	string Asset2;
} Pairs;


function run() 
{
	set(PLOTNOW);
	
	StartDate = 2015;
	EndDate = 20190101;
	BarPeriod = 5 * 1440;
	
	static Pairs Pair1;
	
// ---------------------------------------
// Startup and data loading
// ---------------------------------------  
	if(is(INITRUN)) 
	{
		printf("Script is running!\n");
		// start R
		if(!Rstart("Test.R", 2)) 
		{
			print("Error - can't start R session!");
			quit();
		}
	}
	
	Rx("testnames <- testfunction()", 2);

	Pair1.Asset1 = Rd("testnamen[[1]]"); // Doens't work due to Pointer Error - Can't figure it out
        Rv("testnamen", Pair1.Asset1, 2); // No Error but no value in Pair.Asset1

	printf("Test Wert 1: %s\n", Pair1.Asset1);

	watch("!----\n");
}

R Code:

testfunction <- function() {
  return(c("Asset", "Name"))
}



I was trying to store assetnames into a struct containing strings.

Thanks for any help!

Re: String from R to Zorro [Re: budfox] #485315
02/23/22 12:53
02/23/22 12:53
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
You can send strings from Zorro to R but I see no function to send strings back from R to Zorro. R is normally used for numerical calculations, not for strings.

Re: String from R to Zorro [Re: Spirit] #485322
02/23/22 17:39
02/23/22 17:39
Joined: Dec 2021
Posts: 7
B
budfox Offline OP
Newbie
budfox  Offline OP
Newbie
B

Joined: Dec 2021
Posts: 7
Hey Spirit,

Thanks for your quick reply!

After taking another look at the manual, I realized that you can only send doubles of R to Zorro, but AndrewAMD has a very nice suggestion to cut the corner (See also this post).

Appreciate your help!


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1