Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2 questions (Q1: script not working and Q2: dynamic vars)
#1
I have 2 questions.

Question 1:
I have a script that outputs "a" to "z" strings, in the following way

a
.
.
z
==== next cycle
aa
ab
.
.
az
==== next cycle
aba
abc
abd
.
.
abz
==== somewhere in final cycle
abcde
abcde
abcde

But somewhere in the final cycle the string misses characters, it should be

abcdea
abcdeb
.
.
abcdez

My script:

Macro Macro17
Code:
Copy      Help
str s="abcdefghijklmnopqrstuvwxyz"
int i t1 t2
str x=" "

;;Each letter in charactercode array
ARRAY(int) b.create(s.len)
for(i 0 b.len)
,b[i]=s[i]

;;to output window strings:  
;;a...z, aa ab ac...az, aba abc abd... abz,  ...etc

for t1 0 7
,for t2 0 b.len        
,,if(t1=0)
,,,x[0]=b[t2]                
,,else
,,,x.fix(x.len+1)
,,,x[t1-1]=b[t1-1]
,,,x[t1]=b[t2]
,,out x


Is it because 'x.fix' ?
Quote:Must not exceed the number of bytes in the string buffer (nc property).




Question 2:
is it possible to dynamically create variables and arrays:

Macro Macro19
Code:
Copy      Help
int i
for i 0 3
,str si

I should have 3 variables: s0, s1, s2

Macro Macro19
Code:
Copy      Help
int i
for i 0 3
,ARRAY(str) si

I should have 3 arrays: s0, s1, s2

The code off course is totally wrong, but I only want to clarify the question.
#2
1. Yes, x.fix(x.len+1) is incorrect.
Macro Macro2104
Code:
Copy      Help
out
str s="abcdefghijklmnopqrstuvwxyz"
int i t1 t2 maxLen=7
str x.all(maxLen 2 ' ')

;;to output window strings:
;;a...z, aa ab ac...az, aba abc abd... abz, ...etc

for t1 0 maxLen
,memcpy x s t1
,for t2 0 s.len
,,x[t1]=s[t2]
,,out x

2. No.
#3
Ok, thank you!!!

edit: Sorry, what does 'memcpy' do? (couldn't find it in help file or QM search help input-field)
#4
click, F1, google in MS


Forum Jump:


Users browsing this thread: 1 Guest(s)