Page 1 of 1

problem with # command

Unread postPosted: 06 Feb 2015, 16:44
by compsystems
Hello, for the following program does not save the contents of variable id1. is a tibasic problema?, there is a ASM program that solves the problem.

Thanks

Code: Select all
test(cpyname,val)
Prgm
  Local temp
  ClrIO
  Disp "cpyname="&string(cpyname) © cpyname->id1
  Disp "val="&string(val) © val->50
  Disp "cpyname="&string(#(string(cpyname))) © cpyname->id1
  Pause

  Disp ""

  val→#(string(cpyname)) © cpyname->50 => id1->50
  Disp "cpyname="&string(#(string(cpyname))) © cpyname->val ???
  Disp "id1="&string(id1) © id1->50 ?????????
  Disp ""

  temp→#(string(cpyname)) © cpyname->temp
  val→temp

  Disp "cpyname="&string(#(string(cpyname)))
  Disp "id1="&string(id1)
  Disp ""

  Pause
  DispHome

EndPrgm


Entry Line steps

DelVar id1 [ENTER]
id1 [ENTER]
test(id1,"50") © 50→id1 [ENTER]
id1 [ENTER]

Re: problem with # command

Unread postPosted: 17 Feb 2015, 08:03
by Bisam
If I understand your comments, it seems that at line :
Code: Select all
  val→#(string(cpyname)) © cpyname->50 => id1->50
the simplification before assignation is incomplete... which is common in a program.
Apparently, global variables remain unassigned when used in a program, unless you explicitly ask to use their value... the problem being HOW ?

You may solve (part of) the problem by using "expr" :
Code: Select all
expr(val & "→#(" & cpyname & ")")

Re: problem with # command

Unread postPosted: 22 Feb 2015, 01:18
by compsystems
solved, is required to enter the variable name as a string

Code: Select all
chekid(varstr,type,content)
Prgm
  © Check the argument variable identifier
  Local vartype
  getType(#varstr)→vartype
  If vartype≠type or vartype="NONE" Then
    content → #varstr
  EndIf
EndPrgm


sample

delvar id1 [ENTER]

chekid("id1","NUM",85) [ENTER]

How the identifier id1 no contains a value, is assigned 85 to id1.

id1 = 85

now

chekid("id1","STR","hello") [ENTER]

How the identifier id1 contains a incorrect data type, reassigned a new value.

id1 = "hello"