hcrisp

01-07-2010, 03:37 PM

Why does this give a segmentation violation? Wave 8.0 with XP.

x = ['a', 'b', 'c']

PM, x

PM, REPLV(x, [3,3], 0)

PM, REPLV(x, [6,3], 0)

x = ['a', 'b', 'c']

PM, x

PM, REPLV(x, [3,3], 0)

PM, REPLV(x, [6,3], 0)

View Full Version : REPLV with strings

hcrisp

01-07-2010, 03:37 PM

Why does this give a segmentation violation? Wave 8.0 with XP.

x = ['a', 'b', 'c']

PM, x

PM, REPLV(x, [3,3], 0)

PM, REPLV(x, [6,3], 0)

x = ['a', 'b', 'c']

PM, x

PM, REPLV(x, [3,3], 0)

PM, REPLV(x, [6,3], 0)

rwagner

01-08-2010, 10:58 AM

This is a documentation error on our part. This routine is not compatible with string datatypes. Thank you for reporting this.

totallyunimodular

01-08-2010, 03:46 PM

Underneath the hood in REPLV it calls REBIN and that is what does not like strings. This turns out to be kind a tricky problem, for me at least. Here is one way to do it, but there has to be a better way:

x = ['a', 'b', 'c']

new_x = STRJOIN(x, ' ')

new_x = new_x + ' '

y = REPLICATE(new_x, 6)

dims = [6,3]

z = STRARR(dims(0), dims(1))

for i=0,dims(0)-1 do z(i,*) = STRSPLIT(y(i), ' ')

INFO, z

;Z STRING = Array(6, 3)

PM, z

;a b c

;a b c

;a b c

;a b c

;a b c

;a b c

x = ['a', 'b', 'c']

new_x = STRJOIN(x, ' ')

new_x = new_x + ' '

y = REPLICATE(new_x, 6)

dims = [6,3]

z = STRARR(dims(0), dims(1))

for i=0,dims(0)-1 do z(i,*) = STRSPLIT(y(i), ' ')

INFO, z

;Z STRING = Array(6, 3)

PM, z

;a b c

;a b c

;a b c

;a b c

;a b c

;a b c

hcrisp

01-11-2010, 07:28 AM

Ryan,

When you file the change request, can you make sure the fix handles the error more elegantly than a segmentation vioation? That way it will keep from crashing PV-WAVE if it finds that particular syntax in my code. Thanks.

Unimodular,

The easiest work-around for me includes using a FOR loop:

x = ['a', 'b', 'c']

xm = STRARR(6,3)

FOR i=0L, N_ELEMENTS(xm(*,0))-1 DO xm(i,*) = x

pm, xm

;a b c

;a b c

;a b c

;a b c

;a b c

;a b c

When you file the change request, can you make sure the fix handles the error more elegantly than a segmentation vioation? That way it will keep from crashing PV-WAVE if it finds that particular syntax in my code. Thanks.

Unimodular,

The easiest work-around for me includes using a FOR loop:

x = ['a', 'b', 'c']

xm = STRARR(6,3)

FOR i=0L, N_ELEMENTS(xm(*,0))-1 DO xm(i,*) = x

pm, xm

;a b c

;a b c

;a b c

;a b c

;a b c

;a b c

rwagner

01-11-2010, 10:25 AM

Hcrisp, Yes, I'll be sure to include that in the CR. Wave should obviously not be seg-faulting here.

Powered by vBulletin® Version 4.2.3 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.