Parse from variable [SOLVED]

Windows specific forum
LiK137
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Jun 23, 2010 5:13 pm

Parse from variable [SOLVED]

Post by LiK137 »

I want to know whether its possible or not:

Code: Select all

Procedure.s ip()
  ip$=HostnameToIP("P")  
  ProcedureReturn ip$
EndProcedure

InitNetwork()

MACadr$=GetMacAddress("192.168.1")

; cmd$="mkdir %TEMP%\@#ip()#@"
cmd$="rename %TEMP%\@#ip()#@ %TEMP%\@#RemoveString("+Chr(34)+MACadr$+Chr(34)+", "+Chr(34)+":"+Chr(34)+")#@"
Repeat
  oldcmdelimerstart=cmdelimerstart:oldcmdelimerend=cmdelimerend
;   i+1
  cmdelimerstart=FindString(cmd$,"@#",cmdelimerstart+1)
  cmdelimerend=FindString(cmd$,"#@",cmdelimerend+1)
  cmdx$=Mid(cmd$,cmdelimerstart+2,cmdelimerend-cmdelimerstart-2)
  ; Here I need to get string value of purebasic operation stored in cmdx$
  cmdx$=ParseString(cmdx$)  ; ParseString() - Is that possible???
  Debug cmdx$;+Str(i)+"  oldstart:"+Str(oldcmdelimerstart)+"  start:"+Str(cmdelimerstart)+"  oldend:"+Str(oldcmdelimerend)+"  end:"+Str(cmdelimerend)
Until cmdelimerstart<oldcmdelimerstart And cmdelimerend<oldcmdelimerend
Debug "Finita"
Here I need to get string value of purebasic operation stored in cmdx$
cmdx$=ParseString(cmdx$) ; ParseString() - Is that possible???
Last edited by LiK137 on Tue Jan 10, 2017 10:44 am, edited 1 time in total.
Amilcar Matos
User
User
Posts: 43
Joined: Thu Nov 27, 2014 3:10 pm
Location: San Juan, Puerto Rico

Re: Parse from variable

Post by Amilcar Matos »

Maybe what you are looking for is this. From PureBasic help file;
Syntax
Result$ = StringField(String$, Index, Delimiter$)
Description
Returns the string field at the specified index.

Hope it helps!
:D
User avatar
Demivec
Addict
Addict
Posts: 4259
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Parse from variable

Post by Demivec »

LiK137 wrote:Here I need to get string value of purebasic operation stored in cmdx$
cmdx$=ParseString(cmdx$) ; ParseString() - Is that possible???
If by parse you mean you only want to know the portion of the string that contains the command then use something similar to what Amilcar Matos suggested.

If you want to execute the command that you parsed then the answer is no, you can't do it. That would require PureBasic to compile that string and then execute it, which it won't.

You can build a parser and then execute the parsed commands. This would vary in complexity with the commands and their parameters that were possible and whether they were static (always the same) or changing.
Post Reply