Gamestudio Links
Zorro Links
Newest Posts
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
6 registered members (Petra, AndrewAMD, VoroneTZ, Quad, 2 invisible), 833 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 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