using arrays in George

A forum dedicated to George scripting questions
Post Reply
wvreek
Posts: 10
Joined: 29 Jul 2009, 08:01

using arrays in George

Post by wvreek »

Hi there,
I'm making a conversion tool, and want to load a series of names in an array.
But all normal procedures like:

Code: Select all

names = ['first, 'second', 'third']
don't work. The only way seems to be to cycle 1 by 1:

Code: Select all

n=0
name[n] = 'first'
n = n+1
name[n] = 'second'
etc. etc.
Or is there a more efficient way?
User avatar
Broughtvulture
Posts: 31
Joined: 09 Jul 2015, 00:58

Re: using arrays in George

Post by Broughtvulture »

I'd recommend using the "FOR" statement as a more effective way of loading a series of names in an array:

Code: Select all

PARAM NONE

Length = 3

Array[1] = "First"
Array[2] = "Second"
Array[3] = "Third"

FOR i = 1 TO Length
tv_warn "Array " i " = " Array[i]
END
Here is the documentation this is based on:
"George Script Basics"(Arrays):
http://wiki.tvpaint.com/index.php?title=George#Arrays" onclick="window.open(this.href);return false;

"For statement":
http://wiki.tvpaint.com/index.php?title=FOR" onclick="window.open(this.href);return false;
Windows 7 64-bit
FX 8350 8 Core - 16 GB RAM
TVPaint Professional 11.0.8 64-bit

BNV
User avatar
schwarzgrau
Posts: 1238
Joined: 23 Jan 2012, 22:08
Location: Offenbach / Germany
Contact:

Re: using arrays in George

Post by schwarzgrau »

wvreek wrote:Or is there a more efficient way?
I don't think so. I've just started using GEORGE and had the same problem. It seems to be a very very basic programming language, where not everything is possible ( which usually is ). Stuff which is even possible in javascript etc.
I tried to check if a variable is set a few days ago, which seems to be impossible in GEORGE. I guess the TVPaint developers added a few commands over the years, but it isn't been developed since the early nineties.
Windows 11 22H2 / TVP 11.7.0 PRO WIBU / Cintiq 22HD
Windows 11 22H2 / TVP 11.7.0 PRO WIBU / Mobile Studio Pro 16" (2019)
Android 13 / TVP 11.7.0 / Galaxy Tab 7 FE
INSTAGRAM
wvreek
Posts: 10
Joined: 29 Jul 2009, 08:01

Re: using arrays in George

Post by wvreek »

Thanks for your answers

@ Broughtvulture:
Yes, I'm aware of FOR and the docs, but the problem of still having to assign the names 1 by 1 remains, but I solved it with js.

@ schwarzgrau
Yeah, I guess it is.
Just made a small js routine to generate the cumbersome routine and pasted it into the george script, works fine now.
User avatar
schwarzgrau
Posts: 1238
Joined: 23 Jan 2012, 22:08
Location: Offenbach / Germany
Contact:

Re: using arrays in George

Post by schwarzgrau »

You integrated js into george ? It seems I have absolutely no idea what I'm doing. Could you tell me how ?
Windows 11 22H2 / TVP 11.7.0 PRO WIBU / Cintiq 22HD
Windows 11 22H2 / TVP 11.7.0 PRO WIBU / Mobile Studio Pro 16" (2019)
Android 13 / TVP 11.7.0 / Galaxy Tab 7 FE
INSTAGRAM
wvreek
Posts: 10
Joined: 29 Jul 2009, 08:01

Re: using arrays in George

Post by wvreek »

No, I mean I just used js to generate the text of the george commands and pasted that into the george file.
To avoid typing all the names in the folders I wanted to convert.

cheers, Wouter
User avatar
Broughtvulture
Posts: 31
Joined: 09 Jul 2015, 00:58

Re: using arrays in George

Post by Broughtvulture »

wvreek wrote:Thanks for your answers

@ Broughtvulture:
the problem of still having to assign the names 1 by 1 remains, but I solved it with js.
I accepted the challenge =)

Code: Select all

//Automatic Name Creator
//Type in Names, Insert Numerical Value
//Arrays with Names created Automatically
//---------------------------------------
//---------------------------------------
//---------------------------------------
//Insert Names & Number of Names
List = "First Second Third"
Amount = 3
//---------------------------------------
//Creates Incrementor
Length = 0
FOR i = 0 TO Amount
IF (i > 2)
Length = Length + 1
END
END

//Creates Array
ListName[Amount]
TrueAmount = Amount - 1

//Assigns Values to Arrays
FOR i = 0 TO Length
parse List numa numb
//tv_warn "Numa: " numa " - Numb:" numb
ListName[i] = numa
IF (i == Length)
ListName[i+1] = numb
END
List = numb
END

//---------------------------------------
//Displays Arrays & Values Given
FOR i = 0 TO TrueAmount
tv_warn "ListName[" i "] = " ListName[i]
END
//---------------------------------------
//---------------------------------------
//---------------------------------------
//TO wvreek
//FROM Broughtvulture
Windows 7 64-bit
FX 8350 8 Core - 16 GB RAM
TVPaint Professional 11.0.8 64-bit

BNV
Post Reply